@happyvertical/smrt-planner 0.57.5 → 0.57.7
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/agents/assistant.md +29 -2
- package/agents/shell.md +13 -0
- package/app/404.html +27 -30
- package/app/_app/immutable/assets/0.BaRFeYGU.css +1 -0
- package/app/_app/immutable/assets/AppShell.BkKNrxND.css +1 -0
- package/app/_app/immutable/assets/{ModelPage.FEM0ZnPM.css → ModelPage.SIoeO-AU.css} +1 -1
- package/app/_app/immutable/assets/app.BHwMQ9Zv.css +1 -0
- package/app/_app/immutable/assets/{forms.DXOeP4wZ.css → forms.BRdbPdvs.css} +1 -1
- package/app/_app/immutable/assets/icons.BDx21rPt.css +1 -0
- package/app/_app/immutable/assets/labels.Dxa6EyRI.css +1 -0
- package/app/_app/immutable/assets/planner.DOQVfcOi.css +1 -0
- package/app/_app/immutable/assets/state.C0UZEhxS.css +1 -0
- package/app/_app/immutable/chunks/{C1VofLtR.js → B2uXaQfZ.js} +1 -1
- package/app/_app/immutable/chunks/{DuZeZzOA.js → BQLQsso4.js} +1 -1
- package/app/_app/immutable/chunks/BdOPgmQ_.js +11 -0
- package/app/_app/immutable/chunks/BeL8dJx9.js +4 -0
- package/app/_app/immutable/chunks/{Bal1oPZu.js → Bhd-3niN.js} +1 -1
- package/app/_app/immutable/chunks/{CTlMHIE6.js → BqEBz5Vq.js} +1 -1
- package/app/_app/immutable/chunks/{GdHEbDDH.js → BxyJ_Q7v.js} +1 -1
- package/app/_app/immutable/chunks/{C3sRGrYK.js → C2OYATC6.js} +1 -1
- package/app/_app/immutable/chunks/C6AANt9H.js +26 -0
- package/app/_app/immutable/chunks/{BybfWt-B.js → C8FX0hli.js} +6 -6
- package/app/_app/immutable/chunks/{BDbFl7UA.js → CYhwv6d2.js} +1 -1
- package/app/_app/immutable/chunks/CdKHckEF.js +1 -0
- package/app/_app/immutable/chunks/CsaWd8kG.js +2 -0
- package/app/_app/immutable/chunks/Cwz7QFS4.js +2 -0
- package/app/_app/immutable/chunks/{BG9Gz_25.js → D3lXu_rt.js} +25 -25
- package/app/_app/immutable/chunks/{YGONf0jr.js → D8MqcCKq.js} +1 -1
- package/app/_app/immutable/chunks/DF-0MxNw.js +1 -0
- package/app/_app/immutable/chunks/DGaFQflg.js +1 -0
- package/app/_app/immutable/chunks/DIE02RSm.js +1 -0
- package/app/_app/immutable/chunks/DIgo5ngo.js +1 -0
- package/app/_app/immutable/chunks/{5ukUzDcw.js → Db12RzZi.js} +1 -1
- package/app/_app/immutable/chunks/{Cga8zF3r.js → DfN2k_EX.js} +1 -1
- package/app/_app/immutable/chunks/DmHVTNcC.js +4 -0
- package/app/_app/immutable/chunks/{gCpxN2IC.js → DmdvNG82.js} +2 -2
- package/app/_app/immutable/chunks/{DjJovMrk.js → DwIRC3h5.js} +1 -1
- package/app/_app/immutable/chunks/{nphy1MQF.js → FeyhlLIZ.js} +1 -1
- package/app/_app/immutable/chunks/ICDFUCZL.js +2 -0
- package/app/_app/immutable/chunks/IDZmjRDr.js +1 -0
- package/app/_app/immutable/chunks/JqlEoPqZ.js +1 -0
- package/app/_app/immutable/chunks/{BiEOJeYb.js → TcjpRcdI.js} +1 -1
- package/app/_app/immutable/chunks/Vt9hDpHd.js +1 -0
- package/app/_app/immutable/chunks/ezs6CGyc.js +1 -0
- package/app/_app/immutable/chunks/lUJaueNM.js +16 -0
- package/app/_app/immutable/entry/app.C5bxPKCP.js +2 -0
- package/app/_app/immutable/entry/start.CZvO61qD.js +1 -0
- package/app/_app/immutable/nodes/0.DFJFBCCB.js +7 -0
- package/app/_app/immutable/nodes/{1.DKP901Gn.js → 1.D_79m87b.js} +1 -1
- package/app/_app/immutable/nodes/{10.DNN0cVai.js → 10.20u2-jxn.js} +1 -1
- package/app/_app/immutable/nodes/{11.DgbmegX3.js → 11.CvMq32jC.js} +1 -1
- package/app/_app/immutable/nodes/{12.D5MtnJoE.js → 12.Cd0cy1AC.js} +1 -1
- package/app/_app/immutable/nodes/{13._rY66Xa_.js → 13.DYYS3YVQ.js} +1 -1
- package/app/_app/immutable/nodes/14.BEf5BJDn.js +1 -0
- package/app/_app/immutable/nodes/2.C_kLkHNl.js +24 -0
- package/app/_app/immutable/nodes/{3.V5uGCpGb.js → 3.CZw3hv8O.js} +1 -1
- package/app/_app/immutable/nodes/{4.CCwzLrgu.js → 4.WMU9NDex.js} +1 -1
- package/app/_app/immutable/nodes/{5.CgHzwpns.js → 5.CuqxSfl4.js} +1 -1
- package/app/_app/immutable/nodes/{6.CvQHLh_u.js → 6.BXLQB7tR.js} +1 -1
- package/app/_app/immutable/nodes/{7.7EIrly34.js → 7.BZvxNeL2.js} +1 -1
- package/app/_app/immutable/nodes/{8.DyyRBuTw.js → 8.Bj2O4pyx.js} +1 -1
- package/app/_app/immutable/nodes/{9.DcURs0gN.js → 9.yeFzeUHj.js} +1 -1
- package/app/_app/version.json +1 -1
- package/app/advanced-styles/index.html +34 -35
- package/app/ai/index.html +39 -40
- package/app/blueprint/index.html +29 -32
- package/app/cookbook/index.html +29 -32
- package/app/index.html +39 -42
- package/app/m/ads/AdDeliveryTier/index.html +36 -37
- package/app/m/ads/AdEvent/index.html +36 -37
- package/app/m/ads/AdFormat/index.html +36 -37
- package/app/m/ads/AdGroup/index.html +36 -37
- package/app/m/ads/AdVariation/index.html +36 -37
- package/app/m/analytics/AnalyticsDataStream/index.html +36 -37
- package/app/m/analytics/AnalyticsEvent/index.html +36 -37
- package/app/m/analytics/AnalyticsProperty/index.html +36 -37
- package/app/m/analytics/AnalyticsReport/index.html +36 -37
- package/app/m/approvals/ApprovalEvent/index.html +36 -37
- package/app/m/approvals/ApprovalPolicy/index.html +36 -37
- package/app/m/approvals/ApprovalRequest/index.html +36 -37
- package/app/m/assets/Asset/attachments/index.html +38 -39
- package/app/m/assets/Asset/index.html +36 -37
- package/app/m/assets/AssetAssociation/index.html +36 -37
- package/app/m/assets/AssetMetafield/index.html +36 -37
- package/app/m/assets/AssetStatus/index.html +36 -37
- package/app/m/assets/AssetType/index.html +36 -37
- package/app/m/assets/Folder/index.html +36 -37
- package/app/m/chat/AgentSession/index.html +36 -37
- package/app/m/chat/ChatMessage/index.html +36 -37
- package/app/m/chat/ChatParticipant/index.html +36 -37
- package/app/m/chat/ChatReaction/index.html +36 -37
- package/app/m/chat/ChatRoom/index.html +36 -37
- package/app/m/chat/ChatThread/index.html +36 -37
- package/app/m/chat/VoiceGatewayTurn/index.html +36 -37
- package/app/m/chat/VoiceSession/index.html +36 -37
- package/app/m/commerce/Agreement/index.html +36 -37
- package/app/m/commerce/Cart/index.html +36 -37
- package/app/m/commerce/Contract/index.html +36 -37
- package/app/m/commerce/ContractLineItem/index.html +36 -37
- package/app/m/commerce/Customer/index.html +36 -37
- package/app/m/commerce/DocumentTax/index.html +36 -37
- package/app/m/commerce/Estimate/index.html +36 -37
- package/app/m/commerce/Fulfillment/index.html +36 -37
- package/app/m/commerce/FulfillmentLineItem/index.html +36 -37
- package/app/m/commerce/HistoricalCustomerFunds/index.html +36 -37
- package/app/m/commerce/HistoricalCustomerFundsAllocation/index.html +36 -37
- package/app/m/commerce/HistoricalSalesLine/index.html +36 -37
- package/app/m/commerce/Invoice/index.html +36 -37
- package/app/m/commerce/InvoiceLineItem/index.html +36 -37
- package/app/m/commerce/Lease/index.html +36 -37
- package/app/m/commerce/LicenseSale/index.html +36 -37
- package/app/m/commerce/Order/index.html +36 -37
- package/app/m/commerce/Payment/index.html +36 -37
- package/app/m/commerce/PaymentAllocation/index.html +36 -37
- package/app/m/commerce/PaymentInstrument/index.html +36 -37
- package/app/m/commerce/PaymentIntent/index.html +36 -37
- package/app/m/commerce/Payout/index.html +36 -37
- package/app/m/commerce/ProductionOrder/index.html +36 -37
- package/app/m/commerce/PurchaseContract/index.html +36 -37
- package/app/m/commerce/PurchaseOrder/index.html +36 -37
- package/app/m/commerce/SalesContract/index.html +36 -37
- package/app/m/commerce/SupplierQuote/index.html +36 -37
- package/app/m/commerce/TaxCode/index.html +36 -37
- package/app/m/commerce/TaxComponent/index.html +36 -37
- package/app/m/commerce/TaxSettings/index.html +36 -37
- package/app/m/commerce/TaxSummaryReport/index.html +36 -37
- package/app/m/commerce/Vendor/index.html +36 -37
- package/app/m/commerce/WholesaleOrder/index.html +36 -37
- package/app/m/content/Content/index.html +36 -37
- package/app/m/content/ContentContribution/index.html +36 -37
- package/app/m/content/ContentContributionAttachment/index.html +36 -37
- package/app/m/content/ContentContributionRevision/index.html +36 -37
- package/app/m/content/ContentContributionType/index.html +36 -37
- package/app/m/content/ContentContributor/index.html +36 -37
- package/app/m/content/ContentCorrection/index.html +36 -37
- package/app/m/content/ContentFeedSource/index.html +36 -37
- package/app/m/content/ContentGovernanceAssignment/index.html +36 -37
- package/app/m/content/ContentGovernancePolicy/index.html +36 -37
- package/app/m/content/ContentGovernanceProfile/index.html +36 -37
- package/app/m/content/ContentReference/index.html +36 -37
- package/app/m/content/ContentReview/index.html +36 -37
- package/app/m/content/ContentVersion/index.html +36 -37
- package/app/m/events/Event/index.html +36 -37
- package/app/m/events/EventParticipant/index.html +36 -37
- package/app/m/events/EventSeries/index.html +36 -37
- package/app/m/events/EventType/index.html +36 -37
- package/app/m/expenses/Expense/index.html +36 -37
- package/app/m/facts/Fact/index.html +36 -37
- package/app/m/facts/FactContent/index.html +36 -37
- package/app/m/facts/FactEvidence/index.html +36 -37
- package/app/m/facts/FactSource/index.html +36 -37
- package/app/m/facts/FactSubject/index.html +36 -37
- package/app/m/facts/FactTag/index.html +36 -37
- package/app/m/fields/FieldPolicy/index.html +36 -37
- package/app/m/fields/FieldPolicySuggestion/index.html +36 -37
- package/app/m/fields/FieldUsageCounter/index.html +36 -37
- package/app/m/images/Image/index.html +36 -37
- package/app/m/inventory/InventoryLocation/index.html +36 -37
- package/app/m/inventory/StockLevel/index.html +36 -37
- package/app/m/inventory/StockMovement/index.html +36 -37
- package/app/m/ledgers/Account/index.html +36 -37
- package/app/m/ledgers/Journal/index.html +36 -37
- package/app/m/ledgers/JournalEntry/index.html +36 -37
- package/app/m/ledgers/Ledger/index.html +36 -37
- package/app/m/manufacturing/Assembly/index.html +36 -37
- package/app/m/manufacturing/BillOfMaterials/index.html +36 -37
- package/app/m/manufacturing/BomLine/index.html +36 -37
- package/app/m/manufacturing/Operation/index.html +36 -37
- package/app/m/manufacturing/ProductionRun/index.html +36 -37
- package/app/m/manufacturing/ProductionRunCompletion/index.html +36 -37
- package/app/m/manufacturing/RoutingStep/index.html +36 -37
- package/app/m/marketing/Campaign/index.html +36 -37
- package/app/m/marketing/CampaignChannel/index.html +36 -37
- package/app/m/marketing/CampaignMetricSnapshot/index.html +36 -37
- package/app/m/messages/Account/index.html +36 -37
- package/app/m/messages/Attachment/index.html +36 -37
- package/app/m/messages/Blacklist/index.html +36 -37
- package/app/m/messages/Email/failed-sends/index.html +38 -39
- package/app/m/messages/Email/index.html +36 -37
- package/app/m/messages/Email/mailbox/index.html +38 -39
- package/app/m/messages/EmailAccount/index.html +36 -37
- package/app/m/messages/EmailAttachment/index.html +36 -37
- package/app/m/messages/EmailFolder/index.html +36 -37
- package/app/m/messages/Message/index.html +36 -37
- package/app/m/messages/MessagingEndpoint/index.html +36 -37
- package/app/m/messages/PersonaMessageRoute/index.html +36 -37
- package/app/m/messages/SlackAccount/index.html +36 -37
- package/app/m/messages/SlackMessage/index.html +36 -37
- package/app/m/messages/TelegramAccount/index.html +36 -37
- package/app/m/messages/Tweet/index.html +36 -37
- package/app/m/messages/TwitterAccount/index.html +36 -37
- package/app/m/messages/Whitelist/index.html +36 -37
- package/app/m/messages/ZulipAccount/index.html +36 -37
- package/app/m/places/Place/index.html +36 -37
- package/app/m/places/PlaceType/index.html +36 -37
- package/app/m/products/Category/index.html +36 -37
- package/app/m/products/Material/index.html +36 -37
- package/app/m/products/Product/index.html +36 -37
- package/app/m/products/Product/ingredients/index.html +38 -39
- package/app/m/products/ProductVariant/index.html +36 -37
- package/app/m/products/Sku/index.html +36 -37
- package/app/m/profiles/ApiKey/index.html +36 -37
- package/app/m/profiles/Bot/index.html +36 -37
- package/app/m/profiles/MagicLinkToken/index.html +36 -37
- package/app/m/profiles/NostrIdentity/index.html +36 -37
- package/app/m/profiles/OidcIdentity/index.html +36 -37
- package/app/m/profiles/Organization/index.html +36 -37
- package/app/m/profiles/Person/index.html +36 -37
- package/app/m/profiles/Profile/index.html +36 -37
- package/app/m/profiles/ProfileMetadata/index.html +36 -37
- package/app/m/profiles/ProfileMetafield/index.html +36 -37
- package/app/m/profiles/ProfileRelationship/index.html +36 -37
- package/app/m/profiles/ProfileRelationshipTerm/index.html +36 -37
- package/app/m/profiles/ProfileRelationshipType/index.html +36 -37
- package/app/m/profiles/ProfileType/index.html +36 -37
- package/app/m/projects/Comment/index.html +36 -37
- package/app/m/projects/Issue/index.html +36 -37
- package/app/m/projects/Label/index.html +36 -37
- package/app/m/projects/Project/index.html +36 -37
- package/app/m/projects/ProjectIntegration/index.html +36 -37
- package/app/m/projects/PullRequest/index.html +36 -37
- package/app/m/projects/Repository/index.html +36 -37
- package/app/m/properties/Property/index.html +36 -37
- package/app/m/properties/Zone/index.html +36 -37
- package/app/m/reports/RuntimeReport/index.html +39 -37
- package/app/m/reports/SmrtPrincipalReportRefreshTask/index.html +36 -37
- package/app/m/reports/SmrtReportLock/index.html +36 -37
- package/app/m/reports/SmrtReportRefreshTask/index.html +36 -37
- package/app/m/reports/SmrtReportRun/index.html +36 -37
- package/app/m/reports/SmrtReportSchedule/index.html +36 -37
- package/app/m/reports/SmrtReportWatermark/index.html +36 -37
- package/app/m/sales/Agreement/index.html +36 -37
- package/app/m/sales/AttributionException/index.html +36 -37
- package/app/m/sales/AttributionPolicy/index.html +36 -37
- package/app/m/sales/Commission/index.html +36 -37
- package/app/m/sales/CommissionAdjustment/index.html +36 -37
- package/app/m/sales/CommissionPayout/index.html +36 -37
- package/app/m/sales/CommissionPlan/index.html +36 -37
- package/app/m/sales/Earner/index.html +36 -37
- package/app/m/sales/EarnerSourceAttribution/index.html +36 -37
- package/app/m/sales/EarningEvent/index.html +36 -37
- package/app/m/sales/ExecutedAgreement/index.html +36 -37
- package/app/m/sales/Lead/index.html +36 -37
- package/app/m/sales/Opportunity/index.html +36 -37
- package/app/m/sales/OpportunityConversion/index.html +36 -37
- package/app/m/sales/PipelineDefinition/index.html +36 -37
- package/app/m/sales/PipelineStage/index.html +36 -37
- package/app/m/sales/Referral/index.html +36 -37
- package/app/m/sales/ReferralAgreement/index.html +36 -37
- package/app/m/sales/ReferralLink/index.html +36 -37
- package/app/m/sales/ReferralProgram/index.html +36 -37
- package/app/m/sales/ReferralTermSnapshot/index.html +36 -37
- package/app/m/sales/ReferralTouch/index.html +36 -37
- package/app/m/sales/Referrer/index.html +36 -37
- package/app/m/sales/SalesActivity/index.html +36 -37
- package/app/m/sales/SalesRepresentative/index.html +36 -37
- package/app/m/sites/Site/index.html +36 -37
- package/app/m/sites/SiteAgentBinding/index.html +36 -37
- package/app/m/social/OAuthState/index.html +36 -37
- package/app/m/social/SocialAccount/index.html +36 -37
- package/app/m/social/SocialPost/index.html +36 -37
- package/app/m/social/SocialPostAnalyticsSnapshot/index.html +36 -37
- package/app/m/subscriptions/BillingAdjustment/index.html +36 -37
- package/app/m/subscriptions/ClientCharge/index.html +36 -37
- package/app/m/subscriptions/CreditGrant/index.html +36 -37
- package/app/m/subscriptions/PricingRule/index.html +36 -37
- package/app/m/subscriptions/RetailCharge/index.html +36 -37
- package/app/m/subscriptions/SpendingPolicy/index.html +36 -37
- package/app/m/subscriptions/SubscriptionPlan/index.html +36 -37
- package/app/m/subscriptions/TenantSubscription/index.html +36 -37
- package/app/m/subscriptions/TenantUsageMetric/index.html +36 -37
- package/app/m/support/ServiceTimeEntry/index.html +36 -37
- package/app/m/support/SupportAiRun/index.html +36 -37
- package/app/m/support/SupportAvailability/index.html +36 -37
- package/app/m/support/SupportCase/index.html +36 -37
- package/app/m/support/SupportCaseEvent/index.html +36 -37
- package/app/m/support/SupportChannelBinding/index.html +36 -37
- package/app/m/support/SupportCharge/index.html +36 -37
- package/app/m/support/SupportCompensation/index.html +36 -37
- package/app/m/support/SupportCompensationPlan/index.html +36 -37
- package/app/m/support/SupportEscalation/index.html +36 -37
- package/app/m/support/SupportInteraction/index.html +36 -37
- package/app/m/support/SupportPlan/index.html +36 -37
- package/app/m/support/SupportPolicy/index.html +36 -37
- package/app/m/support/SupportQualification/index.html +36 -37
- package/app/m/support/SupportServiceTarget/index.html +36 -37
- package/app/m/support/SupportSpecialist/index.html +36 -37
- package/app/m/support/SupportWorkLink/index.html +36 -37
- package/app/m/tags/Tag/index.html +36 -37
- package/app/m/tags/TagAlias/index.html +36 -37
- package/app/m/timesheets/AttendanceBreak/index.html +36 -37
- package/app/m/timesheets/AttendancePunch/index.html +36 -37
- package/app/m/timesheets/AttendanceSegment/index.html +36 -37
- package/app/m/timesheets/ServiceChargeSnapshot/index.html +36 -37
- package/app/m/timesheets/ServiceCompensationSnapshot/index.html +36 -37
- package/app/m/timesheets/ServiceTimeEntry/index.html +36 -37
- package/app/m/users/Group/index.html +36 -37
- package/app/m/users/GroupMember/index.html +36 -37
- package/app/m/users/GroupRole/index.html +36 -37
- package/app/m/users/Membership/index.html +36 -37
- package/app/m/users/MembershipOverride/index.html +36 -37
- package/app/m/users/Permission/index.html +36 -37
- package/app/m/users/Role/index.html +36 -37
- package/app/m/users/RolePermission/index.html +36 -37
- package/app/m/users/Session/index.html +36 -37
- package/app/m/users/Tenant/index.html +36 -37
- package/app/m/users/TenantIntegration/index.html +36 -37
- package/app/m/users/TenantPermissionOverride/index.html +36 -37
- package/app/m/users/User/index.html +36 -37
- package/app/m/video/Character/index.html +36 -37
- package/app/m/video/CharacterAsset/index.html +36 -37
- package/app/m/video/CompositeJob/index.html +36 -37
- package/app/m/video/Performer/index.html +36 -37
- package/app/m/video/PerformerAsset/index.html +36 -37
- package/app/m/video/Scene/index.html +36 -37
- package/app/m/video/SceneAsset/index.html +36 -37
- package/app/m/video/VideoComposition/index.html +36 -37
- package/app/m/video/VideoCompositionAsset/index.html +36 -37
- package/app/m/video/VideoSequence/index.html +36 -37
- package/app/m/video/VideoSequenceAsset/index.html +36 -37
- package/app/m/video/VideoShot/index.html +36 -37
- package/app/m/video/VideoShotAsset/index.html +36 -37
- package/app/m/video/VideoShotCharacter/index.html +36 -37
- package/app/m/video/VideoWorkflow/index.html +36 -37
- package/app/m/voice/VoiceOutput/index.html +36 -37
- package/app/m/voice/VoiceProfile/index.html +36 -37
- package/app/m/voice/VoiceSample/index.html +36 -37
- package/app/mcp.html +2 -2
- package/app/packages/ads/index.html +30 -33
- package/app/packages/analytics/index.html +30 -33
- package/app/packages/approvals/index.html +30 -33
- package/app/packages/assets/index.html +30 -33
- package/app/packages/chat/index.html +30 -33
- package/app/packages/comments/index.html +30 -33
- package/app/packages/commerce/index.html +30 -33
- package/app/packages/content/index.html +30 -33
- package/app/packages/events/index.html +30 -33
- package/app/packages/expenses/index.html +30 -33
- package/app/packages/facts/index.html +30 -33
- package/app/packages/fields/index.html +30 -33
- package/app/packages/human-resources/index.html +30 -33
- package/app/packages/images/index.html +30 -33
- package/app/packages/index.html +30 -33
- package/app/packages/ingestion/index.html +30 -33
- package/app/packages/inventory/index.html +30 -33
- package/app/packages/ledgers/index.html +30 -33
- package/app/packages/manufacturing/index.html +30 -33
- package/app/packages/marketing/index.html +30 -33
- package/app/packages/messages/index.html +30 -33
- package/app/packages/places/index.html +30 -33
- package/app/packages/preferences/index.html +30 -33
- package/app/packages/products/index.html +30 -33
- package/app/packages/profiles/index.html +30 -33
- package/app/packages/projects/index.html +30 -33
- package/app/packages/properties/index.html +30 -33
- package/app/packages/reports/index.html +30 -33
- package/app/packages/sales/index.html +30 -33
- package/app/packages/sites/index.html +30 -33
- package/app/packages/social/index.html +30 -33
- package/app/packages/subscriptions/index.html +30 -33
- package/app/packages/support/index.html +30 -33
- package/app/packages/tags/index.html +30 -33
- package/app/packages/timesheets/index.html +30 -33
- package/app/packages/users/index.html +30 -33
- package/app/packages/video/index.html +30 -33
- package/app/packages/voice/index.html +30 -33
- package/app/packages/webhooks/index.html +30 -33
- package/app/recipes/account-access/help/index.html +32 -35
- package/app/recipes/account-access/index.html +36 -38
- package/app/recipes/activity/help/index.html +32 -35
- package/app/recipes/activity/index.html +36 -38
- package/app/recipes/agreements/help/index.html +32 -35
- package/app/recipes/agreements/index.html +36 -38
- package/app/recipes/analytics.reports/help/index.html +32 -35
- package/app/recipes/analytics.reports/index.html +36 -38
- package/app/recipes/assets/help/index.html +32 -35
- package/app/recipes/assets/index.html +36 -38
- package/app/recipes/billing/help/index.html +32 -35
- package/app/recipes/billing/index.html +36 -38
- package/app/recipes/chat.assistant/help/index.html +32 -35
- package/app/recipes/chat.assistant/index.html +36 -38
- package/app/recipes/comments/help/index.html +32 -35
- package/app/recipes/comments/index.html +36 -38
- package/app/recipes/commerce.customers/help/index.html +32 -35
- package/app/recipes/commerce.customers/index.html +36 -38
- package/app/recipes/commerce.estimates/help/index.html +32 -35
- package/app/recipes/commerce.estimates/index.html +36 -38
- package/app/recipes/commerce.purchases/help/index.html +32 -35
- package/app/recipes/commerce.purchases/index.html +36 -38
- package/app/recipes/commerce.sales/help/index.html +32 -35
- package/app/recipes/commerce.sales/index.html +36 -38
- package/app/recipes/commerce.vendors/help/index.html +32 -35
- package/app/recipes/commerce.vendors/index.html +36 -38
- package/app/recipes/commerce.wholesale/help/index.html +32 -35
- package/app/recipes/commerce.wholesale/index.html +36 -38
- package/app/recipes/events.calendar/help/index.html +32 -35
- package/app/recipes/events.calendar/index.html +36 -38
- package/app/recipes/expenses.tracking/help/index.html +32 -35
- package/app/recipes/expenses.tracking/index.html +36 -38
- package/app/recipes/fields.form-customization/help/index.html +32 -35
- package/app/recipes/fields.form-customization/index.html +36 -38
- package/app/recipes/ingestion/help/index.html +32 -35
- package/app/recipes/ingestion/index.html +36 -38
- package/app/recipes/integrations/help/index.html +32 -35
- package/app/recipes/integrations/index.html +36 -38
- package/app/recipes/inventory.stock/help/index.html +32 -35
- package/app/recipes/inventory.stock/index.html +36 -38
- package/app/recipes/ledgers.bookkeeping/help/index.html +32 -35
- package/app/recipes/ledgers.bookkeeping/index.html +36 -38
- package/app/recipes/messages/help/index.html +32 -35
- package/app/recipes/messages/index.html +36 -38
- package/app/recipes/products/help/index.html +32 -35
- package/app/recipes/products/index.html +36 -38
- package/app/recipes/projects.tracker/help/index.html +32 -35
- package/app/recipes/projects.tracker/index.html +36 -38
- package/app/recipes/reports.materialized/help/index.html +32 -35
- package/app/recipes/reports.materialized/index.html +36 -38
- package/app/recipes/reports.runtime/help/index.html +32 -35
- package/app/recipes/reports.runtime/index.html +37 -39
- package/app/recipes/sales.pipeline/help/index.html +32 -35
- package/app/recipes/sales.pipeline/index.html +36 -38
- package/app/recipes/tags.taxonomy/help/index.html +32 -35
- package/app/recipes/tags.taxonomy/index.html +36 -38
- package/app/recipes/team-collaboration/help/index.html +32 -35
- package/app/recipes/team-collaboration/index.html +36 -38
- package/app/recipes/timesheets.time-entries/help/index.html +32 -35
- package/app/recipes/timesheets.time-entries/index.html +36 -38
- package/app/s/custom-accounts/index.html +29 -32
- package/app/s/custom-appointments/index.html +29 -32
- package/app/s/custom-billing/index.html +29 -32
- package/app/s/custom-bookings/index.html +79 -0
- package/app/s/custom-buying/index.html +29 -32
- package/app/s/custom-checkout/index.html +29 -32
- package/app/s/custom-classes/index.html +29 -32
- package/app/s/custom-clients/index.html +29 -32
- package/app/s/custom-events/index.html +29 -32
- package/app/s/custom-fleet/index.html +29 -32
- package/app/s/custom-gigs/index.html +79 -0
- package/app/s/custom-giving/index.html +29 -32
- package/app/s/custom-instruments/index.html +79 -0
- package/app/s/custom-jobs/index.html +29 -32
- package/app/s/custom-kitchen/index.html +29 -32
- package/app/s/custom-lessons/index.html +79 -0
- package/app/s/custom-material/index.html +29 -32
- package/app/s/custom-meetings/index.html +29 -32
- package/app/s/custom-members/index.html +29 -32
- package/app/s/custom-merch/index.html +79 -0
- package/app/s/custom-money/index.html +79 -0
- package/app/s/custom-paint/index.html +29 -32
- package/app/s/custom-parts/index.html +29 -32
- package/app/s/custom-rentals/index.html +29 -32
- package/app/s/custom-roastery/index.html +29 -32
- package/app/s/custom-schedule/index.html +29 -32
- package/app/s/custom-shelf/index.html +29 -32
- package/app/s/custom-shop/index.html +29 -32
- package/app/s/custom-students/index.html +79 -0
- package/app/s/custom-wholesale/index.html +29 -32
- package/app/s/custom-work/index.html +29 -32
- package/app/s/custom-yard/index.html +29 -32
- package/app/s/section-access-control/index.html +29 -32
- package/app/s/section-account-security/index.html +29 -32
- package/app/s/section-accounting/index.html +29 -32
- package/app/s/section-activity/index.html +29 -32
- package/app/s/section-agreements/index.html +29 -32
- package/app/s/section-analytics/index.html +29 -32
- package/app/s/section-assets/index.html +29 -32
- package/app/s/section-billing/index.html +29 -32
- package/app/s/section-calendar/index.html +29 -32
- package/app/s/section-catalog/index.html +29 -32
- package/app/s/section-chat.assistant/index.html +29 -32
- package/app/s/section-comments/index.html +29 -32
- package/app/s/section-fields.form-customization/index.html +29 -32
- package/app/s/section-ingestion/index.html +29 -32
- package/app/s/section-integrations/index.html +29 -32
- package/app/s/section-messages/index.html +29 -32
- package/app/s/section-more/index.html +29 -32
- package/app/s/section-operations/index.html +29 -32
- package/app/s/section-projects/index.html +29 -32
- package/app/s/section-purchasing/index.html +29 -32
- package/app/s/section-reports.materialized/index.html +29 -32
- package/app/s/section-reports.runtime/index.html +29 -32
- package/app/s/section-sales/index.html +29 -32
- package/app/s/section-taxonomy/index.html +29 -32
- package/app/s/section-team/index.html +29 -32
- package/app/s/section-work/index.html +29 -32
- package/dist/assistant/change.d.ts +10 -1
- package/dist/assistant/change.d.ts.map +1 -1
- package/dist/assistant/change.js +6 -1
- package/dist/assistant/prompt.d.ts +10 -1
- package/dist/assistant/prompt.d.ts.map +1 -1
- package/dist/assistant/prompt.js +42 -7
- package/dist/assistant/session.svelte.d.ts +6 -0
- package/dist/assistant/session.svelte.d.ts.map +1 -1
- package/dist/assistant/session.svelte.js +6 -0
- package/dist/assistant/transport.d.ts +23 -3
- package/dist/assistant/transport.d.ts.map +1 -1
- package/dist/assistant/transport.js +356 -13
- package/dist/catalog/catalog.json +107 -41
- package/dist/components/BrowserAssistant.svelte +26 -0
- package/dist/components/BrowserAssistant.svelte.d.ts.map +1 -1
- package/dist/components/ModelPage.svelte +36 -4
- package/dist/components/ModelPage.svelte.d.ts.map +1 -1
- package/dist/components/PlannerReports.svelte +61 -0
- package/dist/components/PlannerReports.svelte.d.ts +10 -0
- package/dist/components/PlannerReports.svelte.d.ts.map +1 -0
- package/dist/components/PlannerSavedReportsWidget.svelte +38 -0
- package/dist/components/PlannerSavedReportsWidget.svelte.d.ts +9 -0
- package/dist/components/PlannerSavedReportsWidget.svelte.d.ts.map +1 -0
- package/dist/components/ReportProposalCard.svelte +63 -0
- package/dist/components/ReportProposalCard.svelte.d.ts +17 -0
- package/dist/components/ReportProposalCard.svelte.d.ts.map +1 -0
- package/dist/components/SectionOverview.svelte +22 -1
- package/dist/components/SectionOverview.svelte.d.ts.map +1 -1
- package/dist/components/ThemeBridge.svelte +2 -2
- package/dist/core/prompt.d.ts.map +1 -1
- package/dist/core/prompt.js +7 -1
- package/dist/core/reply.d.ts +6 -0
- package/dist/core/reply.d.ts.map +1 -1
- package/dist/core/reply.js +11 -0
- package/dist/data/packs.d.ts.map +1 -1
- package/dist/data/packs.js +415 -0
- package/dist/data/planner-source.d.ts.map +1 -1
- package/dist/data/planner-source.js +4 -1
- package/dist/library/icons.d.ts.map +1 -1
- package/dist/library/icons.js +10 -0
- package/dist/library/library.json +506 -0
- package/dist/overviews/definitions.d.ts.map +1 -1
- package/dist/overviews/definitions.js +6 -1
- package/dist/overviews/registry.d.ts.map +1 -1
- package/dist/overviews/registry.js +9 -5
- package/dist/planner/Planner.svelte +17 -0
- package/dist/planner/Planner.svelte.d.ts.map +1 -1
- package/dist/planner/instance.d.ts +6 -0
- package/dist/planner/instance.d.ts.map +1 -1
- package/dist/planner/shell.d.ts.map +1 -1
- package/dist/planner/shell.js +3 -1
- package/dist/reports/intent.d.ts +106 -0
- package/dist/reports/intent.d.ts.map +1 -0
- package/dist/reports/intent.js +667 -0
- package/dist/reports/planner.d.ts +33 -0
- package/dist/reports/planner.d.ts.map +1 -0
- package/dist/reports/planner.js +60 -0
- package/dist/reports/sources.d.ts +36 -0
- package/dist/reports/sources.d.ts.map +1 -0
- package/dist/reports/sources.js +125 -0
- package/dist/reports/store.d.ts +64 -0
- package/dist/reports/store.d.ts.map +1 -0
- package/dist/reports/store.js +214 -0
- package/dist/smrt-version.d.ts +1 -1
- package/dist/smrt-version.js +1 -1
- package/package.json +54 -54
- package/app/_app/immutable/assets/0.C8CwV4Fz.css +0 -1
- package/app/_app/immutable/assets/AppShell.Dnc9PAvY.css +0 -1
- package/app/_app/immutable/assets/app.4ScdTV_S.css +0 -1
- package/app/_app/immutable/assets/labels.DrQMsG17.css +0 -1
- package/app/_app/immutable/assets/state.CkVocVUJ.css +0 -1
- package/app/_app/immutable/chunks/9pRTae44.js +0 -1
- package/app/_app/immutable/chunks/BhU_yBI_.js +0 -1
- package/app/_app/immutable/chunks/Bsn3IIve.js +0 -4
- package/app/_app/immutable/chunks/C_3CJO_1.js +0 -1
- package/app/_app/immutable/chunks/Cr4byQts.js +0 -24
- package/app/_app/immutable/chunks/CtjBwCj8.js +0 -1
- package/app/_app/immutable/chunks/CyUSxz1P.js +0 -4
- package/app/_app/immutable/chunks/J9kOiFLO.js +0 -11
- package/app/_app/immutable/chunks/M-CuJzQN.js +0 -1
- package/app/_app/immutable/chunks/NppCG--v.js +0 -1
- package/app/_app/immutable/chunks/O8DAZ_le.js +0 -1
- package/app/_app/immutable/chunks/d_dqmeIr.js +0 -1
- package/app/_app/immutable/chunks/gMSmS-_y.js +0 -2
- package/app/_app/immutable/entry/app.B4gMiHwR.js +0 -2
- package/app/_app/immutable/entry/start.BXkBl20Z.js +0 -1
- package/app/_app/immutable/nodes/0.2MYMg80l.js +0 -9
- package/app/_app/immutable/nodes/14.B6TD25VU.js +0 -1
- package/app/_app/immutable/nodes/2.x9WyxQ1S.js +0 -24
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,bt as t,c as n,et as r,nt as i,r as a,t as o,tt as s,vt as c}from"./DG3qFFTE.js";import{i as l,n as u,r as d,t as f}from"./Dt-HX3Vu.js";new URL(`sveltekit-internal://`);function p(e,t){return e===`/`||t===`ignore`?e:t===`never`?e.endsWith(`/`)?e.slice(0,-1):e:t===`always`&&!e.endsWith(`/`)?e+`/`:e}function ee(e){return e.split(`%25`).map(decodeURI).join(`%25`)}function te(e){for(let t in e)e[t]=decodeURIComponent(e[t]);return e}function m({href:e}){return e.split(`#`)[0]}function h(e,t,n,r=!1){let i=new URL(e);Object.defineProperty(i,"searchParams",{value:new Proxy(i.searchParams,{get(e,r){if(r===`get`||r===`getAll`||r===`has`)return(t,...i)=>(n(t),e[r](t,...i));t();let i=Reflect.get(e,r);return typeof i==`function`?i.bind(e):i}}),enumerable:!0,configurable:!0});let a=[`href`,`pathname`,`search`,`toString`,`toJSON`];r&&a.push(`hash`);for(let n of a)Object.defineProperty(i,n,{get(){return t(),e[n]},enumerable:!0,configurable:!0});return i}function g(){}function ne(...e){let t=5381;for(let n of e)if(typeof n==`string`){let e=n.length;for(;e;)t=t*33^n.charCodeAt(--e)}else if(ArrayBuffer.isView(n)){let e=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r=e.length;for(;r;)t=t*33^e[--r]}else throw TypeError(`value must be a string or TypedArray`);return(t>>>0).toString(36)}var re=window.fetch;window.fetch=(e,t)=>((e instanceof Request?e.method:t?.method||`GET`)!==`GET`&&_.delete(ie(e)),re(e,t));var _=new Map;function v(e,t){let n=ie(e,t),r=document.querySelector(n);if(r?.textContent){r.remove();let{body:e,...t}=JSON.parse(r.textContent);r.getAttribute(`data-b64`)!==null&&(e=f(e));let i=r.getAttribute(`data-ttl`);return i&&_.set(n,{body:e,init:t,ttl:1e3*Number(i)}),Promise.resolve(new Response(e,t))}return window.fetch(e,t)}function y(e,t,n){if(_.size>0){let t=ie(e,n),r=_.get(t);if(r){if(performance.now()<r.ttl&&[`default`,`force-cache`,`only-if-cached`,void 0].includes(n?.cache))return new Response(r.body,r.init);_.delete(t)}}return window.fetch(t,n)}function ie(e,t){let n=`script[data-sveltekit-fetched][data-url=${JSON.stringify(e instanceof Request?e.url:e)}]`;if(t?.headers||t?.body){let e=[];t.headers&&e.push([...new Headers(t.headers)].join(`,`)),t.body&&(typeof t.body==`string`||ArrayBuffer.isView(t.body))&&e.push(t.body),n+=`[data-hash="${ne(...e)}"]`}return n}var b=/^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/,ae=/^\/\((?:[^)]+)\)$/;function oe(e){let t=[];return{pattern:e===`/`||ae.test(e)?/^\/$/:RegExp(`^${ce(e).map(e=>{let n=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(e);if(n)return t.push({name:n[1],matcher:n[2],optional:!1,rest:!0,chained:!0}),`(?:/([^]*))?`;let r=/^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(e);if(r)return t.push({name:r[1],matcher:r[2],optional:!0,rest:!1,chained:!0}),`(?:/([^/]+))?`;if(!e)return;let i=e.split(/\[(.+?)\](?!\])/);return`/`+i.map((e,n)=>{if(n%2){if(e.startsWith(`x+`))return ue(String.fromCharCode(parseInt(e.slice(2),16)));if(e.startsWith(`u+`))return ue(String.fromCharCode(...e.slice(2).split(`-`).map(e=>parseInt(e,16))));let[,r,a,o,s]=b.exec(e);return t.push({name:o,matcher:s,optional:!!r,rest:!!a,chained:a?n===1&&i[0]===``:!1}),a?`([^]*?)`:r?`([^/]*)?`:`([^/]+?)`}return ue(e)}).join(``)}).join(``)}/?$`),params:t}}function se(e){return e!==``&&!/^\([^)]+\)$/.test(e)}function ce(e){return e.slice(1).split(`/`).filter(se)}function le(e,t,n){let r={},i=e.slice(1),a=i.filter(e=>e!==void 0),o=0;for(let e=0;e<t.length;e+=1){let s=t[e],c=i[e-o];if(s.chained&&s.rest&&o&&(c=i.slice(e-o,e+1).filter(e=>e).join(`/`),o=0),c===void 0){if(s.rest)c=``;else continue}if(!s.matcher||n[s.matcher](c)){r[s.name]=c;let n=t[e+1],l=i[e+1];n&&!n.rest&&n.optional&&l&&s.chained&&(o=0),!n&&!l&&Object.keys(r).length===a.length&&(o=0)}else if(s.optional&&s.chained)o++;else return}if(!o)return r}function ue(e){return e.normalize().replace(/[[\]]/g,`\\$&`).replace(/%/g,`%25`).replace(/\//g,`%2[Ff]`).replace(/\?/g,`%3[Ff]`).replace(/#/g,`%23`).replace(/[.*+?^${}()|\\]/g,`\\$&`)}function de({nodes:e,server_loads:t,dictionary:n,matchers:r}){let i=new Set(t);return Object.entries(n).map(([t,[n,i,s]])=>{let{pattern:c,params:l}=oe(t),u={id:t,exec:e=>{let t=c.exec(e);if(t)return le(t,l,r)},errors:[1,...s||[]].map(t=>e[t]),layouts:[0,...i||[]].map(o),leaf:a(n)};return u.errors.length=u.layouts.length=Math.max(u.errors.length,u.layouts.length),u});function a(t){let n=t<0;return n&&(t=~t),[n,e[t]]}function o(t){return t===void 0?t:[i.has(t),e[t]]}}function fe(e,t=JSON.parse){try{return t(sessionStorage[e])}catch{}}function pe(e,t,n=JSON.stringify){let r=n(t);try{sessionStorage[e]=r}catch{}}var x=globalThis.__sveltekit_qeoaal?.base??``,me=globalThis.__sveltekit_qeoaal?.assets??x??``,he=`1792257399125`,ge=`sveltekit:snapshot`,_e=`sveltekit:scroll`,ve=`sveltekit:states`,ye=`sveltekit:pageurl`,S=`sveltekit:history`,C=`sveltekit:navigation`,w={tap:1,hover:2,viewport:3,eager:4,off:-1,false:-1},be=location.origin;function T(e){if(e instanceof URL)return e;let t=document.baseURI;if(!t){let e=document.getElementsByTagName(`base`);t=e.length?e[0].href:document.URL}return new URL(e,t)}function E(){return{x:pageXOffset,y:pageYOffset}}function D(e,t){return e.getAttribute(`data-sveltekit-${t}`)}var xe={...w,"":w.hover};function Se(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11&&(t=t.host),t}function Ce(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()===`A`&&e.hasAttribute(`href`))return e;e=Se(e)}}function we(e,t,n){let r;try{if(r=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI),n&&r.hash.match(/^#[^/]/)){let e=location.hash.split(`#`)[1]||`/`;r.hash=`#${e}${r.hash}`}}catch{}let i=e instanceof SVGAElement?e.target.baseVal:e.target,a=!r||!!i||k(r,t,n)||(e.getAttribute(`rel`)||``).split(/\s+/).includes(`external`),o=r?.origin===be&&e.hasAttribute(`download`);return{url:r,external:a,target:i,download:o}}function O(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=e;for(;s&&s!==document.documentElement;)r===null&&(r=D(s,`preload-code`)),i===null&&(i=D(s,`preload-data`)),t===null&&(t=D(s,`keepfocus`)),n===null&&(n=D(s,`noscroll`)),a===null&&(a=D(s,`reload`)),o===null&&(o=D(s,`replacestate`)),s=Se(s);function c(e){switch(e){case``:case`true`:return!0;case`off`:case`false`:return!1;default:return}}return{preload_code:xe[r??`off`],preload_data:xe[i??`off`],keepfocus:c(t),noscroll:c(n),reload:c(a),replace_state:c(o)}}function Te(e){let t=n(e),r=!0;function i(){r=!0,t.update(e=>e)}function a(e){r=!1,t.set(e)}function o(e){let n;return t.subscribe(t=>{(n===void 0||r&&t!==n)&&e(n=t)})}return{notify:i,set:a,subscribe:o}}var Ee={v:g};function De(){let{set:e,subscribe:t}=n(!1),r;async function i(){clearTimeout(r);try{let t=await fetch(`${me}/_app/version.json`,{headers:{pragma:`no-cache`,"cache-control":`no-cache`}});if(!t.ok)return!1;let n=(await t.json()).version!==he;return n&&(e(!0),Ee.v(),clearTimeout(r)),n}catch{return!1}}return{subscribe:t,check:i}}function k(e,t,n){return e.origin!==be||!e.pathname.startsWith(t)?!0:n?e.pathname!==location.pathname:!1}function Oe(e){}Uint8Array.fromBase64,typeof process==`object`&&process.versions?.node,Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`).get,typeof SharedArrayBuffer>`u`||Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`).get;var ke=new Set([`load`,`prerender`,`csr`,`ssr`,`trailingSlash`,`config`]);[...ke],[...new Set([...ke])];function Ae(e){return e.filter(e=>e!=null)}function A(e,t){return e+`/`+t}function je(e){return e instanceof u||e instanceof l?e.status:500}function Me(e){return e instanceof l?e.text:`Internal Error`}var j,M,Ne,Pe=a.toString().includes(`$$`)||/function \w+\(\) \{\}/.test(a.toString()),Fe=`a:`;Pe?(j={data:{},form:null,error:null,params:{},route:{id:null},state:{},status:-1,url:new URL(Fe)},M={current:null},Ne={current:!1}):(j=new class{#e=t({});get data(){return e(this.#e)}set data(e){c(this.#e,e)}#t=t(null);get form(){return e(this.#t)}set form(e){c(this.#t,e)}#n=t(null);get error(){return e(this.#n)}set error(e){c(this.#n,e)}#r=t({});get params(){return e(this.#r)}set params(e){c(this.#r,e)}#i=t({id:null});get route(){return e(this.#i)}set route(e){c(this.#i,e)}#a=t({});get state(){return e(this.#a)}set state(e){c(this.#a,e)}#o=t(-1);get status(){return e(this.#o)}set status(e){c(this.#o,e)}#s=t(new URL(Fe));get url(){return e(this.#s)}set url(e){c(this.#s,e)}},M=new class{#e=t(null);get current(){return e(this.#e)}set current(e){c(this.#e,e)}},Ne=new class{#e=t(!1);get current(){return e(this.#e)}set current(e){c(this.#e,e)}},Ee.v=()=>Ne.current=!0);function Ie(e){Object.assign(j,e)}var Le={spanContext(){return Re},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this},addLink(){return this},addLinks(){return this}},Re={traceId:``,spanId:``,traceFlags:0},{onMount:ze,tick:Be}=o,Ve=i??(e=>e()),He=new Set([`icon`,`shortcut icon`,`apple-touch-icon`]),N=null,P=fe(`sveltekit:scroll`)??{},F=fe(`sveltekit:snapshot`)??{},I={url:Te({}),page:Te({}),navigating:n(null),updated:De()};function L(e){P[e]=E()}function Ue(e,t){let n=e+1;for(;P[n];)delete P[n],n+=1;for(n=t+1;F[n];)delete F[n],n+=1}function R(e,t=!1){return t?location.replace(e.href):location.href=e.href,new Promise(g)}async function We(){if(`serviceWorker`in navigator){let e=await navigator.serviceWorker.getRegistration(x||`/`);e&&await e.update()}}var Ge,Ke,z,B,qe,V,Je={},Ye={},Xe=[],Ze=[],H=null;function Qe(){H?.fork?.then(e=>e?.discard()),H=null,Z={element:void 0,href:void 0}}var $e=new Map,et=new Set,tt=new Set,U=new Set,W={branch:[],error:null,url:null,nav:null},nt=!1,rt=!1,it=!0,G=!1,K=!1,at=!1,ot=!1,st,q,J,Y,ct=new Set,lt=new Map,ut=new Map;async function dt(e,t,n){if(globalThis.__sveltekit_qeoaal.data){let{q:e={},p:t={},l:n={},f:r={}}=globalThis.__sveltekit_qeoaal.data;for(let t in e)Je[t]=e[t];for(let e in n)Je[e]=n[e];for(let e in r)Je[e]=r[e];for(let e in t)Ye[e]=t[e]}document.URL!==location.href&&(location.href=location.href),V=e,await e.hooks.init?.(),Ge=de(e),B=document.documentElement,qe=t,Ke=e.nodes[0],z=e.nodes[1],Ke(),z(),q=history.state?.[S],J=history.state?.[C],q||(q=J=Date.now(),history.replaceState({...history.state,[S]:q,[C]:J},``));let r=P[q];function i(){r&&(history.scrollRestoration=`manual`,scrollTo(r.x,r.y))}n?(i(),await Gt(qe,n)):(await X({type:`enter`,url:T(V.hash?Xt(new URL(location.href)):location.href),replace_state:!0}),i()),Wt()}function ft(){Xe.length=0,ot=!1}function pt(e){Ze.some(e=>e?.snapshot)&&(F[e]=Ze.map(e=>e?.snapshot?.capture()))}function mt(e){F[e]?.forEach((e,t)=>{Ze[t]?.snapshot?.restore(e)})}function ht(){L(q),pe(_e,P),pt(J),pe(ge,F)}async function gt(e,t,n,r){let i,a;t.invalidateAll&&Qe(),await X({type:`goto`,url:T(e),keepfocus:t.keepFocus,noscroll:t.noScroll,replace_state:t.replaceState,state:t.state,redirect_count:n,nav_token:r,accept:()=>{if(t.invalidateAll){ot=!0,i=new Set;for(let[e,t]of lt)for(let[n,r]of t)r.resource?.reset(),i.add(A(e,n));a=new Set;for(let[e,t]of ut)for(let n of t.keys())a.add(A(e,n))}t.invalidate&&t.invalidate.forEach(Vt)}}),t.invalidateAll&&s().then(s).then(()=>{for(let[e,t]of lt)for(let[n,{resource:r}]of t)i?.has(A(e,n))&&r.start();for(let[e,t]of ut)for(let[n,{resource:r}]of t)a?.has(A(e,n))&&r.reconnect()})}async function _t(e){if(e.id!==H?.id){Qe();let t={};ct.add(t),H={id:e.id,token:t,promise:Dt({...e,preload:t}).then(e=>(ct.delete(t),e.type===`loaded`&&e.state.error&&Qe(),e)),fork:null}}return H.promise}async function vt(e){let t=(await jt(e,!1))?.route;t&&await Promise.all([...t.layouts,t.leaf].filter(Boolean).map(e=>e[1]()))}async function yt(e,t,n){let r={params:W.params,route:{id:W.route?.id??null},url:new URL(location.href)};if(W={...e.state,nav:r},Ie(e.props.page),st=new V.root({target:t,props:{...e.props,stores:I,components:Ze},hydrate:n,sync:!1,transformError:void 0}),await Promise.resolve(),n){let e={from:null,to:{...r,scroll:P[q]??E()},willUnload:!1,type:`enter`,complete:Promise.resolve()};U.forEach(t=>t(e))}mt(J),rt=!0}async function bt({url:e,params:t,branch:n,errors:r,status:i,error:a,route:o,form:s}){let c=`never`;if(x&&(e.pathname===x||e.pathname===x+`/`))c=`always`;else for(let e of n)e?.slash!==void 0&&(c=e.slash);e.pathname=p(e.pathname,c),e.search=e.search;let l={type:`loaded`,state:{url:e,params:t,branch:n,error:a,route:o},props:{constructors:Ae(n).map(e=>e.node.component),page:$(j)}};s!==void 0&&(l.props.form=s);let u={},d=!j,f=0;for(let e=0;e<Math.max(n.length,W.branch.length);e+=1){let t=n[e],r=W.branch[e];t?.data!==r?.data&&(d=!0),t&&(u={...u,...t.data},d&&(l.props[`data_${f}`]=u),f+=1)}return(!W.url||e.href!==W.url.href||W.error!==a||s!==void 0&&s!==j.form||d)&&(l.props.page={error:a,params:t,route:{id:o?.id??null},state:{},status:i,url:new URL(e),form:s??null,data:d?u:j.data}),l}async function xt({loader:e,parent:t,url:n,params:r,route:i,server_data_node:a}){let o=null,s=!0,c={dependencies:new Set,params:new Set,parent:!1,route:!1,url:!1,search_params:new Set},l=await e();if(l.universal?.load){function e(...e){for(let t of e){let{href:e}=new URL(t,n);c.dependencies.add(e)}}let u={tracing:{enabled:!1,root:Le,current:Le},route:new Proxy(i,{get:(e,t)=>(s&&(c.route=!0),e[t])}),params:new Proxy(r,{get:(e,t)=>(s&&c.params.add(t),e[t])}),data:a?.data??null,url:h(n,()=>{s&&(c.url=!0)},e=>{s&&c.search_params.add(e)},V.hash),async fetch(t,r){t instanceof Request&&(r={body:t.method===`GET`||t.method===`HEAD`?void 0:await t.blob(),cache:t.cache,credentials:t.credentials,headers:[...t.headers].length>0?t?.headers:void 0,integrity:t.integrity,keepalive:t.keepalive,method:t.method,mode:t.mode,redirect:t.redirect,referrer:t.referrer,referrerPolicy:t.referrerPolicy,signal:t.signal,...r});let{resolved:i,promise:a}=St(t,r,n);return s&&e(i.href),a},setHeaders:g,depends:e,parent(){return s&&(c.parent=!0),t()},untrack(e){s=!1;try{return e()}finally{s=!0}}};o=await l.universal.load.call(null,u)??null}return{node:l,loader:e,server:a,universal:l.universal?.load?{type:`data`,data:o,uses:c}:null,data:o??a?.data??null,slash:l.universal?.trailingSlash??a?.slash}}function St(e,t,n){let r=e instanceof Request?e.url:e,i=new URL(r,n);return i.origin===n.origin&&(r=i.href.slice(n.origin.length)),{resolved:i,promise:rt?y(r,i.href,t):v(r,t)}}function Ct(e,t,n,r,i,a){if(ot)return!0;if(!i)return!1;if(i.parent&&e||i.route&&t||i.url&&n)return!0;for(let e of i.search_params)if(r.has(e))return!0;for(let e of i.params)if(a[e]!==W.params[e])return!0;for(let e of i.dependencies)if(Xe.some(t=>t(new URL(e))))return!0;return!1}function wt(e,t){return e?.type===`data`?e:e?.type===`skip`?t??null:null}function Tt(e,t){if(!e)return new Set(t.searchParams.keys());let n=new Set([...e.searchParams.keys(),...t.searchParams.keys()]);for(let r of n){let i=e.searchParams.getAll(r),a=t.searchParams.getAll(r);i.every(e=>a.includes(e))&&a.every(e=>i.includes(e))&&n.delete(r)}return n}function Et({error:e,url:t,route:n,params:r}){return{type:`loaded`,state:{error:e,url:t,route:n,params:r,branch:[]},props:{page:$(j),constructors:[]}}}async function Dt({id:e,invalidating:t,url:n,params:r,route:i,preload:a}){if(H?.id===e)return ct.delete(H.token),H.promise;let{errors:o,layouts:s,leaf:c}=i,l=[...s,c];o.forEach(e=>e?.().catch(g)),l.forEach(e=>e?.[1]().catch(g));let f=W.url?e!==Nt(W.url):!1,p=W.route?i.id!==W.route.id:!1,ee=Tt(W.url,n),te=!1,m=l.map(async(e,t)=>{if(!e)return;let a=W.branch[t];return e[1]===a?.loader&&!Ct(te,p,f,ee,a.universal?.uses,r)?a:(te=!0,xt({loader:e[1],url:n,params:r,route:i,parent:async()=>{let e={};for(let n=0;n<t;n+=1)Object.assign(e,(await m[n])?.data);return e},server_data_node:wt(e[0]?{type:`skip`}:null,e[0]?a?.server:void 0)}))});for(let e of m)e.catch(g);let h=[];for(let e=0;e<l.length;e+=1)if(l[e])try{h.push(await m[e])}catch(t){if(t instanceof d)return{type:`redirect`,location:t.location};if(a&&ct.has(a))return Et({error:await Q(t,{params:r,url:n,route:{id:i.id}}),url:n,params:r,route:i});let s=je(t),c;if(t instanceof u)c=t.body;else{if(await I.updated.check())return await We(),await R(n);c=await Q(t,{params:r,url:n,route:{id:i.id}})}let l=await Ot(e,h,o);return l?bt({url:n,params:r,branch:h.slice(0,l.idx).concat(l.node),errors:o,status:s,error:c,route:i}):await Ft(n,{id:i.id},c,s)}else h.push(void 0);return bt({url:n,params:r,branch:h,errors:o,status:200,error:null,route:i,form:t?void 0:null})}async function Ot(e,t,n){for(;e--;)if(n[e]){let r=e;for(;!t[r];)--r;try{return{idx:r+1,node:{node:await n[e](),loader:n[e],data:{},server:null,universal:null}}}catch{continue}}}async function kt({status:e,error:t,url:n,route:r}){let i={};try{return bt({url:n,params:i,branch:[await xt({loader:Ke,url:n,params:i,route:r,parent:()=>Promise.resolve({}),server_data_node:wt(null)}),{node:await z(),loader:z,universal:null,server:null,data:null}],status:e,error:t,errors:[],route:null})}catch(t){if(t instanceof d){await gt(new URL(t.location,location.href),{},0);return}let a=await V.get_error_template(),o=await Q(t,{url:n,params:i,route:r}),s=a({status:e,message:String(o?.message??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}),c=new DOMParser().parseFromString(s,`text/html`);throw document.documentElement.replaceChild(document.adoptNode(c.head),document.head),document.documentElement.replaceChild(document.adoptNode(c.body),document.body),t}}async function At(e){let t=e.href;if($e.has(t))return $e.get(t);let n;try{let r=(async()=>{let t=await V.hooks.reroute({url:new URL(e),fetch:async(t,n)=>St(t,n,e).promise})??e;if(typeof t==`string`){let n=new URL(e);V.hash?n.hash=t:n.pathname=t,t=n}return t})();$e.set(t,r),n=await r}catch{$e.delete(t);return}return n}async function jt(e,t){if(e&&!k(e,x,V.hash)){let n=await At(e);if(!n)return;let r=Mt(n);for(let n of Ge){let i=n.exec(r);if(i)return{id:Nt(e),invalidating:t,route:n,params:te(i),url:e}}}}function Mt(e){return ee(V.hash?e.hash.replace(/^#/,``).replace(/[?#].+/,``):e.pathname.slice(x.length))||`/`}function Nt(e){return(V.hash?e.hash.replace(/^#/,``):e.pathname)+e.search}function Pt({url:e,type:t,intent:n,delta:r,event:i,scroll:a}){let o=!1,s=Yt(W,n,e,t,a??null);r!==void 0&&(s.navigation.delta=r),i!==void 0&&(s.navigation.event=i);let c={...s.navigation,cancel:()=>{o=!0,s.reject(Error(`navigation cancelled`))}};return G||et.forEach(e=>e(c)),o?null:s}async function X({type:e,url:t,popped:n,keepfocus:i,noscroll:a,replace_state:o,state:c={},redirect_count:u=0,nav_token:d={},accept:f=g,block:p=g,event:ee}){let te=Y;Y=d;let m=await jt(t,!1),h=e===`enter`?Yt(W,m,t,e):Pt({url:t,type:e,delta:n?.delta,intent:m,scroll:n?.scroll,event:ee});if(!h){p(),Y===d&&(Y=te);return}let ne=q,re=J;f(),G=!0,rt&&h.navigation.type!==`enter`&&I.navigating.set(M.current=h.navigation);let _=m&&await Dt(m);if(!_){if(k(t,x,V.hash))return await R(t,o);_=await Ft(t,{id:null},await Q(new l(404,`Not Found`,`Not found: ${t.pathname}`),{url:t,params:{},route:{id:null}}),404,o)}if(t=m?.url||t,Y!==d){h.reject(Error(`navigation aborted`));return}if(!_)return;if(_.type===`redirect`){if(u<20){await X({type:e,url:new URL(_.location,t),popped:n,keepfocus:i,noscroll:a,replace_state:o,state:c,redirect_count:u+1,nav_token:d}),h.fulfil(void 0);return}if(_=await kt({status:500,error:await Q(Error(`Redirect loop`),{url:t,params:{},route:{id:null}}),url:t,route:{id:null}}),!_)return}else if(_.props.page.status>=400&&await I.updated.check())return await We(),await R(t,o);if(ft(),L(ne),pt(re),_.props.page.url.pathname!==t.pathname&&(t.pathname=_.props.page.url.pathname),c=n?n.state:c,!n){let e=+!o,n={[S]:q+=e,[C]:J+=e,[ve]:c};(o?history.replaceState:history.pushState).call(history,n,``,t),o||Ue(q,J)}let v=m&&H?.id===m.id?H.fork:null;H?.fork&&!v?Qe():(H=null,Z={element:void 0,href:void 0}),_.props.page.state=c;let y;if(rt){let e=(await Promise.all(Array.from(tt,e=>e(h.navigation)))).filter(e=>typeof e==`function`);if(e.length>0){function t(){e.forEach(e=>{U.delete(e)})}e.push(t),e.forEach(e=>{U.add(e)})}let n=h.navigation.to;W={..._.state,nav:{params:n.params,route:n.route,url:n.url}},_.props.page&&(_.props.page.url=t),!i&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur();let a=v&&await v;a?y=a.commit():(N=null,st.$set(_.props),N&&Object.assign(_.props.page,N),Ie(_.props.page),y=r?.()),at=!0}else await yt(_,qe,!1);let{activeElement:ie}=document;if(await y,await s(),await s(),Y!==d){h.reject(Error(`navigation aborted`));return}_.props.page&&N&&Object.assign(_.props.page,N);let b=null;if(it){let e=n?n.scroll:a?E():null;e?scrollTo(e.x,e.y):(b=t.hash&&document.getElementById(Zt(t)))?b.scrollIntoView():scrollTo(0,0)}let ae=document.activeElement!==ie&&document.activeElement!==document.body;!i&&!ae&&Jt(t,!b),it=!0,G=!1,h.fulfil(void 0),h.navigation.to&&(h.navigation.to.scroll=E()),U.forEach(e=>e(h.navigation)),e===`popstate`&&mt(J),I.navigating.set(M.current=null)}async function Ft(e,t,n,r,i){return e.origin===be&&e.pathname===location.pathname&&!nt?await kt({status:r,error:n,url:e,route:t}):await R(e,i)}var Z={element:void 0,href:void 0};function It(){let e,t;B.addEventListener(`mousemove`,t=>{let n=t.target;clearTimeout(e),e=setTimeout(()=>{i(n,w.hover)},20)});function n(e){e.defaultPrevented||i(e.composedPath()[0],w.tap)}B.addEventListener(`mousedown`,n),B.addEventListener(`touchstart`,n,{passive:!0});let r=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(vt(new URL(t.target.href)),r.unobserve(t.target))},{threshold:0});async function i(e,n){let r=Ce(e,B),i=r===Z.element&&r?.href===Z.href&&n>=t;if(!r||i)return;let{url:a,external:o,download:s}=we(r,x,V.hash);if(o||s)return;let c=O(r),l=a&&Nt(W.url)===Nt(a);if(!(c.reload||l)){if(n<=c.preload_data){Z={element:r,href:r.href},t=w.tap;let e=await jt(a,!1);if(!e)return;_t(e)}else n<=c.preload_code&&(Z={element:r,href:r.href},t=n,vt(a))}}function a(){r.disconnect();for(let e of B.querySelectorAll(`a`)){let{url:t,external:n,download:i}=we(e,x,V.hash);if(n||i)continue;let a=O(e);a.reload||(a.preload_code===w.viewport&&r.observe(e),a.preload_code===w.eager&&vt(t))}}U.add(a),a()}function Q(e,t){if(e instanceof u)return e.body;let n=je(e),r=Me(e);return V.hooks.handleError({error:e,event:t,status:n,message:r})??{message:r}}function Lt(e,t){ze(()=>(e.add(t),()=>{e.delete(t)}))}function Rt(e){Lt(U,e)}function zt(e){Lt(tt,e)}function Bt(e,t={}){return e=new URL(T(e)),e.origin===be?gt(e,t,0):Promise.reject(Error(`goto: invalid URL`))}function Vt(e){if(typeof e==`function`)Xe.push(e);else{let{href:t}=new URL(e,location.href);Xe.push(e=>e.href===t)}}function Ht(e,t){L(q);let n={[S]:q+=1,[C]:J,[ye]:j.url.href,[ve]:t};history.pushState(n,``,T(e)),at=!0,j.state=t,st.$set({page:Ve(()=>$(j))}),Ue(q,J)}function Ut(e,t){let n={[S]:q,[C]:J,[ye]:j.url.href,[ve]:t};history.replaceState(n,``,T(e)),j.state=t,st.$set({page:Ve(()=>$(j))})}function Wt(){history.scrollRestoration=`manual`,addEventListener(`beforeunload`,e=>{let t=!1;if(ht(),!G){let e=Yt(W,void 0,null,`leave`),n={...e.navigation,cancel:()=>{t=!0,e.reject(Error(`navigation cancelled`))}};et.forEach(e=>e(n))}t?(e.preventDefault(),e.returnValue=``):history.scrollRestoration=`auto`}),addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&ht()}),navigator.connection?.saveData||It(),B.addEventListener(`click`,async t=>{if(t.button||t.which!==1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.defaultPrevented)return;let n=Ce(t.composedPath()[0],B);if(!n)return;let{url:r,external:i,target:a,download:o}=we(n,x,V.hash);if(!r)return;if(a===`_parent`||a===`_top`){if(window.parent!==window)return}else if(a&&a!==`_self`)return;let s=O(n);if(!(n instanceof SVGAElement)&&r.protocol!==location.protocol&&r.protocol!==`https:`&&r.protocol!==`http:`||o)return;let[c,l]=(V.hash?r.hash.replace(/^#/,``):r.href).split(`#`),u=c===m(location);if(i||s.reload&&(!u||!l))Pt({url:r,type:`link`,event:t})?G=!0:t.preventDefault();else{if(l!==void 0&&u){let[,i]=W.url.href.split(`#`);if(i===l){if(t.preventDefault(),l===``||l===`top`&&n.ownerDocument.getElementById(`top`)===null)scrollTo({top:0});else{let e=n.ownerDocument.getElementById(decodeURIComponent(l));e&&(e.scrollIntoView(),e.focus())}return}if(K=!0,L(q),e(r),!s.replace_state)return;K=!1}t.preventDefault(),await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,0)}),setTimeout(e,100)}),await X({type:`link`,url:r,keepfocus:s.keepfocus,noscroll:s.noscroll,replace_state:s.replace_state??r.href===location.href,event:t})}}),B.addEventListener(`submit`,e=>{if(e.defaultPrevented)return;let t=HTMLFormElement.prototype.cloneNode.call(e.target),n=e.submitter;if((n?.formTarget||t.target)===`_blank`||(n?.formMethod||t.method)!==`get`)return;let r=new URL(n?.hasAttribute(`formaction`)&&n?.formAction||t.action);if(k(r,x,!1))return;let i=e.target,a=O(i);if(a.reload)return;e.preventDefault(),e.stopPropagation();let o=new FormData(i,n);r.search=new URLSearchParams(o).toString(),X({type:`form`,url:r,keepfocus:a.keepfocus,noscroll:a.noscroll,replace_state:a.replace_state??r.href===location.href,event:e})}),addEventListener(`popstate`,async t=>{if(!qt){if(t.state?.[`sveltekit:history`]){let n=t.state[S];if(Y={},n===q)return;let r=P[n],i=t.state[`sveltekit:states`]??{},a=new URL(t.state[`sveltekit:pageurl`]??location.href),o=t.state[C],s=W.url?m(location)===m(W.url):!1;if(o===J&&(at||s)){i!==j.state&&(j.state=i),e(a),P[q]=E(),r&&scrollTo(r.x,r.y),q=n;return}let c=n-q;await X({type:`popstate`,url:a,popped:{state:i,scroll:r,delta:c},accept:()=>{q=n,J=o},block:()=>{history.go(-c)},nav_token:Y,event:t})}else K||(e(new URL(location.href)),V.hash&&location.reload())}}),addEventListener(`hashchange`,()=>{K&&(K=!1,history.replaceState({...history.state,[S]:++q,[C]:J},``,location.href))});for(let e of document.querySelectorAll(`link`))He.has(e.rel)&&(e.href=e.href);addEventListener(`pageshow`,e=>{e.persisted&&I.navigating.set(M.current=null)});function e(e){W.url=j.url=e,I.page.set($(j)),I.page.notify()}}async function Gt(e,{status:t=200,error:n,node_ids:r,params:i,route:a,server_route:o,data:s,form:c}){nt=!0;let l=new URL(location.href),u;({params:i={},route:a={id:null}}=await jt(l,!1)||{}),u=Ge.find(({id:e})=>e===a.id);let f,p=!0;try{let e=r.map(async(t,n)=>{let r=s[n];return r?.uses&&(r.uses=Kt(r.uses)),xt({loader:V.nodes[t],url:l,params:i,route:a,parent:async()=>{let t={};for(let r=0;r<n;r+=1)Object.assign(t,(await e[r]).data);return t},server_data_node:wt(r)})}),o=await Promise.all(e);if(u){let e=u.layouts;for(let t=0;t<e.length;t++)e[t]||o.splice(t,0,void 0)}f=await bt({url:l,params:i,branch:o,status:t,error:n,errors:u?.errors,form:c,route:u??null})}catch(t){if(t instanceof d)return await R(new URL(t.location,location.href));f=await kt({status:je(t),error:await Q(t,{url:l,params:i,route:a}),url:l,route:a}),e.textContent=``,p=!1}f&&(f.props.page&&(f.props.page.state={}),await yt(f,e,p))}function Kt(e){return{dependencies:new Set(e?.dependencies??[]),params:new Set(e?.params??[]),parent:!!e?.parent,route:!!e?.route,url:!!e?.url,search_params:new Set(e?.search_params??[])}}var qt=!1;function Jt(e,t=!0){let n=document.querySelector(`[autofocus]`);if(n)n.focus();else{let n=Zt(e);if(n&&document.getElementById(n)){let{x:r,y:i}=E();setTimeout(()=>{let a=history.state;qt=!0,location.replace(new URL(`#${n}`,location.href)),history.replaceState(a,``,e),t&&scrollTo(r,i),qt=!1})}else{let e=document.body,t=e.getAttribute(`tabindex`);e.tabIndex=-1,e.focus({preventScroll:!0,focusVisible:!1}),t===null?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,t)}let r=getSelection();if(r&&r.type!==`None`){let e=[];for(let t=0;t<r.rangeCount;t+=1)e.push(r.getRangeAt(t));setTimeout(()=>{if(r.rangeCount===e.length){for(let t=0;t<r.rangeCount;t+=1){let n=e[t],i=r.getRangeAt(t);if(n.commonAncestorContainer!==i.commonAncestorContainer||n.startContainer!==i.startContainer||n.endContainer!==i.endContainer||n.startOffset!==i.startOffset||n.endOffset!==i.endOffset)return}r.removeAllRanges()}})}}}function Yt(e,t,n,r,i=null){let a,o,s=new Promise((e,t)=>{a=e,o=t});return s.catch(g),{navigation:{from:{params:e.params,route:{id:e.route?.id??null},url:e.url,scroll:E()},to:n&&{params:t?.params??null,route:{id:t?.route?.id??null},url:n,scroll:i},willUnload:!t,type:r,complete:s},fulfil:a,reject:o}}function $(e){return{data:e.data,error:e.error,form:e.form,params:e.params,route:e.route,state:e.state,status:e.status,url:e.url}}function Xt(e){let t=new URL(e);return t.hash=decodeURIComponent(e.hash),t}function Zt(e){let t;if(V.hash){let[,,n]=e.hash.split(`#`,3);t=n??``}else t=e.hash.slice(1);return decodeURIComponent(t)}export{Ut as a,j as c,Ht as i,Oe as l,Bt as n,dt as o,zt as r,M as s,Rt as t,x as u};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BbwIep6z.js","./uBIymjUX.js","./BQxY8kkL.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{$ as e,Mt as t,bt as n,ct as r,gt as i,nt as a,ot as o,vt as s}from"./DG3qFFTE.js";import{t as c}from"./uBIymjUX.js";import{F as l,lt as u}from"./BG9Gz_25.js";import{g as d}from"./Bsn3IIve.js";import{n as f}from"./gCpxN2IC.js";import{n as p,r as m}from"./GdHEbDDH.js";import{a as h,t as g}from"./BQxY8kkL.js";import{_,a as v,c as y,g as b,h as x,l as S,n as C,o as w,p as T,u as E}from"./O8DAZ_le.js";import{b as D,c as O,o as ee,r as te,t as ne}from"./CtjBwCj8.js";import{n as k,t as re}from"./nphy1MQF.js";async function ie(e={}){let t=e.window??(typeof window<`u`?window:void 0),n=e.navigator??(typeof navigator<`u`?navigator:void 0);return!t||!(`SpeechRecognition`in t)&&!(`webkitSpeechRecognition`in t)?`missing`:n&&`brave`in n&&n.brave||/\bElectron\//.test(n?.userAgent??``)?`unreliable`:`works`}function ae(e){return new Worker(new URL(`../workers/local-speech.worker-CU_DjhLr.js`,import.meta.url).href,{name:e?.name})}var oe=2**28,se=16,ce=.95;function le(e){if(e===0)return 1;let t=Math.PI*e;return Math.sin(t)/t}function ue(e,t,n){for(let[e,r]of[[`fromRate`,t],[`toRate`,n]])if(!Number.isFinite(r)||r<=0)throw new h(`invalid_argument`,`${e} must be a positive finite number (got ${String(r)})`);let r=Math.floor(e.length*n/t);if(r>oe)throw new h(`invalid_argument`,`resampled output would be ${r} samples; the limit is ${oe}`);if(t===n)return e.slice();let i=new Float32Array(r),a=t/n,o=a>1?ce/a:1,s=se/o,c=e.length-1;for(let t=0;t<r;t+=1){let n=t*a,r=Math.max(0,Math.ceil(n-s)),l=Math.min(c,Math.floor(n+s)),u=0,d=0;for(let t=r;t<=l;t+=1){let r=t-n,i=.5+.5*Math.cos(Math.PI*r/s),a=o*le(o*r)*i;u+=a*e[t],d+=a}i[t]=d===0?0:u/d}return i}var A={silenceMs:800,minSpeechMs:150,preRollMs:300,maxUtteranceMs:3e4,sensitivity:.5,calibrateMs:300},de=.0015,fe=.003,pe=.006,me=.2,he=.02,ge=2e3,_e=250;function ve(e,t,n){return Math.min(n,Math.max(t,e))}function ye(e={}){let t=(e,t,n)=>typeof e==`number`&&Number.isFinite(e)?Math.max(n,e):t;return{silenceMs:t(e.silenceMs,A.silenceMs,20),minSpeechMs:t(e.minSpeechMs,A.minSpeechMs,0),preRollMs:t(e.preRollMs,A.preRollMs,0),maxUtteranceMs:t(e.maxUtteranceMs,A.maxUtteranceMs,1e3),sensitivity:ve(typeof e.sensitivity==`number`&&Number.isFinite(e.sensitivity)?e.sensitivity:A.sensitivity,0,1),calibrateMs:t(e.calibrateMs,A.calibrateMs,0)}}function be(e){let t=e.length;if(t===0)return 0;let n=0;for(let r=0;r<t;r++){let t=e[r];n+=t*t}return Math.sqrt(n/t)}function xe(e={}){let t=ye(e),n=6-4*t.sensitivity,r=.02-.015*t.sensitivity,i=fe,a=0,o=[],s=!1,c=0,l=0,u=0,d=()=>Math.max(i*n,r),f=()=>Math.max(d()*.6,i*1.5),p=()=>{s=!1,c=0,l=0,u=0};return{get speaking(){return s},get noiseFloor(){return i},get threshold(){return d()},push(e,n=20){let r=[],m=Number.isFinite(e)?Math.max(0,e):0,h=ve(m/(d()*3),0,1),g=a<t.calibrateMs;if(g&&(a+=n,!s)){o.push(m);let e=[...o].sort((e,t)=>e-t);i=ve(e[Math.min(e.length-1,Math.floor(e.length*me))]??fe,de,pe)}if(!s){if(m>d())c+=n,c>=t.minSpeechMs&&(s=!0,l=0,u=c,r.push({type:`start`,leadMs:t.preRollMs+c}),c=0);else if(g)c=0;else{c=0;let e=n/ge*(m<i?4:1);i=ve(i+(m-i)*Math.min(1,e),de,he)}return{events:r,level:h,speaking:s}}return u+=n,m>f()?l=0:l+=n,l>=t.silenceMs?(r.push({type:`end`,reason:`silence`,trailingSilenceMs:l}),p()):u>=t.maxUtteranceMs&&(r.push({type:`split`}),u=0,l=0),{events:r,level:h,speaking:s}},flush(){let e=[];return s&&e.push({type:`end`,reason:`flush`,trailingSilenceMs:l}),p(),e}}}function Se(e){let t=ye(e),n=xe(t),r=Math.max(1,Math.round(e.sampleRate*20/1e3)),i=r/e.sampleRate*1e3,a=Math.ceil((t.preRollMs+t.minSpeechMs)/i)+1,o=[],s=new Float32Array,c=null,l=!1,u=(t,n,r)=>{let a=Math.max(0,Math.floor((r-_e)/i)),o=t.slice(0,Math.max(1,t.length-a)),s=0;for(let e of o)s+=e.length;let c=new Float32Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;e.onUtterance({pcm:c,sampleRate:e.sampleRate,durationMs:s/e.sampleRate*1e3,reason:n})},d=t=>{t!==l&&(l=t,e.onSpeaking?.(t))},f=s=>{let l=n.push(be(s),i);e.onLevel?.(l.level),o.push(s),o.length>a&&o.shift(),c&&c.push(s);for(let e of l.events)if(e.type===`start`){c=[...o];let e=Math.ceil(t.preRollMs/i),n=Math.max(0,o.length-Math.ceil(t.minSpeechMs/i));for(let t=n;t<e;t++)c.unshift(new Float32Array(r))}else if(e.type===`end`){let t=c??[];c=null,o.length=0,t.length>0&&u(t,e.reason,e.trailingSilenceMs)}else if(e.type===`split`){let e=c??[];c=[],e.length>0&&u(e,`max`,0)}d(n.speaking)};return{get speaking(){return n.speaking},segmenter:n,push(e){let t=e;s.length>0&&(t=new Float32Array(s.length+e.length),t.set(s,0),t.set(e,s.length));let n=0;for(;n+r<=t.length;)f(t.slice(n,n+r)),n+=r;s=t.slice(n)},flush(){let t=n.flush();for(let e of t)e.type===`end`&&c&&c.length>0&&u(c,`flush`,e.trailingSilenceMs);c=null,o.length=0,s=new Float32Array,d(!1),e.onLevel?.(0)},discard(){n.flush(),c=null,o.length=0,s=new Float32Array,d(!1),e.onLevel?.(0)}}}var Ce=44,we=4294967295,Te=1;function Ee(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n+=1){let r=e[n];Number.isNaN(r)||(t[n]=Math.min(32767,Math.round((r>1?1:r<-1?-1:r)*32768)))}return t}function De(e,t){if(!Number.isInteger(e)||e<1||e*2>we)throw new h(`invalid_argument`,`${t} must be a positive integer sample rate (got ${String(e)})`)}function Oe(e,t,n){for(let r=0;r<n.length;r+=1)e.setUint8(t+r,n.charCodeAt(r))}function ke(e,t){De(t,`sampleRate`);let n=e.length*2;if(n+Ce-8>we)throw new h(`invalid_argument`,`too many samples for a single WAV (4 GiB limit)`);let r=e instanceof Int16Array?e:Ee(e),i=new Uint8Array(Ce+n),a=new DataView(i.buffer);Oe(a,0,`RIFF`),a.setUint32(4,36+n,!0),Oe(a,8,`WAVE`),Oe(a,12,`fmt `),a.setUint32(16,16,!0),a.setUint16(20,Te,!0),a.setUint16(22,1,!0),a.setUint32(24,t,!0),a.setUint32(28,t*2,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),Oe(a,36,`data`),a.setUint32(40,n,!0);for(let e=0;e<r.length;e+=1)a.setInt16(Ce+e*2,r[e],!0);return i}var Ae=`hv-pcm-tap`,je=`
|
|
3
|
-
class HvPcmTap extends AudioWorkletProcessor {
|
|
4
|
-
process(inputs) {
|
|
5
|
-
const channels = inputs[0];
|
|
6
|
-
if (channels && channels.length > 0 && channels[0].length > 0) {
|
|
7
|
-
const frames = channels[0].length;
|
|
8
|
-
const mono = new Float32Array(frames);
|
|
9
|
-
for (let c = 0; c < channels.length; c += 1) {
|
|
10
|
-
const data = channels[c];
|
|
11
|
-
for (let i = 0; i < frames; i += 1) mono[i] += data[i];
|
|
12
|
-
}
|
|
13
|
-
if (channels.length > 1) {
|
|
14
|
-
for (let i = 0; i < frames; i += 1) mono[i] /= channels.length;
|
|
15
|
-
}
|
|
16
|
-
this.port.postMessage(mono, [mono.buffer]);
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
registerProcessor('${Ae}', HvPcmTap);
|
|
22
|
-
`;function Me(){return typeof AudioContext<`u`&&typeof AudioWorkletNode<`u`&&typeof Blob<`u`&&typeof URL<`u`&&typeof URL.createObjectURL==`function`}function Ne(e,t){let{sampleRate:n,maxDurationMs:r}=t;if(!Number.isInteger(n)||n<1)throw RangeError(`sampleRate must be a positive integer`);if(!Number.isFinite(r)||r<=0)throw RangeError(`maxDurationMs must be a positive number`);if(!Me())throw new g(`unsupported`,`PCM capture needs AudioContext, AudioWorkletNode and Blob URLs`);let i=new AudioContext,a=Math.ceil(r/1e3*i.sampleRate),o=[],s=0,c=!1,l=!1,u=!1,d=!1,f,p,m,h,_=e=>{if(d)return;let n=e.data;if(t.onSamples?.(n,i.sampleRate),t.retain===!1)return;let r=a-s;n.length>r&&(n=n.subarray(0,Math.max(0,r)),c=!0),n.length>0&&(o.push(n),s+=n.length),s>=a&&!l&&(l=!0,t.onLimit?.())},v=()=>{if(f!==void 0){let e=f;f=void 0;try{URL.revokeObjectURL(e)}catch{}}},y=()=>{if(h)return h;d=!0,v(),m&&(m.port.onmessage=null);try{p?.disconnect(),m?.disconnect()}catch{}return h=(async()=>{try{i.state!==`closed`&&await i.close()}catch{}})(),h},b=(async()=>{f=URL.createObjectURL(new Blob([je],{type:`text/javascript`}));try{await i.audioWorklet.addModule(f)}finally{v()}d||(p=i.createMediaStreamSource(e),m=new AudioWorkletNode(i,Ae,{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1]}),m.port.onmessage=_,p.connect(m),m.connect(i.destination),i.state===`suspended`&&await i.resume())})();b.catch(()=>void 0);let x;return{ready:b,stop(){return x??=(async()=>{try{await b}catch(e){throw await y(),new g(`setup_failed`,`PCM capture could not start`,e)}if(await y(),u)throw new g(`cancelled`,`PCM capture was cancelled`);let e=new Float32Array(s),t=0;for(let n of o.splice(0))e.set(n,t),t+=n.length;let r=ue(e,i.sampleRate,n);return{samples:r,wav:ke(r,n),truncated:c}})(),x},cancel(){u||(u=!0,o.length=0,y())}}}var Pe=16e3;function Fe(){return Me()&&typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`}var Ie=36e5;async function Le(e={}){let t=e.createCapture??Ne;if(!e.createCapture&&!Fe()&&!e.stream)throw new g(`unsupported`,`Hands-free capture needs the microphone API and Web Audio`);let n=!e.stream,r=e.stream??await navigator.mediaDevices.getUserMedia(e.constraints??{audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),i={speechstart:new Set,speechend:new Set,level:new Set},a=(e,t)=>{for(let n of[...i[e]])try{n(t)}catch{}},o,s=!1,c=!1,l=0,u=Math.max(0,e.resumeGuardMs??350),d=()=>{if(n)for(let e of r.getTracks())e.stop()},f;try{f=t(r,{sampleRate:Pe,maxDurationMs:Ie,retain:!1,onSamples:(t,n)=>{s||c||(l>0?l-=t.length/n*1e3:(o??=Se({...e,sampleRate:n,onSpeaking:e=>{e&&a(`speechstart`,{})},onLevel:e=>a(`level`,{level:e}),onUtterance:e=>{let t=ue(e.pcm,e.sampleRate,Pe);a(`speechend`,{samples:t,sampleRate:Pe,durationMs:e.durationMs,reason:e.reason})}}),o.push(t)))}})}catch(e){throw d(),e}if(f.ready)try{await f.ready}catch(e){throw s=!0,f.cancel(),d(),new g(`setup_failed`,`Hands-free capture could not start`,e)}let p=async e=>{s||(e&&o?.flush(),s=!0,f.cancel(),d())};return{on(e,t){let n=i[e];return n.add(t),()=>{n.delete(t)}},get speaking(){return o?.speaking??!1},get suspended(){return c},suspend(){s||c||(c=!0,l=0,o?.discard(),a(`level`,{level:0}))},resume(){!s&&c&&(c=!1,l=u)},stop:()=>p(!0),cancel:()=>{p(!1)}}}var Re=e=>{let t=null,n=!1,r=!1,i=!1;return{async start(){let a=await Le({...e.vad,...e.constraints?{constraints:e.constraints}:{}});n||r?a.cancel():(t=a,i&&a.suspend(),a.on(`speechstart`,()=>e.onSpeaking?.(!0)),a.on(`level`,({level:t})=>e.onLevel?.(t)),a.on(`speechend`,t=>{e.onSpeaking?.(!1),e.onUtterance({pcm:t.samples,sampleRate:t.sampleRate,durationMs:t.durationMs,reason:t.reason})}))},suspend(){i=!0,t?.suspend(),e.onSpeaking?.(!1)},resume(){i=!1,t?.resume()},stop(){r=!0;let n=t;t=null,n?.stop().catch(t=>{e.onError?.(t instanceof Error?t:Error(String(t)))})},cancel(){n=!0,t?.cancel(),t=null}}};function ze(e){return m({model:e,createWorker:()=>new ae,loadSpeech:()=>c(()=>import(`./BbwIep6z.js`),__vite__mapDeps([0,1,2]),import.meta.url)})}var Be=[`material`,`glass`,`studio`,`smrt`,`happyvertical`],Ve=`@happyvertical/smrt-commerce:`,He={currency:[`Order`,`PurchaseOrder`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`].map(e=>({model:`${Ve}${e}`,field:`currency`})),taxRate:[`InvoiceLineItem`,`ContractLineItem`].map(e=>({model:`${Ve}${e}`,field:`taxRate`})),pricesIncludeTax:[`Invoice`,`Contract`].map(e=>({model:`${Ve}${e}`,field:`lineAmountType`})),taxRounding:[`Invoice`,`Contract`].map(e=>({model:`${Ve}${e}`,field:`taxRoundingScope`})),paymentTerms:[...[`Order`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`].map(e=>({model:`${Ve}${e}`,field:`terms`})),{model:`${Ve}Customer`,field:`paymentTerms`}]},Ue={id:`more`,label:`More`},We=/^@[^/]+\/(?:smrt-)?([^:]+):(.+)$/;function Ge(e,t){let n=e.models.find(e=>e.id===t);if(n)return{packageId:n.packageId,name:n.name};let r=We.exec(t);return r?{packageId:r[1],name:r[2]}:{packageId:`unknown`,name:t}}var Ke=(e,t,n)=>`item:${e}:${t}${n?`:${n}`:``}`,qe=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase()),Je=(e,t)=>qe(Ge(e,t).name);function Ye(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}=Ge(e,n.model),i=Ke(t,r,n.key);s.items.some(e=>e.id===i)||s.items.push({id:i,label:n.label})}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:${Ue.id}`,label:Ue.label,items:o.map(t=>{let{packageId:n,name:r}=Ge(e,t);return{id:Ke(n,r),label:qe(r)}})}),i}var Xe=(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 Ze(e,t){let n=t.layout,r=Ye(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,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=Xe(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 Xe(r.filter(e=>e.custom||e.items.length>0),n?.sectionOrder)}var j=(e,t)=>e.models.find(e=>e.id===t),Qe=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 $e(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),Qe(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,Qe(r)}function et(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,Qe(r)}function tt(e,t,n){let r=e?structuredClone(e):{version:1},i=(r.hidden??[]).filter(e=>e!==t);return r.hidden=n?[...i,t]:i,Qe(r)}var nt=`https://s-m-r-t.dev/schemas/cookbook/v1.json`,rt=new Set([`basic`,`advanced`,`hidden`]),it=new Set([`api`,`mcp`,`cli`]),at=new Set([`light`,`dark`,`system`]),ot={borderRadius:[`none`,`sm`,`md`,`lg`,`xl`,`full`],density:[`comfortable`,`touch`],contrast:[`auto`,`standard`,`more`]},st=new Set([`header.start`,`header.center`,`header.end`,`footer.start`,`footer.center`,`footer.end`,`leftSidebar.header`,`leftSidebar.footer`,`rightSidebar.header`,`rightSidebar.footer`]),M=e=>typeof e==`object`&&!!e&&!Array.isArray(e),N=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),ct=(e,t)=>M(e)&&!Object.hasOwn(e,`__proto__`)&&Object.values(e).every(t),lt=(e,t,n,r,i)=>{e.push({severity:t,code:n,path:r,message:i})},P=(e,t,n,r)=>lt(e,`error`,t,n,r),F=(e,t,n,r)=>lt(e,`warning`,t,n,r);function ut(e,t,n){if(!M(e))return P(n,`invalid_type`,t,`${t} must be an object`);for(let r of[`objectRef`,`fieldName`])(typeof e[r]!=`string`||!e[r])&&P(n,`invalid_value`,`${t}.${r}`,`${t}.${r} must be a non-empty string`);e.scopeType!==`app`&&P(n,`invalid_value`,`${t}.scopeType`,`${t}.scopeType must be "app"`);for(let r of[`defaultValue`,`help`,`label`]){let i=e[r];i!=null&&typeof i!=`string`&&P(n,`invalid_type`,`${t}.${r}`,`${t}.${r} must be a string or null`)}let r=e.visibility;r!=null&&!(typeof r==`string`&&rt.has(r))&&P(n,`invalid_value`,`${t}.visibility`,`${t}.visibility must be basic, advanced or hidden`);let i=e.displayOrder;i!=null&&!(typeof i==`number`&&Number.isFinite(i))&&P(n,`invalid_value`,`${t}.displayOrder`,`${t}.displayOrder must be a finite number`),e.locked!=null&&typeof e.locked!=`boolean`&&P(n,`invalid_type`,`${t}.locked`,`${t}.locked must be a boolean`)}function dt(e,t){if(!M(e)||e.version!==1)return P(t,`invalid_value`,`layout`,`layout must be an object with version 1`);for(let n of[`sectionOrder`,`hidden`])e[n]!==void 0&&!N(e[n])&&P(t,`invalid_type`,`layout.${n}`,`layout.${n} must be a list of strings`);for(let n of[`itemOrder`,`moved`,`placements`]){let r=e[n];r!==void 0&&((n===`itemOrder`?ct(r,N):ct(r,e=>typeof e==`string`))||P(t,`invalid_type`,`layout.${n}`,n===`itemOrder`?`layout.itemOrder must map ids to lists of strings`:`layout.${n} must map ids to strings`))}if(M(e.placements))for(let[n,r]of Object.entries(e.placements))typeof r==`string`&&!st.has(r)&&P(t,`unknown_layout_slot`,`layout.placements.${n}`,`Unknown shell slot "${r}".`);for(let n of[`sections`,`items`,`panels`])e[n]!==void 0&&!ct(e[n],e=>M(e))&&P(t,`invalid_type`,`layout.${n}`,`layout.${n} must map ids to objects`);let n=e.customSections;n!==void 0&&!(Array.isArray(n)&&n.every(e=>M(e)&&typeof e.id==`string`&&typeof e.label==`string`))&&P(t,`invalid_type`,`layout.customSections`,`layout.customSections must be a list of { id, label }`)}function ft(e,t){if(!M(e))return P(t,`invalid_type`,`theme`,`theme must be an object`);e.preset!==void 0&&typeof e.preset!=`string`&&P(t,`invalid_type`,`theme.preset`,`theme.preset must be a string`),e.fontFamily!==void 0&&(typeof e.fontFamily!=`string`||!e.fontFamily)&&P(t,`invalid_value`,`theme.fontFamily`,`theme.fontFamily must be a non-empty string`),e.customCss!==void 0&&(typeof e.customCss==`string`?Array.from(e.customCss).length>65536&&P(t,`invalid_value`,`theme.customCss`,`theme.customCss must be at most 65,536 characters`):P(t,`invalid_type`,`theme.customCss`,`theme.customCss must be a string`)),e.colorScheme!==void 0&&!(typeof e.colorScheme==`string`&&at.has(e.colorScheme))&&P(t,`invalid_value`,`theme.colorScheme`,`theme.colorScheme must be light, dark or system`);for(let n of[`borderRadius`,`density`,`contrast`]){let r=ot[n],i=e[n];i!==void 0&&!(typeof i==`string`&&r.includes(i))&&P(t,`invalid_value`,`theme.${n}`,`theme.${n} must be one of ${r.join(`, `)}`)}let n=e.custom;n!==void 0&&(!M(n)||typeof n.primary!=`string`?P(t,`invalid_value`,`theme.custom`,`theme.custom must be an object with a string primary`):/^#[0-9a-fA-F]{6}$/.test(n.primary)?n.fontFamily!==void 0&&typeof n.fontFamily!=`string`&&P(t,`invalid_type`,`theme.custom.fontFamily`,`theme.custom.fontFamily must be a string`):P(t,`invalid_value`,`theme.custom.primary`,`theme.custom.primary must be a hex colour like #c2410c`))}var pt=/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,95}$/,mt=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,ht=/^[a-z][a-z0-9-]{0,31}$/,gt=e=>e===null||typeof e==`string`||typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`;function _t(e,t,n){return M(e)?[typeof e.id==`string`&&mt.test(e.id),typeof e.type==`string`&&ht.test(e.type),typeof e.span==`number`&&Number.isInteger(e.span)&&e.span>=1&&e.span<=4,M(e.options)&&Object.values(e.options).every(gt),e.version===void 0||typeof e.version==`number`&&Number.isInteger(e.version)&&e.version>=1].every(Boolean)?e:(F(n,`malformed_overview_widget`,t,`${t} was dropped because it is not a valid overview widget`),null):(F(n,`malformed_overview_widget`,t,`${t} was dropped`),null)}function vt(e,t,n){return M(e)?(e.span===void 0||typeof e.span==`number`&&Number.isInteger(e.span)&&e.span>=1&&e.span<=4)&&(e.options===void 0||M(e.options)&&Object.values(e.options).every(gt))&&(e.version===void 0||typeof e.version==`number`&&Number.isInteger(e.version)&&e.version>=1)?e:(F(n,`malformed_overview_change`,t,`${t} was dropped because it is not a valid widget change`),null):(F(n,`malformed_overview_change`,t,`${t} was dropped`),null)}function yt(e,t,n){if(!M(e)||e.version!==1)return F(n,`malformed_overview`,t,`${t} was dropped because it must be an object with version 1`),null;let r={...e,version:1};for(let i of[`order`,`removed`])e[i]!==void 0&&!N(e[i])?(F(n,`malformed_overview_list`,`${t}.${i}`,`${t}.${i} was dropped because it must be a list of strings`),delete r[i]):e[i]!==void 0&&(r[i]=[...new Set(e[i])]);if(e.added!==void 0){if(!Array.isArray(e.added))F(n,`malformed_overview_widgets`,`${t}.added`,`${t}.added was dropped because it must be a list of widgets`),delete r.added;else{let i=e.added.flatMap((e,r)=>{let i=_t(e,`${t}.added[${r}]`,n);return i?[i]:[]});i.length?r.added=i:delete r.added}}if(e.changed!==void 0){if(!M(e.changed)||Object.hasOwn(e.changed,`__proto__`))F(n,`malformed_overview_changes`,`${t}.changed`,`${t}.changed was dropped because it must map widget ids to objects`),delete r.changed;else{let i={};for(let[r,a]of Object.entries(e.changed)){if(!mt.test(r)){F(n,`malformed_overview_change`,`${t}.changed.${r}`,`${t}.changed.${r} was dropped because its widget id is invalid`);continue}let e=vt(a,`${t}.changed.${r}`,n);e&&(i[r]=e)}Object.keys(i).length?r.changed=i:delete r.changed}}return r}function bt(e,t={}){let n=[];if(!M(e))return P(n,`invalid_type`,``,`expected a JSON object`),{ok:!1,errors:[`expected a JSON object`],diagnostics:n};let{$schema:r,version:i}=e;r!==void 0&&r!==`https://s-m-r-t.dev/schemas/cookbook/v1.json`&&r!==`https://s-m-r-t.dev/schemas/blueprint/v1.json`&&P(n,`invalid_schema`,`$schema`,`$schema must be ${nt}`),i===void 0?P(n,`missing_field`,`version`,`version is required`):typeof i!=`number`||!Number.isInteger(i)?P(n,`invalid_type`,`version`,`version must be a whole number`):i>1?P(n,`unsupported_version`,`version`,`version ${i} is newer than this reader understands (1)`):i!==1&&P(n,`unsupported_version`,`version`,`version ${i} is not supported`),r===`https://s-m-r-t.dev/schemas/blueprint/v1.json`&&F(n,`migrated_schema`,`$schema`,`$schema uses the legacy blueprint URL; migrated`);for(let t of[`name`,`description`])e[t]!==void 0&&typeof e[t]!=`string`&&P(n,`invalid_type`,t,`${t} must be a string`);let a=[];if(!N(e.recipes))P(n,`invalid_type`,`recipes`,`recipes must be a list of recipe ids`);else if(a=[...new Set(e.recipes)].sort(),t.recipes){let r=new Set(t.recipes);for(let t of a)r.has(t)||P(n,`unknown_recipe`,`recipes[${e.recipes.indexOf(t)}]`,`recipes: unknown recipe "${t}"`)}let o=[];e.features!==void 0&&(N(e.features)?(o=[...new Set(e.features)].sort(),o.length!==e.features.length&&F(n,`duplicate_value`,`features`,`features listed a model more than once; deduplicated`)):P(n,`invalid_type`,`features`,`features must be a list of model names`));let s=[];if(!Array.isArray(e.policies))P(n,`invalid_type`,`policies`,`policies must be a list`);else for(let[t,r]of e.policies.entries())ut(r,`policies[${t}]`,n),s.push(r);if(e.exposure!==void 0&&(ct(e.exposure,e=>N(e)&&e.every(e=>it.has(e)))||P(n,`invalid_value`,`exposure`,`exposure must map model names to lists of api, mcp or cli`)),e.layout!==void 0&&dt(e.layout,n),e.theme!==void 0&&ft(e.theme,n),M(e.theme)&&typeof e.theme.preset==`string`){let r=t.themePresets?new Set(t.themePresets):void 0;r&&!r.has(e.theme.preset)&&P(n,`unknown_theme_preset`,`theme.preset`,`Unknown theme preset "${e.theme.preset}".`)}if(M(e.layout)&&e.layout.version===1&&t.layout){let r=t.layout.sections?new Set(t.layout.sections):void 0,i=t.layout.items?new Set(t.layout.items):void 0,a=t.layout.placementItems?new Set(t.layout.placementItems):void 0;if(r&&Array.isArray(e.layout.customSections))for(let t of e.layout.customSections)M(t)&&typeof t.id==`string`&&r.add(t.id);let o=(e,t)=>t===`section`?r?.has(e)!==!1:t===`item`?i?.has(e)!==!1:r?.has(e)===!0||i?.has(e)===!0||!r&&!i,s=(e,t,r)=>{typeof e==`string`&&!o(e,r)&&P(n,`unknown_layout_id`,t,`Unknown layout ${r===`either`?`section or item`:r} "${e}".`)};if(N(e.layout.sectionOrder)&&e.layout.sectionOrder.forEach((e,t)=>{s(e,`layout.sectionOrder[${t}]`,`section`)}),N(e.layout.hidden)&&e.layout.hidden.forEach((e,t)=>{s(e,`layout.hidden[${t}]`,`either`)}),M(e.layout.itemOrder))for(let[t,n]of Object.entries(e.layout.itemOrder))s(t,`layout.itemOrder.${t}`,`section`),N(n)&&n.forEach((e,n)=>{s(e,`layout.itemOrder.${t}[${n}]`,`item`)});if(M(e.layout.moved))for(let[t,n]of Object.entries(e.layout.moved))s(t,`layout.moved.${t}`,`item`),s(n,`layout.moved.${t}`,`section`);for(let t of[`sections`,`items`])if(M(e.layout[t]))for(let n of Object.keys(e.layout[t]))s(n,`layout.${t}.${n}`,t===`sections`?`section`:`item`);if(M(e.layout.placements))for(let t of Object.keys(e.layout.placements))a&&!a.has(t)&&P(n,`unknown_layout_id`,`layout.placements.${t}`,`Unknown layout placement item "${t}".`)}let c={};if(e.overviews!==void 0){if(!M(e.overviews)||Object.hasOwn(e.overviews,`__proto__`))P(n,`invalid_type`,`overviews`,`overviews must map overview ids to overrides`);else{let r=t.overviewIds?new Set(t.overviewIds):void 0;for(let[i,a]of Object.entries(e.overviews)){let e=`overviews.${i}`;if(!pt.test(i)){F(n,`invalid_overview_id`,e,`${e} was dropped because its overview id is invalid`);continue}if(r&&!r.has(i)){F(n,`unknown_overview`,e,`Unknown overview "${i}" was dropped.`);continue}let o=yt(a,e,n);if(!o)continue;if(!t.validateOverview){c[i]=o;continue}let s;try{s=t.validateOverview(i,o)}catch{F(n,`overview_validation_failed`,e,`Overview "${i}" was dropped because its host validator failed.`);continue}for(let t of s.diagnostics??[])F(n,t.code,t.path||e,t.message);!s.ok&&s.diagnostics.length===0&&F(n,`overview_rejected`,e,`Overview "${i}" was rejected by its host validator and dropped.`),s.ok&&s.override&&(c[i]=s.override)}}}let l=n.filter(e=>e.severity===`error`).map(e=>e.message);if(l.length)return{ok:!1,errors:l,diagnostics:n};let u={...e,$schema:nt,version:1,recipes:a,features:o,policies:s};return e.exposure!==void 0&&(u.exposure=e.exposure),e.layout!==void 0&&(u.layout=e.layout),e.theme!==void 0&&(u.theme=e.theme),delete u.overviews,Object.keys(c).length&&(u.overviews=c),{ok:!0,cookbook:u,warnings:n.filter(e=>e.severity===`warning`).map(e=>e.message),diagnostics:n}}var I=e=>e===void 0?e:structuredClone(e),xt=(e,t)=>JSON.stringify(e??null)===JSON.stringify(t??null),St=()=>({$schema:nt,version:1,recipes:[],features:[],policies:[]});function Ct(e){return!e.recipes.length&&!e.features.length&&!e.policies.length&&!Object.keys(e.exposure??{}).length&&!e.layout&&!e.theme&&!Object.keys(e.overviews??{}).length}var wt=e=>[...new Set(e)].sort();function Tt(e){let t=new Set([`$schema`,`version`,`name`,`description`,`recipes`,`features`,`policies`,`exposure`,`layout`,`theme`,`overviews`]),n={$schema:nt,version:1,...e.name?{name:e.name}:{},...e.description?{description:e.description}:{},recipes:wt(e.recipes),features:wt(e.features),policies:[...e.policies].sort((e,t)=>e.objectRef.localeCompare(t.objectRef)||e.fieldName.localeCompare(t.fieldName)).map(e=>({...e}))},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=I(e.layout));let i=Kt(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,I(t)])));for(let[r,i]of Object.entries(e))t.has(r)||(n[r]=I(i));return n}var L=e=>new Map(e.recipes.map(e=>[e.id,e]));function Et(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 wt(n)}function Dt(e,t){let n=L(e);return new Set([...t.recipes.flatMap(e=>n.get(e)?.models??[]),...t.features])}function Ot(e){return e.settingTargets??He}function kt(e,t){return Object.values(Ot(e)).some(e=>e.some(e=>e.model===t.objectRef&&e.field===t.fieldName))}function At(e,t){let n=Dt(e,t),r={...t,policies:t.policies.filter(t=>n.has(t.objectRef)||kt(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 jt=(e,t)=>{let n=L(e);return t.recipes.filter(e=>n.has(e))},Mt=(e,t)=>{let n=L(e);return t.recipes.filter(e=>!n.has(e))};function Nt(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 Pt(e,t,n){let r=L(e),i=jt(e,t),a=Et([...i,...n],r);return{doc:{...t,recipes:wt([...a,...Mt(e,t)])},changes:{...Nt(i,a),kept:[]}}}function Ft(e,t,n){let r=L(e),i=jt(e,t),a=new Set(n),o=Et(i.filter(e=>!a.has(e)),r),s=At(e,{...t,recipes:wt([...o,...Mt(e,t)])}),{added:c,removed:l}=Nt(i,o);return{doc:s,changes:{added:c,removed:l,kept:n.filter(e=>o.includes(e)&&i.includes(e))}}}function It(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=At(e,o)),{doc:o,changes:{...Nt(t.features,a),kept:[]}}}var Lt=(e,t)=>({added:[...e.added,...t.added],removed:[...e.removed,...t.removed],kept:[...e.kept,...t.kept]}),Rt={currency:`USD`,taxRate:0,paymentTerms:``,pricesIncludeTax:!1,taxRounding:`line`},zt=[`currency`,`taxRate`,`paymentTerms`,`pricesIncludeTax`,`taxRounding`];function Bt(e){if(e?.defaultValue!==void 0&&e.defaultValue!==null)try{return JSON.parse(e.defaultValue)}catch{return}}var Vt=(e,t,n)=>e.find(e=>e.scopeType===`app`&&e.objectRef===t&&e.fieldName===n);function Ht(e,t){let n=Ot(e),r={...Rt},i=(e,r)=>{for(let{model:i,field:a}of n[e]){let e=Bt(Vt(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 Ut=e=>e==null||e===``;function Wt(e,t,n,r){let i=L(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 j(e,n)?.fields?.find(e=>e.name===r)?.default}function Gt(e,t,n){let r=Ot(e),i=t.policies.map(e=>({...e}));for(let a of zt){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=Wt(e,t,n,o),c=!Ut(s)&&!(!Ut(r)&&r===s)&&!(Ut(r)&&a===`taxRate`&&s===0),l=Vt(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 Kt(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 qt(e){let t=e?.colorScheme??`system`,n=e?.custom?`brand colour ${e.custom.primary}`:e?.preset??`smrt`;return t===`system`?n:`${n}, ${t}`}function Jt(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=Kt(n),i={...e};return r?i.theme=r:delete i.theme,i}function Yt(e,t){let n=[],r=(e,t,r,i)=>n.push({severity:e,code:t,path:r,message:i}),i=bt(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=L(e),s=Ze(e,{...a,layout:void 0}),c=bt(a,{themePresets:e.themePresets??Be,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(Et(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=j(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=Dt(e,a);for(let[t,n]of a.policies.entries()){let i=`policies[${t}]`,a=j(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)&&!kt(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??{}))j(e,t)||r(`error`,`unknown_model`,`exposure.${t}`,`Unknown model "${t}".`);return n}var R=(e,t,n={})=>({ok:!1,error:{code:e,message:t,...n}}),z=(e,t=``,n={})=>({ok:!0,state:e,summary:t,...n}),Xt=`This replaces the recipes, options, menu and look. Send replace: true to confirm.`,B=e=>e.join(`, `);function Zt(e){return`${(e??``).normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`my-app`}.cookbook.json`}var Qt=e=>`${JSON.stringify(e,null,2)}\n`;function $t(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 Tt(At(e,{...I(t),recipes:[...Et(r,n),...i]}))}function en(e,t){return t?e.cookbooks?.find(e=>e.id===t)?.name:void 0}var tn=(e,t)=>{let n=t=>e.recipes.find(e=>e.id===t)?.label??t;return[t.added.length?`Added ${B(t.added.map(n))}.`:``,t.removed.length?`Removed ${B(t.removed.map(n))}.`:``,t.kept.length?`Kept ${B(t.kept.map(n))} (needed).`:``].filter(Boolean).join(` `)},nn=(e,t)=>[t.added.length?`Added ${B(t.added.map(t=>Je(e,t)))}.`:``,t.removed.length?`Removed ${B(t.removed.map(t=>Je(e,t)))}.`:``].filter(Boolean).join(` `),rn=e=>`${Number((e*100).toFixed(4))}%`,V=(e,t)=>({...e,doc:Tt(t)});function an(e,t){let n=Ze(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 on=(e,t)=>{let n={...e};return t?n.layout=t:delete n.layout,n},sn={add_recipes(e,t,{ids:n}){let r=n.filter(t=>!e.recipes.some(e=>e.id===t));if(r.length)return R(`not_found`,`No such recipe: ${B(r)}.`,{path:`input.ids`});let{doc:i,changes:a}=Pt(e,t.doc,n);return z(V(t,i),tn(e,a),{changes:a})},remove_recipes(e,t,{ids:n}){let{doc:r,changes:i}=Ft(e,t.doc,n);return z(V(t,r),tn(e,i),{changes:i})},add_features(e,t,{ids:n}){let r=n.filter(t=>!j(e,t)?.exposed);if(r.length)return R(`not_found`,`No such model to add: ${B(r)}.`,{path:`input.ids`});let{doc:i,changes:a}=It(e,t.doc,n,!0);return z(V(t,i),nn(e,a),{changes:a})},remove_features(e,t,{ids:n}){let{doc:r,changes:i}=It(e,t.doc,n,!1);return z(V(t,r),nn(e,i),{changes:i})},add_cookbook(e,t,{id:n}){let r=e.cookbooks?.find(e=>e.id===n);if(!r)return R(`not_found`,`No cookbook "${n}".`,{path:`input.id`});let i=Pt(e,t.doc,r.document.recipes),a=It(e,i.doc,r.document.features.filter(t=>j(e,t)?.exposed),!0),o=Lt(i.changes,a.changes);return z(V(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 R(`not_found`,`No cookbook "${n}".`,{path:`input.id`});let i=Ft(e,t.doc,r.document.recipes),a=It(e,i.doc,r.document.features,!1),o=Lt(i.changes,a.changes);return z(V(t,a.doc),[tn(e,i.changes),nn(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&&!Ct(t.doc)?R(`confirmation_required`,Xt):z({doc:$t(e,i.document),applied:n},`${i.name} set up.`):R(`not_found`,`No cookbook "${n}".`,{path:`input.id`})},import_cookbook(e,t,{document:n,replace:r}){let i=bt(n);if(!i.ok)return R(`invalid_input`,i.errors[0]??`Not a cookbook.`,{path:`input.document`,details:{errors:i.errors}});if(!r&&!Ct(t.doc))return R(`confirmation_required`,Xt);let a=i.cookbook.recipes.length;return z({doc:$t(e,i.cookbook),applied:null},`Imported ${a} ${a===1?`recipe`:`recipes`}.`,i.warnings.length?{warnings:i.warnings}:{})},set_settings(e,t,n){let r=Ht(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 R(`invalid_input`,`${t} is not a known currency.`,{path:`input.currency`});if(!/^[A-Z]{3}$/.test(t))return R(`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 ${rn(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 R(`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 z(t);let o=a.join(`, `);return z(V(t,Gt(e,t.doc,i)),`${o[0].toUpperCase()}${o.slice(1)}.`)},set_policy(e,t,n){let r=j(e,n.model);if(!r)return R(`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 R(`not_found`,`${r.name} has no field ${n.field}.`,{path:`input.field`})}if(!Dt(e,t.doc).has(r.id))return R(`not_found`,`${qe(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 R(`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`]){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 R(`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 z(t);let l=i.filter(e=>e!==a);return z(V(t,{...t.doc,policies:c?l:[...l,o]}),`Updated ${qe(r.name)} ${n.field}.`)},set_theme(e,t,n){let r=Jt(t.doc,n);return JSON.stringify(Tt(r).theme??null)===JSON.stringify(t.doc.theme??null)?z(t):z(V(t,r),`Theme: ${qt(Tt(r).theme)}.`)},reset_theme(e,t){if(!t.doc.theme)return z(t);let n={...t.doc};return delete n.theme,z(V(t,n),`Theme: default.`)},set_name(e,t,n){let r={...t.doc};for(let e of[`name`,`description`]){let t=n[e];if(t===void 0)continue;let i=t?.trim();i?r[e]=i:delete r[e]}return JSON.stringify(Tt(r))===JSON.stringify(t.doc)?z(t):z(V(t,r),n.name?`Named the app ${n.name.trim()}.`:`Updated the app details.`)},rename_section(e,t,{id:n,label:r}){let i=an(e,t.doc).section(n);if(!i)return R(`not_found`,`No menu section "${n}".`,{path:`input.id`});let a=$e(t.doc.layout,i,r);return JSON.stringify(a??null)===JSON.stringify(t.doc.layout??null)?z(t):z(V(t,on(t.doc,a)),`Renamed the section to ${r.trim()}.`)},rename_item(e,t,{id:n,label:r}){let i=an(e,t.doc).item(n);if(!i)return R(`not_found`,`No menu entry "${n}".`,{path:`input.id`});let a=et(t.doc.layout,i,r);return JSON.stringify(a??null)===JSON.stringify(t.doc.layout??null)?z(t):z(V(t,on(t.doc,a)),r?`Renamed the entry to ${r.trim()}.`:`Entry name restored.`)},hide(e,t,{id:n}){let r=an(e,t.doc);return r.section(n)??r.item(n)?t.doc.layout?.hidden?.includes(n)?z(t):z(V(t,on(t.doc,tt(t.doc.layout,n,!0))),`Hidden.`):R(`not_found`,`No menu section or entry "${n}".`,{path:`input.id`})},show(e,t,{id:n}){let r=an(e,t.doc);return!r.section(n)&&!r.item(n)?R(`not_found`,`No menu section or entry "${n}".`,{path:`input.id`}):t.doc.layout?.hidden?.includes(n)?z(V(t,on(t.doc,tt(t.doc.layout,n,!1))),`Shown.`):z(t)},validate(e,t){let n=Yt(e,t.doc);return z(t,``,{data:{ok:!n.some(e=>e.severity===`error`),diagnostics:n}})},export_cookbook(e,t,{name:n}){return z(t,``,{data:{fileName:Zt(n??t.doc.name??en(e,t.applied)),text:Qt(t.doc),cookbook:I(t.doc)}})}};function cn(e,t,n,r){let i=sn[n];return i?i(e,t,r):R(`unknown_command`,`No command "${n}".`)}var ln=(e,t)=>({type:`array`,description:e,minItems:1,maxItems:50,items:t?.length?{type:`string`,enum:[...t]}:{type:`string`,minLength:1}}),un=(e,t={})=>({type:`string`,description:e,minLength:1,maxLength:200,...t}),H=(e,t=[])=>({type:`object`,properties:e,...t.length?{required:t}:{},additionalProperties:!1});function dn(e){let t=e.recipes.map(e=>e.id),n=(e.cookbooks??[]).map(e=>e.id),r=e.themePresets??Be,i=e=>({type:`string`,description:e,...n.length?{enum:[...n]}:{minLength:1}}),a=e=>un(`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:H({ids:ln(`Recipe ids to add.`,t)},[`ids`])},{name:`remove_recipes`,description:`Switch recipes off. A recipe another one needs is kept and reported.`,inputSchema:H({ids:ln(`Recipe ids to remove.`,t)},[`ids`])},{name:`add_features`,description:"Add single models no recipe covers, by qualified name (`@scope/pkg:Class`).",inputSchema:H({ids:ln(`Qualified model names to add.`)},[`ids`])},{name:`remove_features`,description:`Remove single models added with add_features.`,inputSchema:H({ids:ln(`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:H({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:H({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:H({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:H({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:H({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:H({model:un(`Qualified model name, e.g. @happyvertical/smrt-commerce:Order.`),field:un(`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},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:H({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:H({})},{name:`set_name`,description:`Name and describe the app. null clears a part.`,inputSchema:H({name:{type:[`string`,`null`],minLength:1,maxLength:60},description:{type:[`string`,`null`],minLength:1,maxLength:400}})},{name:`rename_section`,description:`Rename a menu section.`,inputSchema:H({id:a(`the section`),label:un(`The new name.`,{maxLength:60})},[`id`,`label`])},{name:`rename_item`,description:`Rename a menu entry. A null label restores its own name.`,inputSchema:H({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:H({id:a(`the section or entry`)},[`id`])},{name:`show`,description:`Show a hidden menu section or entry again.`,inputSchema:H({id:a(`the section or entry`)},[`id`])},{name:`validate`,description:`Check the current cookbook against the catalog and report typed diagnostics. Changes nothing.`,inputSchema:H({})},{name:`export_cookbook`,description:`The cookbook as a <name>.cookbook.json file (text in the result). Changes nothing.`,inputSchema:H({name:un(`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:H({undoId:un(`The undoId from a receipt.`),force:{type:`boolean`,description:`Undo even after later edits.`}},[`undoId`])}]}function fn(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:dn(e).map(e=>({type:`object`,properties:{name:{const:e.name},input:e.inputSchema},required:[`name`],additionalProperties:!1}))}}},required:[`commands`],additionalProperties:!1}}}var pn=e=>e===null?`null`:Array.isArray(e)?`array`:Number.isInteger(e)?`integer`:typeof e;function mn(e,t){let n=pn(t);return n===e||e===`number`&&n===`integer`}function hn(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=>mn(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=hn(o,r,`${n}[${e}]`);if(t)return t}}if(pn(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=hn(r,t,`${n}.${e}`);if(a)return a}}return null}function gn(e){return Object.fromEntries(dn(e).map(e=>[e.name,e.inputSchema]))}var U=(e,t,n={})=>({code:e,message:t,...n}),_n=e=>Array.isArray(e)?e.map(_n):e&&typeof e==`object`?Object.fromEntries(Object.keys(e).sort().map(t=>[t,_n(e[t])])):e,vn=e=>{try{return JSON.stringify(_n(e))??`undefined`}catch{return`unserializable`}};function yn(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return{ok:!1,error:U(`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:U(`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:U(`invalid_input`,`${e} is not part of a command.`,{path:e})};let o=hn(t[i],a);return o?{ok:!1,error:U(`invalid_input`,o.message,{path:o.path})}:{ok:!0,name:i,input:a}}var bn=e=>e===void 0||typeof e==`string`&&e.length>0&&e.length<=200?null:U(`invalid_input`,`id must be a non-empty string of at most 200 characters.`,{path:`id`}),xn=e=>e===void 0||Number.isInteger(e)&&e>=0?null:U(`invalid_input`,`expectedRevision must be a whole number.`,{path:`expectedRevision`});function Sn(e){let{catalog:t}=e,n=gn(t),r=dn(t),i=fn(t),a=e.maxJournal??500,o=e.maxUndo??20,s,c=0,l=new Map;if(e.state){let n=e.state,r=bt(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:$t(t,r.cookbook),applied:n.applied??null},c=n.revision;for(let e of n.journal??[])l.set(e.id,I(e))}else if(e.cookbook!==void 0){let n=bt(e.cookbook);if(!n.ok)throw Error(`Invalid cookbook: ${n.errors.join(`; `)}`);s={doc:$t(t,n.cookbook),applied:null}}else s={doc:$t(t,St()),applied:null};let u=new Map,d=[],f=0,p=new Map;function m(e,n){let{doc:r}=e,i=new Map(t.recipes.map(e=>[e.id,e])),a=Ht(t,r),o=new Set(t.models.filter(e=>e.exposed!==!1).map(e=>e.id));return{version:1,revision:n,app:{name:r.name??en(t,e.applied)??`my-app`,description:r.description??null,cookbook:e.applied},recipes:r.recipes.flatMap(e=>{let t=i.get(e);return t?[{id:e,label:t.label}]:[]}),features:r.features.filter(e=>o.has(e)),unavailable:[...r.recipes.filter(e=>!i.has(e)),...r.features.filter(e=>!o.has(e))],settings:{currency:a.currency,taxRate:Number((a.taxRate*100).toFixed(4)),paymentTerms:a.paymentTerms,pricesIncludeTax:a.pricesIncludeTax,taxRounding:a.taxRounding},theme:{text:qt(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:Ze(t,r).map(e=>({id:e.id,label:e.label,hidden:e.hidden,items:e.items.map(e=>({id:e.id,label:e.label,hidden:e.hidden}))})),policies:r.policies.length,undo:[...d]}}let h=()=>m(s,c);function g(){for(let[e,t]of p)t!==c&&(p.set(e,c),e(h()))}function _(e,t,n){if(e!==void 0)for(l.set(e,{id:e,fingerprint:t,result:I(n)});l.size>a;){let e=l.keys().next().value;if(e===void 0)break;l.delete(e)}}function v(e,t){if(e===void 0)return null;let n=l.get(e);return n?n.fingerprint===t?{...I(n.result),replayed:!0}:{ok:!1,id:e,error:U(`id_reuse`,`The id "${e}" was already used for a different command.`,{path:`id`})}:null}function y(t,n){let r=`${e.undoPrefix??`undo`}-${++f}`;u.set(r,{before:I(t),after:I(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||!xt(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 S(e,t){let n=u.get(t.undoId);if(!n)return{ok:!1,...e===void 0?{}:{id:e},error:U(`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:U(`conflict`,`The plan changed since; send force: true to undo anyway.`,{details:{currentRevision:c}})};let r=c,i=I(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,h());return g(),o}function C(e,r={}){try{let i=e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,a=i?.id,o=bn(a);if(o)return{ok:!1,error:o};let l=i?.expectedRevision??r.expectedRevision,u=xn(l);if(u)return{ok:!1,...a===void 0?{}:{id:a},error:u};let d=vn({name:i?.name,input:i?.input??{},expectedRevision:l}),f=v(a,d);if(f)return f;let p=e=>(_(a,d,e),e),m=e=>({ok:!1,...a===void 0?{}:{id:a},error:e}),C=yn(e,n,[`id`,`expectedRevision`]);if(!C.ok)return p(m(C.error));if(l!==void 0&&l!==c)return p(m(U(`conflict`,`The plan is at revision ${c}, not ${l}. Read the snapshot and try again.`,{details:{expectedRevision:l,currentRevision:c}})));if(C.name===`undo`)return p(S(a,C.input));let w=s,T=cn(t,w,C.name,C.input);if(!T.ok)return p(m(T.error));let E=c,D=b(w,T.state),O;D&&(s=T.state,c+=1,O=y(w,T.state));let ee=p(x(a,C.name,T,E,c,h(),O));return g(),ee}catch(e){return{ok:!1,error:U(`failed`,e instanceof Error?e.message:String(e))}}}function w(e){let r=(e,t)=>({ok:!1,...t===void 0?{}:{id:t},error:e,snapshot:h()});try{if(!e||typeof e!=`object`||Array.isArray(e))return r(U(`invalid_input`,`A batch is an object: { commands }.`));let i=e,a=i.id,o=bn(a);if(o)return r(o);let l=xn(i.expectedRevision);if(l)return r(l,a);let u=vn({commands:i.commands,expectedRevision:i.expectedRevision}),d=v(a,u);if(d)return`results`in d||`snapshot`in d?d:r(d.error,a);let f=e=>(_(a,u,e),e),p=i.commands;if(!Array.isArray(p)||p.length===0||p.length>50)return f(r(U(`invalid_input`,`commands must be a list of 1 to 50 commands.`,{path:`commands`}),a));let S=i.expectedRevision;if(S!==void 0&&S!==c)return f(r(U(`conflict`,`The plan is at revision ${c}, not ${S}. Read the snapshot and try again.`,{details:{expectedRevision:S,currentRevision:c}}),a));let C=(e,t,n)=>f(r(U(`batch_failed`,`Command ${e+1} (${String(t)}) failed: ${n.message}`,{path:`commands[${e}]`,details:{index:e,cause:n}}),a)),w=s,T=c,E=w,D=T,O=[];for(let[e,r]of p.entries()){let i=yn(r,n,[]);if(!i.ok)return C(e,r?.name,i.error);if(i.name===`undo`)return C(e,`undo`,U(`invalid_input`,`undo cannot run inside a batch.`));let a=cn(t,E,i.name,i.input);if(!a.ok)return C(e,i.name,a.error);let o=D;b(E,a.state)&&(D+=1),E=a.state,O.push(x(void 0,i.name,a,o,D,m(E,D)))}let ee=D!==T,te;if(ee){s=E,c=D,te=y(w,E);for(let e of O)e.receipt.changed&&delete e.receipt.undoId}let ne=f({ok:!0,...a===void 0?{}:{id:a},snapshot:h(),receipt:{...a===void 0?{}:{id:a},count:O.length,changed:ee,revisionBefore:T,revisionAfter:D,...te?{undoId:te}:{}},results:O});return g(),ne}catch(e){return r(U(`failed`,e instanceof Error?e.message:String(e)))}}return{run:C,batch:w,snapshot:h,cookbook:()=>I(s.doc),state:()=>({version:1,revision:c,applied:s.applied,cookbook:I(s.doc),journal:[...l.values()].map(e=>I(e))}),subscribe(e){return p.set(e,c),e(h()),()=>{p.delete(e)}},tools:r,batchTool:i}}var Cn=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 wn(){let e=u.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:D,models:e,cookbooks:k.map(e=>({id:e.id,name:e.name,document:e.document})),themePresets:x,currencies:[...Cn],settingTargets:te}}var Tn;function En(){return Tn??=wn(),Tn}var Dn=[`cookbooks`,`recipes`,`features`,`layout`,`theme`,`settings`,`export`],On={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:[...Dn],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 kn(e){return[...dn(e),On]}function An(e,t){return kn({...En(),recipes:e.map(e=>({id:e,label:e,models:[],nav:[],requires:[]})),cookbooks:t.map(e=>({id:e,name:e,document:{}}))})}var jn=An(D.map(e=>e.id),k.map(e=>e.id));Object.fromEntries(jn.map(e=>[e.name,e.inputSchema])),jn.map(e=>e.name);function Mn(e,t,n=`input`){return hn(e,t,n)?.message??null}function Nn(e){let t=e;return{get:()=>t,set:e=>{t=e}}}var W=(e,t,n={})=>({code:e,message:t,...n}),G=(e,t)=>({ok:!1,...t===void 0?{}:{id:t},error:e}),K=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Pn=new Set([`apply_cookbook`,`import_cookbook`]),Fn=e=>e instanceof Error?e.message:String(e);function In(e,t){if(!K(e))return JSON.stringify([t,e??null]);let{overviews:n,...r}=e;return JSON.stringify([t,r])}function Ln(e){let{catalog:t,port:n,options:r={},env:i={}}=e,a=i.section??Nn(null),o=i.tab??Nn(null),s=kn(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 b(){if(!n?.read){d=Sn(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=In(r,v());try{d=Sn({catalog:t,state:{version:1,revision:0,applied:v(),cookbook:r,journal:[]}})}catch(e){d=Sn({catalog:t}),p=Fn(e)}}b();function x(e,n){let r=d.state();try{d=Sn({catalog:t,state:{version:1,revision:r.revision+1,applied:v(),cookbook:e,journal:r.journal}}),p=null}catch(e){p=Fn(e)}m=new Map,h=new Map,f=n}function S(){if(n?.read)try{let e=n.read(),t=In(e,v());if(t===f)return;x(e,t)}catch(e){p=Fn(e)}}let C=()=>W(`failed`,`The app's document is not one the planner can read (${p}). Fix it or reset the cookbook, then try again.`),w=e=>G(C(),e);function T(e){if(!e)return;let t=m.get(e);return t||(t=`undo-${++g}`,m.set(e,t),h.set(t,e)),t}function E(e){let t=new Set(e);for(let[e,n]of m)t.has(e)||(m.delete(e),h.delete(n))}let D=e=>({...e,undo:e.undo.map(e=>T(e)),focus:{tab:y(),section:a.get()}});function O(){let e=d.snapshot();return E(e.undo),D(e)}function ee(e){if(!n?.read)return e;try{let t=n.read(),r=K(t)?t.overviews:void 0,{overviews:i,...a}=e;return Tt(K(r)&&Object.keys(r).length?{...a,overviews:r}:a)}catch{return e}}function te(e){if(!e.ok)return e;let{receipt:t}=e,n=e.replayed?void 0:T(t.undoId),{undoId:r,...i}=t,a=e.data;if(t.name===`export_cookbook`&&K(a)&&!e.replayed){let e=ee(a.cookbook);a={...a,cookbook:e,text:`${JSON.stringify(e,null,2)}\n`}}return{...e,...a===void 0?{}:{data:a},snapshot:O(),receipt:{...i,...n?{undoId:n}:{}}}}function ne(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=>Pn.has(e)),applied:i,libraryApplied:a}),n.read&&(f=In(n.read(),v())),a&&r.onReplaced?.()}function k(){if(!_.size)return;S();let e=O(),t=JSON.stringify(e);for(let[n,r]of _)r!==t&&(_.set(n,t),n(e))}function re(e,t){for(let t of Object.keys(e))if(![`name`,`input`,`id`,`expectedRevision`].includes(t))return W(`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 W(`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)?W(`invalid_input`,`expectedRevision must be a whole number.`,{path:`expectedRevision`}):null}function ie(e,t){let n=re(e,t),i=typeof e.id==`string`?e.id:void 0;if(n)return G(n,i);let s=e.expectedRevision??t.expectedRevision,c=e.input??{},u=Mn(l,c);if(u)return G(W(`invalid_input`,u,{path:`input`}),i);let f=d.snapshot().revision;if(s!==void 0&&s!==f)return G(W(`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&&!O().sections.some(e=>e.id===c.section))return G(W(`not_found`,`No menu section "${c.section}".`,{path:`input.section`}),i);let p=!1;c.tab&&Dn.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:O(),receipt:{name:`focus`,...i===void 0?{}:{id:i},summary:``,changed:p,revisionBefore:f,revisionAfter:f}};return k(),m}function ae(e){let t=e.input;if(!n?.prepareImport||!K(t))return{raw:e};let r=n.prepareImport(t.document);return r.ok?{raw:{...e,input:{...t,document:r.cookbook}},dropped:r.dropped}:G(W(`invalid_input`,r.error,{path:`input.document`}),e.id)}function oe(e){if(n?.read&&e.some(e=>typeof e==`string`&&Pn.has(e)))try{let e=n.read();if(Ct(d.cookbook())&&!Ct(e)){let n=d.state();d=Sn({catalog:t,state:{version:1,revision:n.revision,applied:v(),cookbook:e,journal:n.journal}}),m=new Map,h=new Map,f=In(e,v())}}catch(e){p=Fn(e)}}function se(e,t={}){try{if(S(),p)return w(K(e)&&typeof e.id==`string`?e.id:void 0);if(!K(e))return te(d.run(e,t));if(e.name===`focus`)return ie(e,t);if(oe([e.name]),p)return w(typeof e.id==`string`?e.id:void 0);let n=e,r;if(e.name===`import_cookbook`){let t=ae(e);if(`ok`in t)return t;n=t.raw,r=t.dropped}let i=d.snapshot().app.cookbook,a=ce(n),o=a?le(n,t,a):te(d.run(n,t));if(!o.ok)return o;!o.replayed&&o.receipt.changed&&ne([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}`)]}}),k(),s.ok?{...s,snapshot:O()}:s}catch(e){return G(W(`failed`,Fn(e)))}}function ce(e){let n=e.input;if(e.name!==`apply_cookbook`||!K(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 G(r.error.code===`batch_failed`&&t?t:r.error,e.id)}let i=r.results[0],a=r.replayed?void 0:T(r.receipt.undoId);return{...i,...r.id===void 0?{}:{id:r.id},...r.replayed?{replayed:!0}:{},snapshot:O(),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 ue(e){try{if(S(),p)return{ok:!1,error:C(),snapshot:O()};let t=K(e)&&Array.isArray(e.commands)?e.commands:[];if(oe(t.map(e=>K(e)?e.name:void 0)),p)return{ok:!1,error:C(),snapshot:O()};let n=d.snapshot().app.cookbook,r=d.batch(e);if(!r.ok)return{...r,snapshot:O()};!r.replayed&&r.receipt.changed&&ne(t.map(e=>String(e?.name)),n);let i=r.replayed?void 0:T(r.receipt.undoId),{undoId:a,...o}=r.receipt,s=O(),c={...r,snapshot:s,receipt:{...o,...i?{undoId:i}:{}},results:r.results.map(e=>({...e,snapshot:r.replayed?s:D(e.snapshot)}))};return k(),c}catch(e){return{ok:!1,error:W(`failed`,Fn(e)),snapshot:O()}}}function A(e){if(!K(e)||e.name!==`undo`||!K(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 fe=(e,t)=>{if(K(e)&&e.name===`undo`&&K(e.input)){let n=e.input.undoId;if(typeof n==`string`&&Mn(u,e.input)===null)return S(),O(),h.has(n)?de(se(A(e),t),n):G(W(`not_found`,`Nothing to undo for "${n}".`,{path:`input.undoId`}),e.id)}return se(A(e),t)};return{run:fe,batch:ue,snapshot(){return S(),O()},cookbook(){return S(),ee(d.cookbook())},undo(){S();let e=O().undo.at(-1);return e?fe({name:`undo`,input:{undoId:e}}):G(W(`not_found`,`Nothing to undo.`))},state:()=>d.state(),get tools(){return s},get batchTool(){return d.batchTool},observe(){return S(),JSON.stringify(O())},deliver:k,subscribe(e){i.watch?.start(),S();let t=O();return _.set(e,JSON.stringify(t)),e(t),()=>{_.delete(e),_.size||i.watch?.stop()}}}}function Rn(e){return e.recipes.length===0&&e.features.length===0&&e.policies.length===0&&Object.keys(e.exposure??{}).length===0&&e.theme===void 0&&d(e.layout)}function zn(e){if(!e.theme?.colorScheme)return e;let{colorScheme:t,...n}=e.theme;return{...e,theme:Object.keys(n).length?n:void 0}}function Bn(e){return JSON.stringify(zn(e))}function Vn(e,t){let n=zn(e);return Rn(n)?!1:t===null||JSON.stringify(n)!==t}function Hn(e,t,n){return t(n?O(structuredClone(e.document),n):e.document)}var Un=`smrt-planner:cookbook`,Wn=`smrt-planner:cookbook-applied`,Gn=new class{#e=n(null);get active(){return e(this.#e)}set active(e){s(this.#e,e,!0)}#t=n(null);get appliedWork(){return e(this.#t)}set appliedWork(e){s(this.#t,e,!0)}load(e=v()){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}l(this.active)}select(e,t=null,n=v()){this.active=e,this.appliedWork=t;try{n?.setItem(Un,e),t===null?n?.removeItem(Wn):n?.setItem(Wn,t)}catch{}}};function Kn(t){let r=n(i(t));return{get:()=>e(r),set:e=>{s(r,e,!0)}}}function qn(e){return{read:()=>e.snapshot(),applied:()=>Gn.active,prepareImport:e=>w(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&&(Gn.select(r,Bn(e.snapshot())),l(r))}}}function Jn(e=C,t={}){let n,i=Ln({catalog:En(),port:qn(e),options:t,env:{section:Kn(null),tab:Kn(null),watch:{start(){n||=o(()=>{r(()=>{i.observe(),a(i.deliver)})})},stop(){n?.(),n=void 0}}}});return i}var Yn=()=>({$schema:y,version:1,recipes:[],features:[],policies:[]});function Xn(e){let{store:t,settings:n,theme:r}=e;return{read(){let e={...Yn(),recipes:[...t.ids].sort()};n&&(e=O(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 Zn(e,t={}){return Ln({catalog:En(),port:Xn(e),options:t})}var Qn=[`cookbooks`,`recipes`,`features`,`layout`,`theme`,`settings`,`export`];function $n(e,t=`cookbooks`){let n=new URLSearchParams(e).get(`tab`);return Qn.find(e=>e===n)??t}var er=new class{#e=n(`cookbooks`);get active(){return e(this.#e)}set active(e){s(this.#e,e,!0)}fromSearch(e,t=`cookbooks`){this.active=$n(e,t)}leaveExport(e=`cookbooks`){this.active===`export`&&(this.active=e)}},tr={},nr=Jn(C,{navigation:{getTab:()=>er.active,setTab:e=>{er.active=e},setSection:e=>tr.openSection?.(e)},onReplaced:()=>tr.onReplaced?.()}),rr=`Qwen3-1.7B-q4f16_1-MLC`,ir=[{id:rr,label:`Qwen3 1.7B (recommended)`,downloadMB:1100,vramMB:2037},{id:`Llama-3.2-1B-Instruct-q4f16_1-MLC`,label:`Llama 3.2 1B (smallest)`,downloadMB:700,vramMB:879},{id:`Qwen3-4B-q4f16_1-MLC`,label:`Qwen3 4B (smarter, larger)`,downloadMB:2300,vramMB:3432}];function ar(e){return ir.find(t=>t.id===e)}function or(e){return e>=1e3?`about ${(e/1e3).toFixed(1)} GB`:`about ${e} MB`}function sr(e){return e.label.replace(/\s*\(.*\)\s*$/,``)}var cr=`Qwen3-4B-q4f16_1-MLC`;function lr(e,t){return t>=e.vramMB*1e6*1.2}async function ur(e=typeof navigator>`u`?void 0:navigator){try{return(await e?.gpu?.requestAdapter())?.limits?.maxBufferSize??0}catch{return 0}}function dr(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
23
|
-
`)}var q=class extends Error{code;provider;model;retryable;constructor(e,t,n,r,i=!1){super(e),this.code=t,this.provider=n,this.model=r,this.retryable=i,this.name=`AIError`}},fr=class extends q{constructor(e,t){super(`Model not found: ${e}`,`MODEL_NOT_FOUND`,t,e,!1),this.name=`ModelNotFoundError`}},pr=class extends q{constructor(e,t){super(`Input exceeds maximum context length`,`CONTEXT_LENGTH_EXCEEDED`,e,t,!1),this.name=`ContextLengthError`}},mr=class extends q{constructor(e=`webllm`,t){super(t??`WebGPU is not available in this environment (navigator.gpu is missing); on-device inference cannot run.`,`WEBGPU_UNAVAILABLE`,e,void 0,!1),this.name=`WebGPUUnavailableError`}},hr=class extends q{constructor(e){super("The webllm provider needs the optional peer dependency @mlc-ai/web-llm. Install it with `pnpm add @mlc-ai/web-llm` (or the npm/yarn equivalent).",`WEBLLM_PEER_MISSING`,`webllm`,void 0,!1),this.name=`WebLLMPeerMissingError`,e!==void 0&&(this.cause=e)}},gr=12e4,_r=Object.freeze({maxOutputTokens:131072,defaultOutputTokens:4096,maxReasoningTokens:1024,maxImagesPerRequest:1,onExceeded:`error`});function J(e,t,n){if(e===void 0)return t;if(!Number.isFinite(e)||e<=0)throw new q(`${n} must be a positive finite number`,`AI_LIMIT_INVALID`);return Math.trunc(e)}function vr(e){let t=e.generationLimits||{},n={maxOutputTokens:J(t.maxOutputTokens,_r.maxOutputTokens,`generationLimits.maxOutputTokens`),defaultOutputTokens:Math.min(J(t.defaultOutputTokens,_r.defaultOutputTokens,`generationLimits.defaultOutputTokens`),J(t.maxOutputTokens,_r.maxOutputTokens,`generationLimits.maxOutputTokens`)),maxReasoningTokens:J(t.maxReasoningTokens,_r.maxReasoningTokens,`generationLimits.maxReasoningTokens`),maxImagesPerRequest:J(t.maxImagesPerRequest,_r.maxImagesPerRequest,`generationLimits.maxImagesPerRequest`),onExceeded:t.onExceeded||_r.onExceeded};if(![`error`,`clamp`].includes(n.onExceeded))throw new q(`generationLimits.onExceeded must be "error" or "clamp"`,`AI_LIMIT_INVALID`);return{...e,timeout:J(e.timeout,gr,`timeout`),maxRetries:(()=>{if(e.maxRetries===void 0)return 0;if(!Number.isFinite(e.maxRetries)||e.maxRetries<0)throw new q(`maxRetries must be a non-negative finite number`,`AI_LIMIT_INVALID`);return Math.trunc(e.maxRetries)})(),generationLimits:n}}function yr(e){switch(e){case!1:case`none`:return 0;case`minimal`:return 1024;case`low`:return 2048;case`medium`:return 4096;case`high`:return 8192;default:return}}function br(e,t,n,r,i,a){if(!Number.isFinite(e)||e<0)throw new q(`${r} must be a non-negative finite number`,`AI_LIMIT_INVALID`,i,a);let o=Math.trunc(e);if(o<=t)return o;if(n===`clamp`)return t;throw new q(`${r} ${o} exceeds configured ceiling ${t}`,`AI_LIMIT_EXCEEDED`,i,a)}function xr(e,t,n,r){let i=vr(e).generationLimits,a=t.maxTokens??i.defaultOutputTokens??i.maxOutputTokens,o=t.thinkingLevel??e.thinkingLevel,s=t.reasoning!==void 0||o!==void 0||t.includeThoughts===!0?t.reasoning?.maxTokens??yr(t.reasoning?.effort??o)??i.maxReasoningTokens:0;return{...t,maxTokens:br(a,i.maxOutputTokens,i.onExceeded,`maxTokens`,n,r),reasoning:{...t.reasoning,maxTokens:br(s,i.maxReasoningTokens,i.onExceeded,`reasoning.maxTokens`,n,r),includeThoughts:t.reasoning?.includeThoughts??t.includeThoughts}}}function Sr(e,t={}){let n=vr(e),r=J(t.timeout,n.timeout,`timeout`),i=new AbortController,a=!1,o=()=>i.abort(t.signal?.reason);t.signal?.aborted?o():t.signal?.addEventListener(`abort`,o,{once:!0});let s=setTimeout(()=>{a=!0,i.abort(Error(`AI request timed out after ${r}ms`))},r);return{signal:i.signal,timeout:r,didTimeout:()=>a,cleanup:()=>{clearTimeout(s),t.signal?.removeEventListener(`abort`,o)}}}[...new Set([`getVideoGenerationJob`,`fetchVideoGenerationResult`,`cancelVideoGenerationJob`])];function Cr(e,t,n,r,i,a,o){if(!e.onUsage)return;let s=e.usageTags,c=s||o?{...s,...o}:void 0;try{e.onUsage({provider:t,model:r,operation:n,usage:i,duration:Date.now()-a,timestamp:new Date,tags:c})}catch{}}var Y=`webllm`,wr=4096,Tr={chat:!0,completion:!0,embeddings:!1,streaming:!0,functions:!0,vision:!1,fineTuning:!1,imageEmbeddings:!1,imageGeneration:!1,videoGeneration:!1,tts:!1,voiceCloning:!1,voiceDesign:!1,maxContextLength:wr,supportedOperations:[`chat`,`completion`,`streaming`,`functions`]},Er=new WeakMap,Dr=new Map;async function Or(){try{let e=await c(()=>import(`./DL8aLXmX.js`),[],import.meta.url),t=typeof e?.CreateMLCEngine==`function`?e:e?.default;if(typeof t?.CreateMLCEngine!=`function`)throw Error(`@mlc-ai/web-llm did not export CreateMLCEngine`);return t}catch(e){throw new hr(e)}}function kr(){return!!globalThis.navigator?.gpu}function X(e){throw new q(`${e} is not supported by the webllm provider.`,`NOT_SUPPORTED`,Y)}function Ar(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var jr=class{options;explicitModel;factoryEngine;localEngines=new Map;constructor(e){this.explicitModel=e.defaultModel??e.model,this.options=vr({...e,defaultModel:this.explicitModel??`Llama-3.2-1B-Instruct-q4f16_1-MLC`})}async acquireEngine(e,t){let n=this.options.engine;if(n)return typeof n==`function`?(this.factoryEngine??=n().catch(e=>{throw this.factoryEngine=void 0,e}),Fr(this.factoryEngine,t)):n;if(!kr())throw new mr(Y);let r=this.options.appConfig?this.localEngines:Dr,i=r.get(e);if(!i){let t=new Set,n={listeners:t,promise:this.createEngine(e,t)};n.promise.catch(()=>{r.get(e)===n&&r.delete(e)}),r.set(e,n),i=n}let a=this.options.onLoadProgress;a&&i.listeners.add(a);try{return await Fr(i.promise,t)}finally{a&&i.listeners.delete(a)}}async createEngine(e,t){return(await Or()).CreateMLCEngine(e,{...this.options.appConfig?{appConfig:this.options.appConfig}:{},initProgressCallback:e=>{for(let n of t)try{n(e)}catch{}}})}mapMessages(e){return e.map(e=>{if(e.role===`user`&&Array.isArray(e.content))return{role:`user`,content:e.content.map(e=>e.type===`text`?{type:`text`,text:e.text}:{type:`image_url`,image_url:{url:e.image_url.url}}),...e.name?{name:e.name}:{}};let t=dr(e.content);return e.role===`tool`||e.role===`function`?{role:`tool`,content:t,tool_call_id:e.tool_call_id??e.name??``}:e.role===`assistant`?Ar({role:`assistant`,content:t||(e.tool_calls?.length?null:``),tool_calls:e.tool_calls?.map(e=>({id:e.id,type:e.type,function:{name:e.function.name,arguments:e.function.arguments}}))}):{role:e.role,content:t,...e.name?{name:e.name}:{}}})}mapResponseFormat(e){return e.responseSchema===void 0?e.responseFormat?.type===`json_object`?{type:`json_object`}:void 0:{type:`json_object`,schema:typeof e.responseSchema==`string`?e.responseSchema:JSON.stringify(e.responseSchema)}}buildRequest(e,t,n,r,i){let a=i&&t.tools?.length?t.tools.map(e=>({type:`function`,function:{name:e.function.name,description:e.function.description,parameters:e.function.parameters}})):void 0;return Ar({model:n,messages:this.mapMessages(e),max_tokens:t.maxTokens,temperature:t.temperature,top_p:t.topP,n:t.n,stop:t.stop,frequency_penalty:t.frequencyPenalty,presence_penalty:t.presencePenalty,seed:t.seed,tools:a,tool_choice:a?t.toolChoice:void 0,response_format:this.mapResponseFormat(t),stream:r,stream_options:r?{include_usage:!0}:void 0})}requestModel(e,t){return this.options.engine?t.model??this.explicitModel:e}mapUsage(e){let t=e;if(t)return{promptTokens:t.prompt_tokens??0,completionTokens:t.completion_tokens??0,totalTokens:t.total_tokens??0}}mapFinishReason(e){switch(e){case`length`:return`length`;case`tool_calls`:return`tool_calls`;default:return`stop`}}assertNotInterrupted(e,t){if(e===`abort`)throw new q(`Generation was interrupted before it finished`,`AI_INTERRUPTED`,Y,t,!0)}mapError(e,t){if(e instanceof q)return e;let n=e?.name??``,r=e instanceof Error?e.message:String(e);if(n===`WebGPUNotAvailableError`||n===`WebGPUNotFoundError`)return new mr(Y,r);if(n===`ContextWindowSizeExceededError`||n===`PrefillChunkSizeSmallerThanImageError`)return new pr(Y,t);if(n===`ModelNotFoundError`||n===`SpecifiedModelNotFoundError`||n===`UnsupportedModelIdError`||n===`ModelNotLoadedError`)return new fr(t??r,Y);let i=new q(r,n===`DeviceLostError`?`WEBGPU_DEVICE_LOST`:`API_ERROR`,Y,t);return i.cause=e,i}abortError(e,t,n){if(e?.didTimeout())return new q(`AI request timed out after ${e.timeout}ms`,`AI_TIMEOUT`,Y,n);if(t.signal?.aborted)return new q(`AI request aborted by caller`,`AI_ABORTED`,Y,n)}async lockEngine(e,t){let n=Er.get(e)??Promise.resolve(),r=()=>{},i=new Promise(e=>{r=e});Er.set(e,n.then(()=>i));try{await Fr(n,t)}catch(e){throw r(),e}return r}bindInterrupt(e,t){let n=()=>{try{Promise.resolve(e.interruptGenerate()).catch(()=>{})}catch{}};return t.aborted&&n(),t.addEventListener(`abort`,n,{once:!0}),()=>t.removeEventListener(`abort`,n)}async chat(e,t={}){let n=Date.now(),r,i,a,o,s,c=t.model||this.options.defaultModel||`Llama-3.2-1B-Instruct-q4f16_1-MLC`;try{t=xr(this.options,t,Y,c);let l=await this.acquireEngine(c,t.signal);r=Sr(this.options,t),a=await this.lockEngine(l,r.signal),i=this.bindInterrupt(l,r.signal),o=l.chat.completions.create(this.buildRequest(e,t,this.requestModel(c,t),!1,!0));let u=o,d=!1,f=()=>{d=!0};u.then(f,f),s=()=>d?void 0:u;let p=await Fr(o,r.signal);if(r.signal.aborted)throw this.abortError(r,t,c)??r.signal.reason;let m=p?.choices?.[0];if(this.assertNotInterrupted(m?.finish_reason,c),!m)throw new q(`No choices returned from webllm`,`NO_CHOICES`,Y);let h=this.mapUsage(p.usage);Cr(this.options,Y,`chat`,p.model||c,h,n,t.usageTags);let g=m.message?.tool_calls?.map(e=>({id:e.id,type:`function`,function:{name:e.function.name,arguments:e.function.arguments}}));return{content:m.message?.content||``,usage:h,model:p.model||c,finishReason:this.mapFinishReason(m.finish_reason),...g?.length?{toolCalls:g}:{}}}catch(e){throw this.abortError(r,t,c)??this.mapError(e,c)}finally{i?.(),Nr(a,s?.()),r?.cleanup()}}async complete(e,t={}){return this.chat([{role:`user`,content:e}],{model:t.model,maxTokens:t.maxTokens,temperature:t.temperature,topP:t.topP,n:t.n,stop:t.stop,stream:t.stream,onProgress:t.onProgress,signal:t.signal,timeout:t.timeout,reasoning:t.reasoning,usageTags:t.usageTags,continueOnLength:t.continueOnLength})}async message(e,t={}){let n=[...t.history||[],{role:t.role||`user`,content:e}];return(await this.chat(n,{model:t.model,maxTokens:t.maxTokens,temperature:t.temperature,topP:t.topP,stop:t.stop,stream:t.stream,frequencyPenalty:t.frequencyPenalty,presencePenalty:t.presencePenalty,responseFormat:t.responseFormat,responseSchema:t.responseSchema,seed:t.seed,tools:t.tools,toolChoice:t.toolChoice,onProgress:t.onProgress,signal:t.signal,timeout:t.timeout,reasoning:t.reasoning,usageTags:t.usageTags,continueOnLength:t.continueOnLength})).content}async*stream(e,t={}){let n=Date.now(),r,i,a,o,s,c=!1,l,u=t.model||this.options.defaultModel||`Llama-3.2-1B-Instruct-q4f16_1-MLC`;try{t=xr(this.options,t,Y,u),a=await this.acquireEngine(u,t.signal),r=Sr(this.options,t),o=await this.lockEngine(a,r.signal),i=this.bindInterrupt(a,r.signal);let d=a.chat.completions.create(this.buildRequest(e,t,this.requestModel(u,t),!0,!1)),f;try{f=await Fr(d,r.signal)}catch(e){throw l=d.then(e=>Pr(e[Symbol.asyncIterator](),a),()=>{}),e}s=f[Symbol.asyncIterator]();let p,m;for(;;){let e=await s.next();if(e.done){c=!0;break}let n=e.value,r=n.choices?.[0];p=r?.finish_reason??p,n.usage&&(m=this.mapUsage(n.usage));let i=r?.delta?.content;i&&(t.onProgress?.(i),yield i)}if(r.signal.aborted)throw this.abortError(r,t,u)??r.signal.reason;this.assertNotInterrupted(p,u),t.onFinishReason?.(this.mapFinishReason(p)),Cr(this.options,Y,`stream`,u,m,n,t.usageTags)}catch(e){throw this.abortError(r,t,u)??this.mapError(e,u)}finally{if(s&&!c&&a){try{Promise.resolve(a.interruptGenerate()).catch(()=>{})}catch{}await Mr(s)}i?.(),Nr(o,l),r?.cleanup()}}async countTokens(e){return Math.ceil(e.length/4)}async getModels(){let e=await Or(),t=this.options.appConfig?.model_list??e.prebuiltAppConfig.model_list,n=new Set(e.functionCallingModelIds??[]);return t.filter(e=>e.model_type!==1).map(e=>{let t=e.model_type===2,r=n.has(e.model_id);return{id:e.model_id,name:e.model_id,description:e.vram_required_MB?`Runs on-device via WebGPU (~${Math.round(e.vram_required_MB)} MB VRAM)`:`Runs on-device via WebGPU`,contextLength:e.overrides?.context_window_size??wr,capabilities:[`text`,`chat`,...r?[`functions`]:[],...t?[`vision`]:[]],supportsFunctions:r,supportsVision:t}})}async getCapabilities(){return{...Tr}}async embed(e,t={}){return X(`Embeddings`)}async embedImage(e,t={}){return X(`Image embeddings`)}async describeImage(e,t,n={}){return X(`Image description`)}async generateImage(e,t={}){return X(`Image generation`)}async submitVideoGenerationJob(e){return X(`Video generation`)}async getVideoGenerationJob(e){return X(`Video generation`)}async fetchVideoGenerationResult(e){return X(`Video generation`)}async cancelVideoGenerationJob(e){return X(`Video generation`)}async validateVideoGenerationAccess(){return X(`Video generation`)}async synthesizeSpeech(e,t){return X(`Text-to-speech`)}streamSpeech(e,t){let n=new q(`Text-to-speech streaming is not supported by the webllm provider.`,`NOT_SUPPORTED`,Y);return{[Symbol.asyncIterator]:()=>({next:()=>Promise.reject(n)})}}async cloneVoice(e){return X(`Voice cloning`)}async designVoice(e){return X(`Voice design`)}async getVoices(e){return X(`Voice listing`)}};async function Mr(e){try{for(;!(await e.next()).done;);}catch{}}function Nr(e,t){e&&(t?t.then(e,e):e())}async function Pr(e,t){try{if((await e.next()).done)return;await Promise.resolve(t?.interruptGenerate())}catch{return}await Mr(e)}function Fr(e,t){return t?t.aborted?Promise.reject(new q(`AI request aborted by caller`,`AI_ABORTED`,Y)):new Promise((n,r)=>{let i=()=>r(new q(`AI request aborted by caller`,`AI_ABORTED`,Y));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})}):e}var Ir={createWorker:()=>new Worker(new URL(new URL(`../workers/llm.worker-BYu-MLm1.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),createEngine:async(e,t,n)=>{let{CreateWebWorkerMLCEngine:r}=await c(async()=>{let{CreateWebWorkerMLCEngine:e}=await import(`./DL8aLXmX.js`);return{CreateWebWorkerMLCEngine:e}},[],import.meta.url);return r(e,t,{initProgressCallback:e=>n(e)})}};async function Lr(e,t,n,r=Ir){if(n?.aborted)throw new DOMException(`Cancelled`,`AbortError`);let i=r.createWorker(),a=()=>i.terminate(),o,s=new Promise((e,t)=>{o=()=>{a(),t(new DOMException(`Cancelled`,`AbortError`))},n?.addEventListener(`abort`,o,{once:!0})});try{return{engine:await Promise.race([r.createEngine(i,e,t),s]),dispose:a}}catch(e){throw a(),e}finally{o&&n?.removeEventListener(`abort`,o)}}var Rr=e=>!!e&&typeof e==`object`&&e.kind===`cookbook-offer`&&typeof e.offerId==`string`,zr=class{find;#e=n(i({}));get offers(){return e(this.#e)}set offers(e){s(this.#e,e,!0)}applier=null;counter=0;constructor(e){this.find=e}pending(){return Object.values(this.offers).find(e=>e.status===`pending`)}engaged(){return Object.values(this.offers).some(e=>e.status===`pending`||e.status===`applied`)}offer(e){let t=this.pending();if(t?.cookbookId===e)return null;t&&(t.status=`replaced`);let n=`offer-${++this.counter}`;return this.offers[n]={id:n,cookbookId:e,status:`pending`,error:``},{kind:`cookbook-offer`,offerId:n}}accept(e){let t=this.offers[e];if(t?.status!==`pending`)return;let n=this.find(t.cookbookId),r=n?this.applier?this.applier(n):`Not ready yet.`:`Unknown cookbook.`;r||!n?(t.status=`failed`,t.error=r??`Could not set it up.`):t.status=`applied`}decline(e){let t=this.offers[e];t?.status===`pending`&&(t.status=`declined`)}},Br=`smrt-planner:assistant:v1`;function Vr(){return{modelId:rr,consented:[]}}function Hr(e){let t=Vr();try{let n=e?.getItem(Br);if(!n)return t;let r=JSON.parse(n);typeof r.modelId==`string`&&ar(r.modelId)&&(t.modelId=r.modelId),Array.isArray(r.consented)&&(t.consented=r.consented.filter(e=>typeof e==`string`&&!!ar(e)))}catch{}return t}function Ur(e,t){try{e?.setItem(Br,JSON.stringify(t))}catch{}}var Wr=e=>!!e&&typeof e==`object`&&e.kind===`theme-undo`&&typeof e.undoId==`string`,Gr=class{store;controller;#e=n(i({}));get undos(){return e(this.#e)}set undos(e){s(this.#e,e,!0)}counter=0;constructor(e,t){this.store=e,this.controller=t}record(e,n){let r=`theme-undo-${++this.counter}`;return this.undos[r]={id:r,previous:e?structuredClone(t(e)):void 0,status:`available`,...n?{commandUndoId:n}:{}},{kind:`theme-undo`,undoId:r}}undo(e){let t=this.undos[e];t?.status===`available`&&(t.commandUndoId&&this.controller?.run({name:`undo`,input:{undoId:t.commandUndoId}}).ok||this.store.write(t.previous),t.status=`undone`)}};function Kr(e,t=[],n=!1,r=!1,i=[]){let a=e.map(e=>e.id),o={type:`array`,items:{enum:a},maxItems:a.length},s={reply:{type:`string`,maxLength:200},add:o,remove:o};return t.length&&(s.cookbook={enum:[...t.map(e=>e.id),null]}),n&&(s.settings={type:`object`,properties:{currency:{type:`string`,pattern:`^[A-Z]{3}$`},taxRate:{type:`number`,minimum:0,maximum:100},paymentTerms:{type:`string`,maxLength:40},pricesIncludeTax:{type:`boolean`},taxRounding:{enum:[`line`,`document`]}},additionalProperties:!1}),r&&(s.theme={type:`object`,properties:{preset:{enum:[...x]},primary:{type:`string`,pattern:`^#[0-9a-fA-F]{6}$`},colorScheme:{enum:[`light`,`dark`]},borderRadius:{enum:[...S]},density:{enum:[...T]},contrast:{enum:[...E]}},additionalProperties:!1}),i.length&&(s.open={enum:[...i,null]}),{type:`object`,properties:s,required:[`reply`,`add`,`remove`],additionalProperties:!1}}function qr(e){let t={};if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e;if(typeof n.currency==`string`){let e=n.currency.trim().toUpperCase();Cn.has(e)&&(t.currency=e)}let r=n.taxRate;if(typeof r==`number`&&Number.isFinite(r)&&r>=0&&r<=100&&(t.taxRate=r),typeof n.paymentTerms==`string`){let e=[...n.paymentTerms].map(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127?` `:e).join(``).trim();e&&e.length<=40&&(t.paymentTerms=e)}return typeof n.pricesIncludeTax==`boolean`&&(t.pricesIncludeTax=n.pricesIncludeTax),(n.taxRounding===`line`||n.taxRounding===`document`)&&(t.taxRounding=n.taxRounding),t}function Jr(e){let t={};if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e;typeof n.preset==`string`&&x.includes(n.preset)&&(t.preset=n.preset);let r=_(n.primary);return r&&(t.primary=r),(n.colorScheme===`light`||n.colorScheme===`dark`||n.colorScheme===`system`)&&(t.colorScheme=n.colorScheme),S.includes(n.borderRadius)&&(t.borderRadius=n.borderRadius),T.includes(n.density)&&(t.density=n.density),E.includes(n.contrast)&&(t.contrast=n.contrast),t}function Yr(e){return e.replace(/<think>[\s\S]*?<\/think>/gi,``).replace(/<think>[\s\S]*$/i,``).trim()}function Xr(e){let t=/"reply"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(e);if(!t)return null;let n=t[1];n=n.replace(/\\$/,``);try{n=JSON.parse(`"${n}"`)}catch{n=n.replace(/\\n/g,` `).replace(/\\"/g,`"`)}return n.trim()||null}function Zr(e,t,n=[],r={}){let i=new Set(t.map(e=>e.id)),a=Yr(e),o=e=>({reply:e,add:[],remove:[],cookbook:null,settings:{},theme:{}}),s=/^[\s`]*[{[]/.test(a)||/"reply"\s*:/.test(a),c=()=>o(s?Xr(a)??`Sorry, say that again?`:a),l;try{l=JSON.parse(a)}catch{return c()}if(!l||typeof l!=`object`||Array.isArray(l))return c();let u=l,d=e=>Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&i.has(e)))]:[],f=d(u.add),p=d(u.remove),m=new Set(f.filter(e=>p.includes(e))),h=r.commands?Qr(u.commands):[];return{reply:typeof u.reply==`string`?u.reply.trim():``,add:f.filter(e=>!m.has(e)),remove:p.filter(e=>!m.has(e)),cookbook:typeof u.cookbook==`string`&&n.some(e=>e.id===u.cookbook)?u.cookbook:null,settings:qr(u.settings),theme:Jr(u.theme),...h.length?{commands:h}:{},...typeof u.open==`string`&&r.sections?.includes(u.open)?{open:u.open}:{}}}function Qr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=8)break;if(!n||typeof n!=`object`)continue;let{name:e,input:r}=n;typeof e==`string`&&t.push({name:e,input:r??{}})}return t}function $r(e,t){let n=e=>t.find(t=>t.id===e),r=e=>n(e)?.label??e,i=e=>e.map(r).join(`, `),a=[];e.added.length&&a.push(`Added ${i(e.added)}.`);let o=e.added.filter(e=>n(e)?.nav?.length===0);return o.length&&a.push(`${i(o)} ${o.length===1?`adds`:`add`} nothing to the menu.`),e.removed.length&&a.push(`Removed ${i(e.removed)}.`),e.kept.length&&a.push(`Kept ${i(e.kept)} (needed).`),a.join(` `)}var ei={name:10,synonym:6,keyword:4},ti=1.5,ni=new Set([`a`,`an`,`and`,`the`,`of`,`for`,`to`,`in`,`on`,`or`,`general`,`simple`]),ri=[`car`,`vehicle`,`metal`,`steel`,`gates`,`studio`,`classes`,`members`,`shop`,`order`,`item`,`material`,`customer`,`sales`,`stock`,`schedule`,`terms`];function ii(e){return e.length<=3?e:e.endsWith(`ies`)?`${e.slice(0,-3)}y`:e.endsWith(`sses`)?e.slice(0,-2):/(us|ss|is)$/.test(e)?e:e.endsWith(`s`)?e.slice(0,-1):e}function ai(e){return e.normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/['’]s\b/g,``).replace(/['’]/g,``).replace(/[^a-z0-9]+/g,` `).trim().split(` `).filter(Boolean).map(ii).join(` `)}var oi=new Set(ri.map(ai)),si={"commerce.customers":[`customer`,`client`,`contacts`,`patrons`],"commerce.purchases":[`purchase`,`buy supplies`,`reorder`,`order from suppliers`],"commerce.sales":[`sell`,`sale`,`sales order`,`point of sale`],"commerce.vendors":[`vendor`,`supplier`,`who we buy from`],"inventory.stock":[`inventory`,`track stock`,`stock levels`,`warehouse`,`count stock`],"products.simple":[`product`,`price list`,`menu`,`things we sell`],"products.clothing":[`clothes`,`shirts`,`fashion`,`sizes and colours`],"products.ingredients":[`ingredient`,`recipe`,`raw material`,`flour`,`components`],"commerce.estimates":[`estimate`,`quote`,`quotes for customers`,`price quote`,`bid`],"commerce.wholesale":[`wholesale`,`bulk`,`trade customers`,`resellers`],"commerce.invoicing":[`invoice`,`send invoices`,`bill customers`,`get paid`,`receipts`],"commerce.fulfillment":[`ship`,`shipping`,`courier`,`parcels`,`deliver`],"commerce.agreements":[`contract`,`agreement`,`sign contracts`],"commerce.leases":[`lease`,`rent out`,`equipment hire`],"commerce.licenses":[`licence`,`licence sales`,`software licenses`],"ledgers.bookkeeping":[`books`,`keep the books`,`bookkeeper`,`accountant`,`expenses`],"projects.tracker":[`project`,`task`,`to do list`,`bug`,`ticket`],"events.calendar":[`appointment`,`schedule appointments`,`event`,`meeting`,`reservation`],"sales.pipeline":[`lead`,`pipeline`,`prospect`,`follow up`,`sales funnel`]};function ci(e,t){let n=ai(e);if(!n)return null;let r=n.split(` `);return r.length===1&&ni.has(n)?null:{text:n,tier:t,weak:t!==`name`&&r.every(e=>oi.has(e)),words:r.length}}function Z(e,t,n){let r=ci(t,n);if(!r)return;let i=e.terms.find(e=>e.text===r.text);i?ei[r.tier]>ei[i.tier]&&(i.tier=r.tier,i.weak=r.weak):e.terms.push(r)}function li(e){return ai(e).split(` `).filter(e=>e&&!ni.has(e))}var ui=[`theme`,`colour`,`color`,`colour scheme`,`dark mode`,`light mode`,`brand`,`branding`,`style`,`warmer`,`cooler`,`font`];function di(e,t=[],n={}){let r=[];for(let t of e){let e={kind:`recipe`,id:t.id,terms:[],exact:ai(t.label)};Z(e,t.label,`name`),Z(e,(t.id.split(`.`).pop()??``).replace(/[-_]/g,` `),`name`);for(let n of li(t.label))Z(e,n,`synonym`);for(let n of t.synonyms)Z(e,n,`synonym`);for(let n of si[t.id]??[])Z(e,n,`keyword`);r.push(e)}for(let e of t){let t={kind:`cookbook`,id:e.id,terms:[],exact:ai(e.name)};Z(t,e.name,`name`),Z(t,e.id.replace(/[-_]/g,` `),`name`);for(let n of e.keywords??[])Z(t,n,`keyword`);r.push(t)}if(n.theme){let e={kind:`theme`,id:`theme`,terms:[]};for(let t of ui)Z(e,t,`keyword`);r.push(e)}return{entries:r}}function fi(e,t){let n=ai(t),r=` ${n} `,i=[];for(let t of e.entries){let e=0,a=!1,o=[];for(let n of t.terms)r.includes(` ${n.text} `)&&(o.push(n.text),e+=ei[n.tier]*(n.words>1?ti:1)*(n.weak?.5:1),n.weak||(a||=!0));o.length&&(t.exact&&t.exact===n&&(e+=1),i.push({kind:t.kind,id:t.id,score:e,confidence:a?`strong`:`weak`,terms:o}))}return i.sort((e,t)=>t.score-e.score||e.id.localeCompare(t.id))}var pi=5,mi=2,hi=[{says:`I run a bakery`,cookbook:`bakery`,answer:{reply:`The Bakery cookbook covers that.`,add:[],remove:[],cookbook:`bakery`}},{says:`I need to send invoices`,recipes:[`commerce.invoicing`],answer:{reply:`Added invoicing for billing customers.`,add:[`commerce.invoicing`],remove:[]}},{says:`we don't need the pipeline`,recipes:[`sales.pipeline`],answer:{reply:`Removed leads and pipeline.`,add:[],remove:[`sales.pipeline`]}},{says:`we're in Canada, 13% tax`,settings:!0,answer:{reply:`Set to Canadian dollars and 13% tax.`,add:[],remove:[],settings:{currency:`CAD`,taxRate:13}}},{says:`make it warmer`,theme:!0,answer:{reply:`Gave it a warm amber brand colour.`,add:[],remove:[],theme:{primary:`#d97706`}}},{says:`hello`,answer:{reply:`Hi. What kind of business is it?`,add:[],remove:[]}}];function gi(e,t,n,r){return hi.filter(i=>(i.recipes??[]).every(t=>e.has(t))&&(!i.cookbook||t.has(i.cookbook))&&(!i.settings||n)&&(!i.theme||r)).map(e=>`"${e.says}" -> ${JSON.stringify(e.answer)}`)}var _i=`reports.runtime`;function vi(e){return`${Number((e*100).toFixed(4))}%`}function yi(e,t,n=[],r,i,a,o=[]){let s=i!==void 0,c=(i??[]).filter(e=>e.kind===`recipe`).slice(0,pi).map(e=>e.id),l=(i??[]).filter(e=>e.kind===`cookbook`).slice(0,mi).map(e=>e.id),u=new Set([...c,...t]),d=new Set(l),f=e=>{let t=e.synonyms.length?` Also called: ${e.synonyms.join(`, `)}.`:``;return`- ${e.id}: ${e.label}. ${e.summary}${t}`},p=[`You help assemble a small business app. Reply as JSON.`,`"reply": answer what they just said in one sentence of 12 words or fewer. No greeting; never repeat a reply.`,`"add"/"remove": recipe ids, only what they ask to add or drop; else []. Dependencies are automatic.`];n.length&&p.push(`"cookbook": id only if their business clearly fits, else null.`),r&&p.push(`"settings": only what they state: currency (ISO), taxRate (percent), paymentTerms, pricesIncludeTax (true when their prices include tax), taxRounding (line|document); else omit, and do not mention them otherwise.`),a&&p.push(`"theme": only if they ask for a look: {"preset": material|glass|studio|smrt|happyvertical} or {"primary": "#rrggbb"}, optional "colorScheme": light|dark, "borderRadius": none|sm|md|lg|xl|full, "density": comfortable|touch, "contrast": auto|standard|more; else omit.`),o.length&&p.push(`"open": a menu section id only when they ask to see or go to one, else null.`),p.push(`"reply" never claims anything beyond add, remove, cookbook, settings, theme and open: the app reports what changed.`),e.some(e=>e.id===`reports.runtime`)&&p.push(`A report or summary of their data needs ${_i} (Reports): add it, and open only its section, never another. You cannot build the report itself yet.`);let m=gi(new Set(e.map(e=>e.id)),new Set(n.map(e=>e.id)),!!r,!!a);m.length&&p.push(``,`Examples:`,...m);let h=!!a&&(i??[]).some(e=>e.kind===`theme`);if(c.length||l.length||h){let e=[];h&&e.push(`theming (use "theme")`),l.length&&e.push(`cookbook ${l.join(`, `)}`),c.length&&e.push(`recipes ${c.join(`, `)}`),p.push(``,`Looks relevant: ${e.join(`; `)}.`)}let g=e=>`- ${e.id}: ${e.name}. ${e.summary}`,_=e=>e.join(`, `),v=e.filter(e=>!s||u.has(e.id)),y=s?e.filter(e=>!u.has(e.id)):[];if(p.push(``),v.length&&p.push(`Recipes:`,...v.map(f)),y.length&&p.push(`Other recipes: ${_(y.map(e=>`${e.id} (${e.label})`))}.`),n.length){let e=n.filter(e=>!s||d.has(e.id)),t=s?n.filter(e=>!d.has(e.id)):[];p.push(``),e.length&&p.push(`Cookbooks:`,...e.map(g)),t.length&&p.push(`Other cookbooks: ${_(t.map(e=>`${e.id} (${e.name})`))}.`)}if(p.push(``,`Currently on: ${t.length?t.join(`, `):`none`}.`),r){let e=r.paymentTerms?`, terms ${r.paymentTerms}`:``,t=r.pricesIncludeTax?`, prices include tax`:`, prices exclude tax`,n=r.taxRounding===`document`?`, tax rounded per document`:``;p.push(`Settings: currency ${r.currency}, tax ${vi(r.taxRate)}${e}${t}${n}.`)}return a&&p.push(`Theme: ${b(a.current)}.`),o.length&&p.push(`Menu: ${o.map(e=>`${e.id} (${e.label})`).join(`, `)}.`),p.join(`
|
|
24
|
-
`)}var bi=`Plan your app`,xi=`What would you like to build?`,Si=400,Ci=e=>Object.keys(e).length>0;function wi(e,t,n){let r=e.run({name:t,input:n});return r.ok?{summary:r.receipt.summary,undoId:r.receipt.undoId}:{summary:``}}var Ti=(e,t,n)=>wi(e,t,n).summary;function Ei(e,t){let n=[];for(let r of t){let t=e.run(r);if(!t.ok){n.push(`The server's ${r.name} was refused: ${t.error.message}`);break}t.receipt.summary&&n.push(t.receipt.summary)}return n.join(` `)}var Di=`Nothing in the app changed.`,Oi=`Building the report itself is not available in the planner yet; it will live under Reports.`,ki=`item:reports:RuntimeReport`;function Ai(e,t,n){return t||(n||e.trim().endsWith(`?`)?e:[e,Di].filter(Boolean).join(` `))}function ji(e,t,n){let r=n.find(e=>e.id===t)?.label??t,i=e.run({name:`focus`,input:{section:t}});return i.ok?`Opened ${r}.`:`Could not open ${r}: ${i.error.message}`}function Mi(e,t){let n=t.add.length?e.run({name:`add_recipes`,input:{ids:t.add}}):null,r=t.remove.length?e.run({name:`remove_recipes`,input:{ids:t.remove}}):null,i=n?.ok?n.receipt.changes?.added??[]:[],a=r?.ok?r.receipt.changes?.removed??[]:[];return{added:i.filter(e=>!a.includes(e)),removed:a.filter(e=>!i.includes(e)),kept:r?.ok?r.receipt.changes?.kept??[]:[]}}function Ni(e){let t=e.now??(()=>Date.now()),n=0,r=e=>`${e}-${++n}`,i={id:`planner`,title:bi,isResolved:!1,messageCount:0,lastMessageAt:null},a=[],o=new Map,s=null,c=(e,n,o,s)=>{let c={id:r(`m`),threadId:i.id,content:n,role:e,createdAt:new Date(t()),...o?{clientRequestId:o}:{}};return s&&(c.toolCallData=s),a.push(c),i.messageCount=a.length,i.lastMessageAt=c.createdAt,c},l=e.controller??Zn({store:e.store,settings:e.settings,theme:e.theme}),u=di(e.recipes,e.cookbooks??[],{theme:!!e.theme}),d=c(`assistant`,xi);async function f(t){let n=e.model();if(!n)return{content:(typeof e.unavailable==`function`?e.unavailable():e.unavailable)??`Download a model first, then I can help. The cards on the Planner page work without one.`};s=new AbortController;try{let r=e.cookbooks??[],i=a.filter(e=>e!==d).slice(0,-1).slice(-6).map(e=>({role:e.role,content:e.content})),o=fi(u,t),c=e.menu?.()??[],f=Zr(await n.message(t,{history:[{role:`system`,content:yi(e.recipes,e.store.ids,r,e.settings?.read(),o,e.theme?{current:e.theme.read()}:void 0,c)},...i],responseSchema:Kr(e.recipes,r,!!e.settings,!!e.theme,c.map(e=>e.id)),temperature:0,maxTokens:Si,signal:s.signal}),e.recipes,r,{commands:typeof e.acceptCommands==`function`?e.acceptCommands():e.acceptCommands,sections:c.map(e=>e.id)}),p=Mi(l,f),m=e.settings&&Ci(f.settings)?Ti(l,`set_settings`,f.settings):``,h=e.theme?.read(),g=e.theme&&Ci(f.theme)?wi(l,`set_theme`,f.theme):null,_=g?.undoId&&e.themeUndos?e.themeUndos.record(h,g.undoId):void 0,v=(f.commands??[]).length?Ei(l,f.commands??[]):``,y=o.some(e=>e.kind===`recipe`&&e.id===`reports.runtime`),b=l.snapshot().sections.find(e=>e.items.some(e=>e.id===ki))?.id,x=f.open&&(!y||f.open===b)?f.open:void 0,S=x?ji(l,x,c):``,C=[$r(p,e.recipes),m,g?.summary??``,v,S].filter(Boolean).join(` `),w=o.find(e=>e.kind===`cookbook`&&e.confidence===`strong`)?.id,T=f.cookbook??(w&&e.offers?.engaged?.()===!1?w:null),E=T?e.offers?.offer(T)??void 0:void 0,D=E?r.find(e=>e.id===T):void 0,O=[Ai(f.reply||(D?`Set up ${D.name}?`:``),C,!!E),y?Oi:``].filter(Boolean).join(` `);return O&&e.onReply?.(O),{content:O,refs:E&&_?[E,_]:E??_}}catch(e){return s?.signal.aborted?{content:`Stopped.`}:{content:`Sorry, the model could not answer: ${e instanceof Error?e.message:String(e)}`}}finally{s=null}}return{async listThreads(){return[i]},async createThread(){return i},async loadMessages(){return[...a]},async sendMessage(e){let t=o.get(e.clientRequestId);if(t)return t;let n=c(`user`,e.content,e.clientRequestId),r=await f(e.content),i={inProgress:!1,userMessage:n,assistantMessage:c(`assistant`,r.content,void 0,r.refs)};return o.set(e.clientRequestId,i),i},async uploadAttachment(e){throw Error(`The assistant cannot take attachments (${e.name}).`)},abort(){s?.abort()}}}function Pi(e,t){return/^qwen3/i.test(t)?{message:(t,n)=>e.message(`${t} /no_think`,n)}:e}var Fi=class{#e=n(`idle`);get status(){return e(this.#e)}set status(e){s(this.#e,e,!0)}#t=n(i({modelId:``,consented:[]}));get prefs(){return e(this.#t)}set prefs(e){s(this.#t,e,!0)}#n=n(i({progress:0,text:``}));get progress(){return e(this.#n)}set progress(e){s(this.#n,e,!0)}#r=n(``);get error(){return e(this.#r)}set error(e){s(this.#r,e,!0)}#i=n(`browser`);get mode(){return e(this.#i)}set mode(e){s(this.#i,e,!0)}#a=n(``);get remoteLabel(){return e(this.#a)}set remoteLabel(e){s(this.#a,e,!0)}transport;offers=new zr(re);themeUndos;loaded=null;chat=null;abort=null;loadGeneration=0;options;constructor(e){this.options=e,this.prefs=Hr(e.storage),this.status=(e.webgpu??kr)()?`idle`:`unsupported`,this.themeUndos=e.theme?new Gr(e.theme,e.controller):null,this.transport=Ni({model:()=>this.chat,store:e.store,recipes:e.recipes,cookbooks:k,offers:this.offers,settings:e.settings,theme:e.theme,controller:e.controller,themeUndos:this.themeUndos??void 0,acceptCommands:()=>this.mode===`host`,unavailable:()=>this.mode===`byo`?`Connect your model on the AI page first, then I can help. The cards on the Planner page work without one.`:this.mode===`host`?`The assistant is not available right now. The cards on the Planner page work without it.`:this.mode===`manual`?`Inference is off. The cards on the Planner page work without it.`:`Download a model first, then I can help. The cards on the Planner page work without one.`,onReply:t=>e.onReply?.(t),menu:e.menu})}setMode(e){e!==this.mode&&this.unload(),this.mode=e,this.status=e===`browser`?(this.options.webgpu??kr)()?`idle`:`unsupported`:`idle`}useRemote(e,t){this.mode!==`browser`&&(this.chat=e,this.remoteLabel=e?t:``,this.status=e?`ready`:`idle`)}get consented(){return this.prefs.consented.includes(this.prefs.modelId)}select(e){ar(e)&&this.status!==`loading`&&(this.prefs={...this.prefs,modelId:e},Ur(this.options.storage,this.prefs))}async start(){if(this.status===`loading`||this.status===`unsupported`)return;let e=this.prefs.modelId;if(!ar(e))return;this.status=`loading`,this.error=``,this.progress={progress:0,text:`Starting`};let t=new AbortController,n=++this.loadGeneration;this.abort=t;try{let r=await Lr(e,e=>{this.progress=e},t.signal,this.options.host??Ir);if(n!==this.loadGeneration||this.mode!==`browser`){r.dispose();return}this.loaded=r,this.prefs={...this.prefs,consented:[...new Set([...this.prefs.consented,e])]},Ur(this.options.storage,this.prefs),this.chat=Pi(new jr({type:`webllm`,engine:r.engine,model:e}),e),this.status=`ready`}catch(e){if(n!==this.loadGeneration)return;t.signal.aborted?this.status=`idle`:(this.error=e instanceof Error?e.message:String(e),this.status=`error`)}finally{n===this.loadGeneration&&(this.abort=null)}}cancel(){this.abort?.abort()}unload(){this.loadGeneration+=1;let e=this.abort;this.abort=null,e?.abort(),this.transport.abort(),this.loaded?.dispose(),this.loaded=null,this.chat=null,this.status!==`unsupported`&&(this.status=`idle`)}},Ii=[{id:`moonshine-base`,label:`Moonshine base`,note:`Accurate and still quick, best for talking as you go (default)`,adapter:`moonshine`,bytes:p[`moonshine-base`]?.bytes??0},{id:`moonshine-tiny`,label:`Moonshine tiny`,note:`Fastest, less accurate`,adapter:`moonshine`,bytes:p[`moonshine-tiny`]?.bytes??0},{id:`whisper-tiny.en`,label:`Whisper tiny`,note:`English, the original choice`,adapter:`whisper-local`,bytes:p[`whisper-tiny.en`]?.bytes??0}],Li=`moonshine-base`;function Ri(e){return Ii.find(t=>t.id===e)??Ii[0]}var zi=`smrt-planner:voice:v1`;function Bi(e){try{let t=e?.getItem(zi);if(t){let e=JSON.parse(t),n=e.local===!0,r=Ii.find(t=>t.id===e.model)?.id;return{local:n,preferLocal:e.preferLocal===!0,model:r??(n?`whisper-tiny.en`:`moonshine-base`)}}}catch{}return{local:!1,preferLocal:!1,model:Li}}function Vi(e,t){try{e?.setItem(zi,JSON.stringify(t))}catch{}}function Hi(e){return Bi(e).local}function Ui(e,t){Vi(e,{...Bi(e),local:t})}function Wi(e){return Bi(e).preferLocal}function Gi(e){return Bi(e).model}function Ki(e,t,n){return e===`works`?`browser`:t&&n?`enable-cached`:`offer`}var qi=class{#e=n(`checking`);get status(){return e(this.#e)}set status(e){s(this.#e,e,!0)}#t=n(!1);get cached(){return e(this.#t)}set cached(e){s(this.#t,e,!0)}#n=n(0);get progress(){return e(this.#n)}set progress(e){s(this.#n,e,!0)}#r=n(``);get error(){return e(this.#r)}set error(e){s(this.#r,e,!0)}#i=n(!1);get browserWorks(){return e(this.#i)}set browserWorks(e){s(this.#i,e,!0)}#a=n(!1);get preferLocal(){return e(this.#a)}set preferLocal(e){s(this.#a,e,!0)}#o=n(0);get size(){return e(this.#o)}set size(e){s(this.#o,e,!0)}#s=n(Li);get model(){return e(this.#s)}set model(e){s(this.#s,e,!0)}#c=n(!1);get preparing(){return e(this.#c)}set preparing(e){s(this.#c,e,!0)}#l=n(null);get dictation(){return e(this.#l)}set dictation(e){s(this.#l,e)}handle=null;abort=null;options;generation=0;constructor(e){this.options=e}async init(){let e=++this.generation;try{await this.probeAndOffer(e)}catch(t){if(e!==this.generation)return;this.status=`error`,this.error=t instanceof Error?t.message:String(t)}}async probeAndOffer(e){let t=await(this.options.probe??ie)();if(e!==this.generation)return;this.browserWorks=t===`works`,this.preferLocal=Wi(this.options.storage),this.model=Gi(this.options.storage);let n=this.preferLocal&&t===`works`?`unreliable`:t;if(n===`works`){this.dictation=(this.options.browserSource??(()=>f({type:`browser-speech`})))(),this.status=`browser`;return}let r=this.options.createModel(this.model);this.handle?.dispose(),this.handle=r,this.size=r.estimateSize();let i=await r.isCached().catch(()=>!1);e===this.generation&&(this.cached=i,Ki(n,Hi(this.options.storage),this.cached)===`enable-cached`?await this.enable():this.status=`offer`)}async enable(){let e=this.handle;if(!e||this.status===`downloading`)return;let t=++this.generation;this.status=`downloading`,this.error=``,this.progress=0,this.preparing=!1;let n=new AbortController;this.abort=n;try{if(await e.load({onProgress:e=>{t===this.generation&&(this.progress=e.bytesTotal>0?e.bytesLoaded/e.bytesTotal:0,this.preparing=e.state===`extracting`)},signal:n.signal}),t!==this.generation)return;Ui(this.options.storage,!0),this.cached=!0;let r=Ri(this.model);this.dictation=(this.options.localSource??((e,t)=>f({type:t.adapter,modelHandle:e})))(e,r),this.status=`ready`}catch(e){if(t!==this.generation)return;n.signal.aborted?this.status=`offer`:(this.error=e instanceof Error?e.message:String(e),this.status=`error`)}finally{t===this.generation&&(this.abort=null,this.preparing=!1)}}async setPreferLocal(e){this.browserWorks&&e!==this.preferLocal&&await this.restart({preferLocal:e})}async setModel(e){e!==this.model&&Ii.some(t=>t.id===e)&&await this.restart({model:e})}async restart(e){this.generation++,this.abort?.abort(),this.abort=null,this.preparing=!1,this.handle?.dispose(),this.handle=null,this.dictation=null,Vi(this.options.storage,{...Bi(this.options.storage),...e}),this.status=`checking`,await this.init()}cancel(){this.abort?.abort()}dismiss(){this.status=`dismissed`}dispose(){this.generation++,this.abort?.abort(),this.handle?.dispose(),this.handle=null,this.dictation=null}},Ji=[`json_schema`,`json_object`,`none`],Yi=12e4;function Q(e){try{let t=new URL(e.trim());if(t.protocol!==`http:`&&t.protocol!==`https:`||t.username||t.password)return null;for(let e of t.searchParams.keys())if(/^(?:api[-_]?key|key|token|authorization|secret|password)$/i.test(e))return null;return`${t.origin}${t.pathname.replace(/\/+$/,``)}`}catch{return null}}function Xi(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||/^127(\.\d{1,3}){3}$/.test(t)}function Zi(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`&&Xi(t.hostname)}catch{return!1}}function Qi(e){try{return new URL(e.trim()).origin}catch{return null}}var $i=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`EndpointError`}};function ea(e){return e===401||e===403?`the endpoint refused the key (${e})`:e===404?`the endpoint or model was not found (404), check the address and model name`:e===429?`the endpoint is rate limiting you (429)`:`the endpoint answered ${e}`}function ta(e){let t=(e?.choices?.[0])?.message?.content;if(typeof t==`string`)return t;if(Array.isArray(t))return t.map(e=>e&&typeof e==`object`&&`text`in e?String(e.text):``).join(``);throw new $i(`the endpoint sent no reply text`)}function na(e,t){if(e!==`none`)return e===`json_schema`&&t&&typeof t==`object`?{type:`json_schema`,json_schema:{name:`planner_turn`,strict:!1,schema:t}}:{type:`json_object`}}function ra(e){let t=Q(e.baseUrl);if(!t)throw new $i(`the address is not a valid http(s) URL`);if(e.apiKey&&!Zi(t))throw new $i(`a key is only sent over https, or to this computer; use an https address`);let n=`${t}/chat/completions`,r=e.fetch??fetch,i=Math.max(0,Ji.indexOf(e.jsonMode??`json_schema`));async function a(t,i){let a=AbortSignal.timeout(Yi);try{return await r(n,{method:`POST`,headers:{"content-type":`application/json`,...e.apiKey?{authorization:`Bearer ${e.apiKey}`}:{}},body:JSON.stringify(t),credentials:`omit`,signal:i?AbortSignal.any([i,a]):a})}catch(e){throw i?.aborted?e:new $i(`could not reach the endpoint. Is it running, and does it allow this page (CORS)?`)}}async function o(t,n={}){let r=n.json!==!1;for(;;){let o=r?Ji[i]??`none`:`none`,s=na(o,n.schema),c=await a({model:e.model,messages:t,stream:!1,temperature:n.temperature??0,...n.maxTokens?{max_tokens:n.maxTokens}:{},...s?{response_format:s}:{}},n.signal);if(c.ok)return r&&e.onJsonMode?.(o),ta(await c.json().catch(()=>null));if(r&&(c.status===400||c.status===422)&&i<Ji.length-1)i+=1;else throw new $i(ea(c.status),c.status)}}return{complete:o,message(e,t){return o([...(t?.history??[]).map(({role:e,content:t})=>({role:e,content:t})),{role:`user`,content:e}],{maxTokens:t?.maxTokens,signal:t?.signal,temperature:t?.temperature,schema:t?.responseSchema})}}}async function ia(e){try{return{ok:!0,message:(await ra({...e,jsonMode:`none`}).complete([{role:`user`,content:`Reply with the single word OK.`}],{maxTokens:8,json:!1})).trim()?`Connected to ${e.model}.`:`Connected to ${e.model}, but it sent an empty reply.`}}catch(e){return{ok:!1,message:e instanceof $i?`Could not connect: ${e.message}.`:`Could not connect.`}}}var aa=[{id:`ollama`,label:`Ollama (on this computer)`,baseUrl:`http://localhost:11434/v1`,model:`llama3.2`,keyless:!0,cors:`Ollama only answers pages it trusts. Start it with OLLAMA_ORIGINS set to this site, for example OLLAMA_ORIGINS=https://your-site.example ollama serve (on macOS: launchctl setenv OLLAMA_ORIGINS https://your-site.example, then restart Ollama). A page served from http://localhost needs no change.`},{id:`openrouter`,label:`OpenRouter`,baseUrl:`https://openrouter.ai/api/v1`,model:`openai/gpt-4o-mini`,cors:`OpenRouter accepts calls from any web page, so no setup is needed. Use a key with a spending limit.`},{id:`openai`,label:`OpenAI`,baseUrl:`https://api.openai.com/v1`,model:`gpt-4o-mini`,cors:`OpenAI accepts calls from web pages when the request carries a key. Use a restricted key with a low spending limit: anyone with access to this browser profile can read it.`},{id:`custom`,label:`Custom OpenAI-compatible endpoint`,baseUrl:``,customUrl:!0,cors:`The server must answer the browser's CORS preflight: allow this site's origin, the "authorization" and "content-type" headers, and the POST and OPTIONS methods.`}];function oa(e){if(!e?.length)return[...aa];let t=[];for(let n of e){let e=typeof n==`string`?aa.find(e=>e.id===n):n;e&&!t.some(t=>t.id===e.id)&&t.push(e)}return t.length?t:[...aa]}var sa=`smrt-planner:inference:v1`,ca=`smrt-planner:inference-key:v1`,la=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function ua(e){let t={preset:``,active:!1,entries:{}};try{let n=e?.getItem(sa);if(!n)return t;let r=JSON.parse(n);if(!la(r))return t;typeof r.preset==`string`&&(t.preset=r.preset),t.active=r.active===!0;let i=!1;if(la(r.entries)){for(let[e,n]of Object.entries(r.entries))if(la(n)&&typeof n.baseUrl==`string`&&typeof n.model==`string`){let r=Q(n.baseUrl)??``;i||=r!==n.baseUrl,t.entries[e]={baseUrl:r,model:n.model}}}i&&(t.active=!1,e?.setItem(sa,JSON.stringify(t)))}catch{}return t}function da(e){let t={};try{let n=e?.getItem(ca),r=n?JSON.parse(n):null;if(la(r))for(let[e,n]of Object.entries(r))la(n)&&typeof n.key==`string`&&n.key&&typeof n.origin==`string`&&n.origin&&(t[e]={origin:n.origin,key:n.key})}catch{}return t}var fa=class{presets;#e=n(``);get presetId(){return e(this.#e)}set presetId(e){s(this.#e,e,!0)}#t=n(i({}));get entries(){return e(this.#t)}set entries(e){s(this.#t,e,!0)}#n=n(i({}));get keys(){return e(this.#n)}set keys(e){s(this.#n,e,!0)}#r=n(!1);get active(){return e(this.#r)}set active(e){s(this.#r,e,!0)}#i=n(`idle`);get testStatus(){return e(this.#i)}set testStatus(e){s(this.#i,e,!0)}#a=n(``);get testMessage(){return e(this.#a)}set testMessage(e){s(this.#a,e,!0)}options;credentialStorage;constructor(e){if(this.options=e,this.credentialStorage=e.credentialPersistence===`memory`?null:e.storage,e.credentialPersistence===`memory`)try{e.storage?.removeItem(ca)}catch{}this.presets=oa(e.presets);let t=ua(e.storage);this.keys=da(this.credentialStorage),this.entries=t.entries,this.presetId=this.presets.some(e=>e.id===t.preset)?t.preset:this.presets[0]?.id??``,this.active=t.active&&this.complete}get preset(){return this.presets.find(e=>e.id===this.presetId)}get baseUrl(){return this.entries[this.presetId]?.baseUrl??this.preset?.baseUrl??``}get model(){return this.entries[this.presetId]?.model??this.preset?.model??``}get key(){let e=this.keys[this.presetId];return e&&e.origin===Qi(this.baseUrl)?e.key:``}get keyForOtherAddress(){let e=this.keys[this.presetId];return!!e&&e.origin!==Qi(this.baseUrl)}get complete(){let e=Q(this.baseUrl);return!!e&&!!this.model.trim()&&(!!this.preset?.keyless||!!this.key.trim()&&Zi(e))}select(e){this.presets.some(t=>t.id===e)&&(this.presetId=e,this.resetTest(),this.save())}setBaseUrl(e){this.entries={...this.entries,[this.presetId]:{baseUrl:e,model:this.model}},this.edited()}setModel(e){this.entries={...this.entries,[this.presetId]:{baseUrl:this.baseUrl,model:e}},this.edited()}setKey(e){let t=Qi(this.baseUrl),n=e.trim();!n||!t?this.forgetKey():(this.keys={...this.keys,[this.presetId]:{origin:t,key:n}},this.edited())}forgetKey(){let{[this.presetId]:e,...t}=this.keys;this.keys=t,this.edited()}chat(){if(!this.complete)return null;let e=Q(this.baseUrl);return e?ra({baseUrl:e,model:this.model.trim(),apiKey:this.preset?.keyless?void 0:this.key,fetch:this.options.fetch}):null}async test(){let e=Q(this.baseUrl);if(!e||!this.model.trim())return this.testStatus=`failed`,this.testMessage=`Enter an http(s) address and a model first.`,{ok:!1,message:this.testMessage};if(!this.preset?.keyless&&!this.key.trim())return this.testStatus=`failed`,this.testMessage=this.keyForOtherAddress?`The saved key was entered for another address. Enter it again for this one.`:`Enter a key first.`,{ok:!1,message:this.testMessage};if(!this.preset?.keyless&&!Zi(e))return this.testStatus=`failed`,this.testMessage=`A key is only sent over https, or to this computer. Use an https address.`,{ok:!1,message:this.testMessage};this.testStatus=`testing`,this.testMessage=``;let t=await ia({baseUrl:e,model:this.model.trim(),apiKey:this.preset?.keyless?void 0:this.key,fetch:this.options.fetch});return this.testStatus=t.ok?`ok`:`failed`,this.testMessage=t.message,t}use(){return this.complete?(this.active=!0,this.save(),this.options.onChange?.(),!0):!1}stop(){this.active=!1,this.save(),this.options.onChange?.()}resetTest(){this.testStatus=`idle`,this.testMessage=``}edited(){this.resetTest();let e=this.active;e&&!this.complete&&(this.active=!1),this.save(),e&&this.options.onChange?.()}save(){try{let e=Object.fromEntries(Object.entries(this.entries).map(([e,t])=>[e,{baseUrl:Q(t.baseUrl)??``,model:t.model}])),t={preset:this.presetId,active:this.active,entries:e};this.options.storage?.setItem(sa,JSON.stringify(t)),this.credentialStorage?.setItem(ca,JSON.stringify(this.keys))}catch{}}};function pa(e,t,n,r=`local`){let i=ua(e);if(!i.active)return null;let a=oa(t).find(e=>e.id===i.preset),o=i.entries[i.preset],s=Q(o?.baseUrl??a?.baseUrl??``),c=(o?.model??a?.model??``).trim(),l=da(r===`memory`?null:e)[i.preset],u=l&&l.origin===Qi(s??``)?l.key:``;return!a||!s||!c||!a.keyless&&(!u||!Zi(s))?null:ra({baseUrl:s,model:c,apiKey:a.keyless?void 0:u,fetch:n})}var ma=`my-app`;function ha(e){return(e??``).normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function ga(e){return`${ha(e)||`my-app`}.cookbook.json`}function _a(e){return new TextEncoder().encode(ya(e)).length}function va(e){if(e<1e3)return`${e} bytes`;let t=e/1024;return`${t<10?t.toFixed(1):Math.round(t)} KB`}function ya(e){return`${JSON.stringify(e,null,2)}\n`}function ba(e,t){let n=URL.createObjectURL(new Blob([ya(e)],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=ga(t),document.body.append(r),r.click(),r.remove(),URL.revokeObjectURL(n)}var xa=`x-kitchen-token`,Sa=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function Ca(e){if(typeof e!=`string`)return!1;let t=e.trim();try{let e=t.startsWith(`/`)&&!t.startsWith(`//`),n=new URL(t,e?`https://planner.invalid`:void 0);return!e&&n.protocol!==`http:`&&n.protocol!==`https:`||n.username||n.password||n.hash?!1:![...n.searchParams.keys()].some(e=>/^(?:api[-_]?key|key|token|authorization|secret|password)$/i.test(e))}catch{return!1}}function wa(e){if(!Sa(e))return;let{endpoint:t}=e;if(Ca(t))return{endpoint:t.trim(),...Object.hasOwn(e,`token`)?{tokenInConfig:!0}:{}}}var Ta=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[];async function Ea(e,t,n=fetch){let r;try{r=await n(e.endpoint,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json`,[xa]:e.token},body:ya(t)})}catch{return{ok:!1,errors:["The kitchen could not be reached. Is `smrt kitchen` still running?"]}}let i;try{i=await r.json()}catch{i=void 0}if(r.ok&&Sa(i)&&i.ok===!0)return{ok:!0,result:{dir:typeof i.dir==`string`?i.dir:``,mode:i.mode===`update`?`update`:`new`,installed:i.installed===!0,added:Ta(i.added),nextSteps:Ta(i.nextSteps)}};let a=Sa(i)?Ta(i.errors):[];return Sa(i)&&typeof i.error==`string`&&a.push(i.error),{ok:!1,errors:a.length?a:[`The kitchen answered ${r.status}.`]}}var Da=[`manual`,`browser`,`host`,`byo`],Oa={mode:`browser`},ka={mode:`manual`},Aa=`planner.config.json`,ja=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function Ma(e){if(typeof e!=`string`)return!1;let t=e.trim();if(!t)return!1;try{let e=t.startsWith(`/`)&&!t.startsWith(`//`),n=new URL(t,e?`https://planner.invalid`:void 0);if(!e&&n.protocol!==`http:`&&n.protocol!==`https:`||n.username||n.password||n.hash)return!1;for(let e of n.searchParams.keys())if(/^(?:api[-_]?key|key|token|authorization|secret|password)$/i.test(e))return!1;return!0}catch{return!1}}function Na(e){if(!ja(e))return null;let{id:t,label:n,baseUrl:r,model:i,keyless:a,cors:o}=e;return typeof t!=`string`||!/^[a-z0-9][a-z0-9-]{0,31}$/.test(t)||typeof n!=`string`||!n.trim()||!Ma(r)||r.startsWith(`/`)?null:{id:t,label:n.trim(),baseUrl:r.trim(),...typeof i==`string`&&i.trim()?{model:i.trim()}:{},...a===!0?{keyless:!0}:{},...typeof o==`string`&&o.trim()?{cors:o.trim()}:{}}}var $=e=>({config:ka,notice:`The assistant settings could not be used (${e}), so inference is off. The planner still works manually.`});function Pa(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length===0)return null;let n=[];for(let r of e){if(typeof r!=`string`||!Da.includes(r)||r===t||n.includes(r))return null;n.push(r)}return n}function Fa(e){if(e===void 0)return{};if(!ja(e))return null;if(e.presets===void 0)return{};if(!Array.isArray(e.presets)||e.presets.length===0)return null;let t=[];for(let n of e.presets){if(typeof n==`string`&&n.trim()){t.push(n.trim());continue}let e=Na(n);if(!e)return null;t.push(e)}return{presets:t}}function Ia(e){if(!ja(e))return $(`not an object`);let t=e.inference;if(t===void 0)return{config:Oa};if(!ja(t))return $(`"inference" is not an object`);let n=t.mode;if(n===void 0)return{config:Oa};if(!Da.includes(n))return $(`unknown mode "${String(n)}"`);let r=n,i=Pa(t.alternatives,r);if(!i)return $(`alternatives must be unique supported modes other than mode`);let a=t.credentialPersistence;if(a!==void 0&&a!==`local`&&a!==`memory`)return $(`credentialPersistence must be "local" or "memory"`);let o=[r,...i],s;if(o.includes(`host`)){let e=t.host;if(!ja(e)||!Ma(e.endpoint))return $(`host mode needs host.endpoint, an http(s) URL or path`);s={endpoint:e.endpoint.trim()}}let c;return o.includes(`byo`)&&(c=Fa(t.byo)??void 0,!c)?$(`byo.presets must be a non-empty valid list`):{config:{mode:r,...i.length?{alternatives:i}:{},...a?{credentialPersistence:a}:{},...s?{host:s}:{},...c?{byo:c}:{}}}}function La(e){try{let t=JSON.parse(e),n=Ia(t),r=ja(t)?wa(t.kitchen):void 0;return r?{...n,kitchen:r}:n}catch{return $(`it is not valid JSON`)}}function Ra(e){return Ia({inference:e})}async function za(e=``,t=fetch){let n;try{n=await t(`${e.replace(/\/$/,``)}/${Aa}`,{headers:{accept:`application/json`},cache:`no-cache`})}catch{return{config:Oa}}if(n.status===404)return{config:Oa};if(!n.ok)return $(`the file answered ${n.status}`);let r=await n.text();return/^\s*</.test(r)?{config:Oa}:La(r)}var Ba=1e3,Va=2e3,Ha=6e4,Ua=(e,t)=>e.length>t?e.slice(0,t):e;function Wa(e){let t=e.fetch??fetch;return{async message(n,r){let i=(r?.history??[]).filter(e=>e.role===`user`||e.role===`assistant`).slice(-6).map(e=>({role:e.role,content:Ua(e.content,Ba)})),a={version:1,message:Ua(n,Va),snapshot:e.snapshot(),...i.length?{history:i}:{}},o=AbortSignal.timeout(Ha),s=r?.signal?AbortSignal.any([r.signal,o]):o,c=await t(e.endpoint,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json`,...e.headers?.()},body:JSON.stringify(a),signal:s});if(!c.ok)throw Error(`the server answered ${c.status}`);return await c.text()}}}function Ga(e){return[Ka(e.think),Ja(e.hear),Ya(e.speak)]}function Ka(e){let t={id:`think`,name:`Think`};if(e.mode===`manual`)return{...t,state:`off`,label:`Think: inference off`,where:`Off`};if(e.mode===`host`)return{...t,state:e.status===`ready`?`ready`:`available`,label:`Think: Server`,where:`Server`};if(e.mode===`byo`){let n=e.remote?`Your model: ${e.remote}`:``;return e.status===`ready`&&e.remote?{...t,state:`ready`,label:`Think: ${n}`,where:n}:{...t,state:`available`,label:`Think: your own model not connected`,where:`Your model`}}return{...qa(e),where:`In browser`}}function qa(e){let t={id:`think`,name:`Think`};return e.status===`unsupported`?{...t,state:`off`,label:`Think: unavailable, this browser has no WebGPU`}:e.status===`ready`?{...t,state:`ready`,label:`Think: ${e.model} ready`}:e.status===`loading`?{...t,state:`available`,label:`Think: ${e.model} loading, ${Math.round(e.progress*100)}%`}:{...t,state:`available`,label:e.downloaded?`Think: ${e.model} downloaded, not loaded`:`Think: not set up`}}function Ja(e){let t={id:`hear`,name:`Hear`};return e.mic?e.status===`browser`?{...t,state:`ready`,label:`Hear: voice typing ready, using your browser`}:e.status===`ready`?{...t,state:`ready`,label:`Hear: voice typing ready, using the downloaded model`}:e.status===`downloading`?{...t,state:`available`,label:`Hear: downloading the speech model`}:{...t,state:`available`,label:`Hear: not set up`}:{...t,state:`off`,label:`Hear: unavailable, this browser has no microphone access`}}function Ya(e){let t={id:`speak`,name:`Speak`};return e.supported?e.readAloud?{...t,state:`ready`,label:`Speak: reading replies aloud with browser voices`}:{...t,state:`available`,label:`Speak: not switched on`}:{...t,state:`off`,label:`Speak: unavailable, this browser has no speech synthesis`}}function Xa(e){return e.dismissed||e.built?!1:!(e.thinkDownloaded||e.hearDownloaded||e.readAloud)}var Za=`smrt-planner:ai:v1`;function Qa(e){let t={dismissed:!1,readAloud:!1,handsFree:!1,sendOnPause:!1};try{let n=e?.getItem(Za);if(!n)return t;let r=JSON.parse(n);t.dismissed=r.dismissed===!0,t.readAloud=r.readAloud===!0,t.handsFree=r.handsFree===!0,t.sendOnPause=r.sendOnPause===!0}catch{}return t}function $a(e,t){try{e?.setItem(Za,JSON.stringify(t))}catch{}}var eo=new class{session;voice;#e=n(i({dismissed:!1,readAloud:!1,handsFree:!1,sendOnPause:!1}));get prefs(){return e(this.#e)}set prefs(e){s(this.#e,e,!0)}#t=n(!1);get hydrated(){return e(this.#t)}set hydrated(e){s(this.#t,e,!0)}#n=n(!1);get firstRun(){return e(this.#n)}set firstRun(e){s(this.#n,e,!0)}#r=n(!1);get speaking(){return e(this.#r)}set speaking(e){s(this.#r,e,!0)}#i=n(i(Oa));get inference(){return e(this.#i)}set inference(e){s(this.#i,e,!0)}#a=n(i([`browser`]));get availableModes(){return e(this.#a)}set availableModes(e){s(this.#a,e,!0)}#o=n(``);get notice(){return e(this.#o)}set notice(e){s(this.#o,e,!0)}#s=n(null);get byo(){return e(this.#s)}set byo(e){s(this.#s,e,!0)}pending=0;generation=0;options;pendingConfig=!1;builtAtHydrate=!1;synth;mic;constructor(e){this.options=e,this.session=new Fi({...e.session,storage:e.storage,onReply:e=>this.speak(e)}),this.voice=new qi({...e.voice,storage:e.storage}),this.synth=e.synth===void 0?typeof speechSynthesis<`u`?speechSynthesis:null:e.synth,this.mic=e.mic??(typeof navigator<`u`&&!!navigator.mediaDevices)}hydrate(e){this.hydrated||(this.prefs=Qa(this.options.storage),this.hydrated=!0,this.builtAtHydrate=e,this.pendingConfig||this.decideFirstRun(),this.voice.init())}awaitConfig(){this.pendingConfig=!0}configure(e){let{config:t,notice:n}=e;this.pendingConfig=!1,this.inference=t,this.notice=n??``;let r=[t.mode,...t.alternatives??[]];this.availableModes=[...r,...t.alternatives?.length&&!r.includes(`manual`)?[`manual`]:[]],this.byo=r.includes(`byo`)?new fa({storage:this.options.storage,credentialPersistence:t.credentialPersistence,presets:t.byo?.presets,fetch:this.options.fetch,onChange:()=>this.syncByo()}):null,this.applyMode(t.mode),this.hydrated&&this.decideFirstRun()}useChat(e,t){this.pendingConfig=!1,this.inference={mode:`host`},this.notice=``,this.availableModes=[`host`],this.byo=null,this.session.setMode(`host`);let n=()=>typeof e==`function`?e():e;this.session.useRemote({message:(e,t)=>{let r=n();if(!r)throw Error(`The host has not connected a model yet.`);return r.message(e,t)}},t),this.hydrated&&this.decideFirstRun()}get assistantReady(){return this.hydrated&&this.session.status===`ready`}selectInference(e){this.availableModes.includes(e)&&e!==this.inference.mode&&(this.inference={...this.inference,mode:e},this.notice=``,this.applyMode(e))}applyMode(e){if(this.session.setMode(e),e===`host`&&this.inference.host){let{controller:e,store:t,settings:n,theme:r}=this.options.session,i=e??Zn({store:t,settings:n,theme:r});this.session.useRemote(Wa({endpoint:this.inference.host.endpoint,snapshot:()=>i.snapshot(),fetch:this.options.fetch}),`Server`)}else e===`byo`?this.syncByo():e===`manual`&&this.session.useRemote(null,``)}syncByo(){let e=this.byo;e&&this.session.useRemote(e.active?e.chat():null,e.model)}decideFirstRun(){this.firstRun=this.inference.mode!==`host`&&this.inference.mode!==`manual`&&Xa({thinkDownloaded:this.session.prefs.consented.length>0||this.session.status===`ready`,hearDownloaded:Hi(this.options.storage),readAloud:this.prefs.readAloud,dismissed:this.prefs.dismissed,built:this.builtAtHydrate})}get capabilities(){let e=ar(this.session.prefs.modelId),t=this.hydrated;return Ga({think:{status:t?this.session.status:`idle`,model:e?sr(e):`model`,progress:this.session.progress.progress,downloaded:t&&this.session.prefs.consented.length>0,mode:this.session.mode,remote:this.session.remoteLabel},hear:{status:t?this.voice.status:`checking`,mic:!t||this.mic},speak:{supported:!t||this.synth!==null,readAloud:t&&this.prefs.readAloud}})}get privacyNote(){return this.inference.mode===`manual`?`Inference is off. Planning, validation and export still work without a model.`:this.inference.mode===`host`?`Your messages and a short summary of your plan go to this site's server. Voice typing and reading aloud stay on this device.`:this.inference.mode===`byo`?`Your messages and a short summary of your plan go to the model endpoint you choose, and nowhere else. Voice typing and reading aloud stay on this device.`:`Everything runs on this device. Nothing you type or say leaves the page.`}get speakSupported(){return this.synth!==null}continueFirstRun(){this.firstRun=!1}dismissFirstRun(){this.firstRun=!1,this.setPrefs({...this.prefs,dismissed:!0})}setReadAloud(e){(!e||this.synth)&&(e||this.cancelSpeech(),this.setPrefs({...this.prefs,readAloud:e}))}setHandsFree(e){this.setPrefs({...this.prefs,handsFree:e})}setSendOnPause(e){this.setPrefs({...this.prefs,sendOnPause:e})}get sendOnPauseActive(){return this.handsFreeActive&&this.prefs.sendOnPause}get handsFreeActive(){return this.prefs.handsFree&&this.voice.status===`ready`}speak(e){if(!this.prefs.readAloud||!this.synth||!e.trim())return;this.cancelSpeech();let t=e.split(/\n{2,}/).map(e=>e.trim()).filter(Boolean),n=this.generation;this.pending=t.length,this.speaking=!0;let r=()=>{n===this.generation&&(this.pending=Math.max(0,this.pending-1),this.pending===0&&(this.speaking=!1))};for(let e of t){let t=new SpeechSynthesisUtterance(e);t.onend=r,t.onerror=r,this.synth.speak(t)}}cancelSpeech(){this.generation+=1,this.pending=0,this.speaking=!1,this.synth?.cancel()}setPrefs(e){this.prefs=e,$a(this.options.storage,e)}}({storage:v(),session:{store:ne,recipes:D,controller:nr,settings:{read:()=>C.settings(),write:e=>C.setSettings(e)},theme:{read:()=>C.snapshot().theme,write:e=>C.setTheme(e)},menu:()=>tr.openSection?nr.snapshot().sections.filter(e=>!e.hidden).map(({id:e,label:t})=>({id:e,label:t})):[]},voice:{createModel:ze}}),to=`M11 4.2C10.4 3 8.6 2.8 7.6 3.8C6.2 3.6 5 4.8 5.2 6.1C3.8 6.6 3.3 8.2 4.1 9.3C3 10.2 3 11.9 4 12.8C3.6 14.2 4.4 15.6 5.8 15.9C6.2 17.3 7.6 18.2 9 17.9C9.7 19.2 11 19.6 11 19.6ZM13 4.2 C13.6 3 15.4 2.8 16.4 3.8 C17.8 3.6 19 4.8 18.8 6.1 C20.2 6.6 20.7 8.2 19.9 9.3 C21 10.2 21 11.9 20 12.8 C20.4 14.2 19.6 15.6 18.2 15.9 C17.8 17.3 16.4 18.2 15 17.9 C14.3 19.2 13 19.6 13 19.6 ZM10.2 7.4C8.6 7.8 7.5 7 7 6.2L7.7 5.8C8.2 6.5 9 6.8 10 6.5ZM10.3 11C8.4 11.6 6.6 10.8 5.9 9.6L6.6 9.2C7.2 10.2 8.6 10.7 10.1 10.2ZM10.2 15C8.5 15.6 6.8 15 6 13.9L6.7 13.5C7.4 14.3 8.6 14.6 10 14.2ZM13.8 7.4 C15.4 7.8 16.5 7 17 6.2 L16.3 5.8 C15.8 6.5 15 6.8 14 6.5 ZM13.7 11 C15.6 11.6 17.4 10.8 18.1 9.6 L17.4 9.2 C16.8 10.2 15.4 10.7 13.9 10.2 ZM13.8 15 C15.5 15.6 17.2 15 18 13.9 L17.3 13.5 C16.6 14.3 15.4 14.6 14 14.2 Z`,no=`M17 20c-.29 0-.56-.06-.76-.15-.71-.37-1.21-.88-1.71-2.38-.51-1.56-1.47-2.29-2.39-3-.79-.61-1.61-1.24-2.32-2.53C9.29 10.98 9 9.93 9 9c0-2.8 2.2-5 5-5s5 2.2 5 5h2c0-3.93-3.07-7-7-7S7 5.07 7 9c0 1.26.38 2.65 1.07 3.9.91 1.65 1.98 2.48 2.85 3.15.81.62 1.39 1.07 1.71 2.05.6 1.82 1.37 2.84 2.73 3.55.51.23 1.07.35 1.64.35 2.21 0 4-1.79 4-4h-2c0 1.1-.9 2-2 2zM7.64 2.64L6.22 1.22C4.23 3.21 3 5.96 3 9s1.23 5.79 3.22 7.78l1.41-1.41C6.01 13.74 5 11.49 5 9s1.01-4.74 2.64-6.36zM11.5 9c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5-1.12-2.5-2.5-2.5-2.5 1.12-2.5 2.5z`,ro=`M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z`;export{nr as A,ir as C,ur as D,ar as E,Bn as F,Vn as I,Dn as L,er as M,Gn as N,lr as O,Hn as P,Re as R,Rr as S,or as T,Ii as _,Wa as a,Gr as b,Ea as c,ga as d,_a as f,pa as g,ha as h,eo as i,tr as j,sr as k,ma as l,ya as m,ro as n,Ra as o,va as p,to as r,za as s,no as t,ba as u,Ri as v,cr as w,Wr as x,Ni as y,ie as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,Ct as n,Dt as r,E as i,Et as a,F as o,Ft as s,G as c,H as l,K as u,L as d,Lt as f,Ot as p,Pt as m,U as h,W as g,X as _,Y as v,a as y,bt as b,ct as ee,d as x,ft as S,gt as C,ht as w,k as te,mt as T,pt as E,q as ne,st as D,v as O,vt as k}from"./DG3qFFTE.js";import"./xihTtKlq.js";import{a as re}from"./Bv5jGtB8.js";import"./YUSKx8_q.js";import{ft as A,lt as ie,p as j,u as M,ut as N}from"./BG9Gz_25.js";import"./DK8Blf1Y.js";import"./M-CuJzQN.js";import"./Cga8zF3r.js";v([`click`]),v([`click`,`keydown`]),v([`click`]);var P=new Map(Object.entries({menu:`M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z`,search:`M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z`,close:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z`,"chevron-right":`M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z`,"chevron-left":`M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z`,"chevron-down":`M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z`,check:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z`,add:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`,mic:`M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.04 6.43 5 7.07V21h4v-2.93c2.96-.64 5-3.54 5-7.07h-2z`,alert:`M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1 5h2v6h-2zm0 8h2v2h-2z`,warning:`M1 21h22L12 2 1 21zm12-3h-2v-2h2zm0-4h-2v-4h2z`,info:`M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-6h2zm0-8h-2V7h2z`,home:`M3 10 12 2 21 10v11h-6v-7H9v7H3z`,user:`M12 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8zM4 21v-2c0-4 16-4 16 0v2H4z`,settings:`M10 2h4l1 3 3-1 3 3-1 3 3 1v4l-3 1 1 3-3 3-3-1-1 3h-4l-1-3-3 1-3-3 1-3-3-1v-4l3-1-1-3 3-3 3 1 1-3zm2 6a4 4 0 1 0 0 8 4 4 0 0 0 0-8z`,trash:`M7 3h10v2h4v2H3V5h4V3zm-2 6h14v12H5V9zm4 2v8h2v-8H9zm4 0v8h2v-8h-2z`,edit:`M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z`,calendar:`M7 2h2v2h6V2h2v2h4v18H3V4h4V2zm-2 8v10h14V10H5zm2 2h4v4H7v-4z`,clock:`M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16zm-1 2h2v5.5l4 2.5-1 1.5-5-3V6z`,camera:`M9 3h6l2 3h4v15H3V6h4l2-3zm3 5a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm0 2a3 3 0 1 1 0 6 3 3 0 0 1 0-6z`,upload:`M11 16V7l-4 4-1.5-1.5L12 3l6.5 6.5L17 11l-4-4v9h-2zM3 18h18v3H3v-3z`,download:`M11 3h2v9l4-4 1.5 1.5L12 16l-6.5-6.5L7 8l4 4V3zM3 18h18v3H3v-3z`})),F=b([]);function I(t){for(let n=e(F).length-1;n>=0;n--){let r=e(F)[n].paths.get(t);if(r!==void 0)return r}return P.get(t)}var L=u(`<svg xmlns="http://www.w3.org/2000/svg" data-smrt-component="Icon" class="svelte-em2a54"><path></path></svg>`);function R(t,i){p(i,!0);let a=y(i,`size`,3,24),o=y(i,`color`,3,`currentColor`),s=y(i,`viewBox`,3,`0 0 24 24`),c=n(()=>!!i[`aria-label`]),l=n(()=>i.path??(i.name?I(i.name):``)),u=n(()=>typeof a()==`number`?`${a()}px`:a());var d=L(),f=T(d);D(()=>{O(d,`width`,e(u)),O(d,`height`,e(u)),O(d,`viewBox`,s()),O(d,`fill`,o()),O(d,`aria-hidden`,!e(c)),O(d,`aria-label`,i[`aria-label`]),O(d,`role`,e(c)?`img`:void 0),O(f,`d`,e(l))}),h(t,d),r()}v([`click`]);var z=Symbol.for(`smrt-ui.page-header`);function ae(){return a(z)??null}var oe=c(`<li class="svelte-1f2td7n"><a class="svelte-1f2td7n"> </a></li>`),B=c(`<nav class="page-crumbs svelte-1f2td7n" data-shell-breadcrumbs=""><ol class="svelte-1f2td7n"></ol></nav>`),se=c(`<a class="back-link svelte-1f2td7n"><!> <span> </span></a>`),ce=c(`<h1 class="page-title page-title-field svelte-1f2td7n" data-page-title-field=""><!></h1>`),le=c(`<h1 class="page-title svelte-1f2td7n" data-shell-page-title=""> </h1>`),ue=c(`<p class="page-subtitle svelte-1f2td7n"> </p>`),de=c(`<div class="page-meta svelte-1f2td7n"><!></div>`),fe=c(`<div class="header-actions svelte-1f2td7n"><!></div>`),pe=c(`<div class="header-extra svelte-1f2td7n" data-page-header-extra=""><!></div>`),me=c(`<header class="page-header svelte-1f2td7n" data-page-header="" data-smrt-component="PageHeader"><!> <div class="header-main svelte-1f2td7n"><div class="header-content svelte-1f2td7n"><!> <!> <!> <!></div> <!></div> <!></header>`);function he(i,a){p(a,!0);let c=y(a,`parents`,19,()=>[]),u=y(a,`crumbsLabel`,3,`Breadcrumb`),f=y(a,`backLabel`,3,`Back`),m=ae(),g=n(()=>a.crumbs??(m?m.crumbs(c()):c()));ee(()=>m?.report?.({title:a.shortTitle??a.title,parents:c()}));var _=me(),v=S(_),b=t=>{var n=B(),r=S(n);d(r,23,()=>e(g),(e,t)=>`${t}:${e.href}`,(t,n)=>{var r=oe(),i=S(r),a=T(i,!0);s(r),D(()=>{O(i,`href`,e(n).href),l(a,e(n).label)}),h(t,r)}),s(r),s(n),D(()=>O(n,`aria-label`,u())),h(t,n)};t(v,t=>{e(g).length>0&&t(b)});var x=w(v,2),C=S(x),E=S(C),ne=e=>{var t=se(),n=S(t);R(n,{name:`chevron-left`,size:20});var r=w(n,2),i=T(r,!0);s(t),te(t,e=>re?.(e)),D(()=>{O(t,`href`,a.backHref),l(i,f())}),h(e,t)};t(E,e=>{a.backHref&&e(ne)});var k=w(E,2),A=e=>{var t=ce(),n=S(t);o(n,()=>a.titleField),s(t),h(e,t)},ie=e=>{var t=le(),n=T(t,!0);D(()=>l(n,a.title)),h(e,t)};t(k,e=>{a.titleField?e(A):e(ie,-1)});var j=w(k,2),M=e=>{var t=ue(),n=T(t,!0);D(()=>l(n,a.subtitle)),h(e,t)};t(j,e=>{a.subtitle&&e(M)});var N=w(j,2),P=e=>{var t=de(),n=S(t);o(n,()=>a.meta),s(t),h(e,t)};t(N,e=>{a.meta&&e(P)}),s(C);var F=w(C,2),I=e=>{var t=fe(),n=S(t);o(n,()=>a.actions),s(t),h(e,t)};t(F,e=>{a.actions&&e(I)}),s(x);var L=w(x,2),z=e=>{var t=pe(),n=S(t);o(n,()=>a.children),s(t),h(e,t)};t(L,e=>{a.children&&e(z)}),s(_),h(i,_),r()}v([`click`]),v([`click`]);function ge(e,t,n){if(!n||n<1||e.length<=n)return{visible:[...e],overflow:[]};let r=e.slice(0,n-1),i=e.slice(n-1),a=i.find(e=>e.id===t)??i[0];return{visible:a?[...r,a]:r,overflow:i.filter(e=>e!==a)}}var _e=c(`<span class="smrt-tabs__tab-count svelte-19k21oo" data-smrt-part="count"> </span>`),ve=c(`<span class="smrt-tabs__tab-badge svelte-19k21oo" data-smrt-part="badge"> </span>`),ye=c(`<a data-smrt-part="tab"><span data-smrt-part="label"> </span> <!> <!></a>`),be=c(`<span class="smrt-tabs__tab-dot svelte-19k21oo" data-smrt-part="marker" aria-hidden="true"></span> <span class="smrt-tabs__visually-hidden svelte-19k21oo" data-smrt-part="description"> </span>`,1),xe=c(`<details class="smrt-tabs__more svelte-19k21oo" data-smrt-part="overflow"><summary class="smrt-tabs__tab-link svelte-19k21oo" data-smrt-part="trigger"><span data-smrt-part="label"> </span> <!></summary> <div class="smrt-tabs__more-menu svelte-19k21oo" data-smrt-part="menu"></div></details>`),Se=c(`<div class="smrt-tabs__tab-panel svelte-19k21oo" data-smrt-part="panel"><!></div>`),Ce=c(`<div class="smrt-tabs__container svelte-19k21oo" data-smrt-component="Tabs"><nav data-smrt-part="list" data-shell-tabs=""><div class="smrt-tabs__links-row svelte-19k21oo" data-smrt-part="row"></div> <!></nav> <!></div>`),we=c(`<button type="button" data-smrt-part="tab" role="tab"><span class="smrt-tabs__tab-content-wrapper svelte-19k21oo" data-smrt-part="body"><span data-smrt-part="label"> </span> <!> <!></span> <div class="smrt-tabs__active-indicator svelte-19k21oo" data-smrt-part="indicator"></div></button>`),Te=c(`<div class="smrt-tabs__tab-panel svelte-19k21oo" data-smrt-part="panel" role="tabpanel"><!></div>`),Ee=c(`<div class="smrt-tabs__container svelte-19k21oo" data-smrt-component="Tabs"><div data-smrt-part="list" role="tablist"></div> <!></div>`);function De(a,c){let u=ne();p(c,!0);let v=(r,a=f)=>{var o=ye();let u;var d=S(o),p=T(d,!0),m=w(d,2),g=e=>{var t=_e(),n=T(t,!0);D(()=>l(n,a().count)),h(e,t)};t(m,e=>{a().count!==void 0&&e(g)});var v=w(m,2),y=e=>{var t=ve(),n=T(t,!0);D(()=>l(n,a().badge)),h(e,t)},b=n(()=>L(a()));t(v,t=>{e(b)&&t(y)}),s(o),D(()=>{u=i(o,1,`smrt-tabs__tab-link svelte-19k21oo`,null,u,{"smrt-tabs__active":a().id===c.active}),O(o,`href`,a().disabled?void 0:a().href),O(o,`aria-current`,a().id===c.active?`page`:void 0),O(o,`aria-disabled`,a().disabled?`true`:void 0),O(o,`data-tab-id`,a().id),l(p,a().label)}),_(`click`,o,e=>{a().disabled?e.preventDefault():ae(a().id)}),h(r,o)},C=y(c,`size`,3,`md`),A=y(c,`variant`,3,`primary`),ie=y(c,`moreLabel`,3,`More`),j=y(c,`moreBadgeLabel`,3,`has updates`),M=n(()=>c.tabs.length>0&&c.tabs.every(e=>!!e.href)),N=n(()=>e(M)?ge(c.tabs,c.active,c.maxVisible):{visible:c.tabs,overflow:[]}),P=n(()=>e(N).overflow.some(e=>L(e))),F=b(null),I=b(null);ee(()=>{let t=c.active;e(M)&&e(I)&&(e(F)&&(e(F).open=!1),e(I).querySelector(`[data-tab-id="${CSS.escape(t)}"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`}))});function L(e){return e.badge!==void 0&&e.badge!==null&&e.badge!==``}let R=n(()=>c.tabs.filter(e=>!e.disabled)),z=b(null);function ae(e){c.tabs.find(t=>t.id===e)?.disabled||e!==c.active&&c.onchange?.(e)}function oe(t,n){let r=e(R).findIndex(e=>e.id===n),i=null;switch(t.key){case`ArrowRight`:t.preventDefault(),i=(r+1)%e(R).length;break;case`ArrowLeft`:t.preventDefault(),i=(r-1+e(R).length)%e(R).length;break;case`Home`:t.preventDefault(),i=0;break;case`End`:t.preventDefault(),i=e(R).length-1}if(i!==null&&i!==r){let t=e(R)[i];t&&(c.onchange?.(t.id),requestAnimationFrame(()=>{(e(z)?.querySelector(`[data-tab-id="${CSS.escape(t.id)}"]`))?.focus()}))}}var B=g(),se=E(B),ce=n=>{var r=Ce(),a=S(r);let u;var f=S(a);d(f,21,()=>e(N).visible,e=>e.id,(t,n)=>{v(t,()=>e(n))}),s(f),x(f,e=>k(I,e),()=>e(I));var p=w(f,2),m=n=>{var r=xe(),i=S(r),a=S(i),o=T(a,!0),c=w(a,2),u=e=>{var t=be(),n=w(E(t),2),r=T(n);D(()=>l(r,`(${j()??``})`)),h(e,t)};t(c,t=>{e(P)&&t(u)}),s(i);var f=w(i,2);d(f,21,()=>e(N).overflow,e=>e.id,(t,n)=>{v(t,()=>e(n))}),s(f),s(r),x(r,e=>k(F,e),()=>e(F)),D(()=>l(o,ie())),h(n,r)};t(p,t=>{e(N).overflow.length>0&&t(m)}),s(a);var g=w(a,2),_=e=>{var t=Se(),n=S(t);o(n,()=>c.children),s(t),h(e,t)};t(g,e=>{c.children&&e(_)}),s(r),D(()=>{u=i(a,1,`smrt-tabs__links svelte-19k21oo`,null,u,{"smrt-tabs__sm":C()===`sm`,"smrt-tabs__lg":C()===`lg`}),O(a,`aria-label`,c[`aria-label`])}),h(n,r)},le=r=>{var a=Ee(),f=S(a);let p;d(f,21,()=>c.tabs,e=>e.id,(r,a)=>{var o=we();let d;var f=S(o),p=S(f),g=T(p,!0),v=w(p,2),y=t=>{var n=_e(),r=T(n,!0);D(()=>l(r,e(a).count)),h(t,n)};t(v,t=>{e(a).count!==void 0&&t(y)});var b=w(v,2),ee=t=>{var n=ve(),r=T(n,!0);D(()=>l(r,e(a).badge)),h(t,n)},x=n(()=>L(e(a)));t(b,t=>{e(x)&&t(ee)}),s(f),m(2),s(o),te(o,e=>re?.(e)),D(()=>{d=i(o,1,`smrt-tabs__tab-button svelte-19k21oo`,null,d,{"smrt-tabs__active":e(a).id===c.active}),o.disabled=e(a).disabled,O(o,`id`,`tab-${u}-${e(a).id??``}`),O(o,`aria-selected`,e(a).id===c.active),O(o,`aria-controls`,`tab-panel-${u}`),O(o,`tabindex`,e(a).id===c.active?0:-1),O(o,`data-tab-id`,e(a).id),l(g,e(a).label)}),_(`click`,o,()=>ae(e(a).id)),_(`keydown`,o,t=>oe(t,e(a).id)),h(r,o)}),s(f),x(f,e=>k(z,e),()=>e(z));var g=w(f,2),v=e=>{var t=Te(),n=S(t);o(n,()=>c.children),s(t),D(()=>{O(t,`id`,`tab-panel-${u}`),O(t,`aria-labelledby`,`tab-${u}-${c.active??``}`)}),h(e,t)};t(g,e=>{c.children&&e(v)}),s(a),D(()=>{p=i(f,1,`smrt-tabs__nav svelte-19k21oo`,null,p,{"smrt-tabs__sm":C()===`sm`,"smrt-tabs__lg":C()===`lg`,"smrt-tabs__secondary":A()===`secondary`}),O(f,`aria-label`,c[`aria-label`])}),h(r,a)};t(se,t=>{e(M)?t(ce):t(le,-1)}),h(a,B),r()}v([`click`,`keydown`]),v([`click`,`keydown`]);function Oe(){let e=new Map,t=new Map,n=(e,t)=>`${e}:${t}`;return{register(t,r,i){e.set(n(t,r),i)},get(t,r){return e.get(n(t,r))},has(t,r){return e.has(n(t,r))},getSlots(t){let n=`${t}:`;return Array.from(e.keys()).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))},getModules(){return Array.from(t.keys())},getModuleMeta(e){return t.get(e)},registerModule(e){t.set(e.name,e)},unregister(t,r){return e.delete(n(t,r))},clear(){e.clear(),t.clear()}}}var ke=Oe(),Ae=[`SmrtJunction`,`SmrtJunctionBase`,`SmrtPolymorphicAssociation`],je=[`Metafield`,`Metadata`,`Association`,`LineItem`,`Allocation`,`Revision`,`Attachment`,`Snapshot`,`Completion`,`Override`,`Alias`],Me=[`Status`,`Type`],Ne={"@happyvertical/smrt-commerce:TaxComponent":`lookup`,"@happyvertical/smrt-commerce:TaxSettings":`settings`,"@happyvertical/smrt-commerce:DocumentTax":`snapshot`,"@happyvertical/smrt-commerce:TaxSummaryReport":`report`},V=new Set([`foreignKey`,`crossPackageRef`]);function Pe(e){let t=e.id?Ne[e.id]:void 0;if(t)return t;let n=e.extends?.split(`:`).pop();if(n&&Ae.includes(n))return`junction`;let r=e.fields.filter(e=>!e.system),i=r.filter(e=>V.has(e.type)).length;return i>=2&&r.length-i<=1?`link`:je.some(t=>e.name.endsWith(t))?`child`:r.length<=3&&Me.some(t=>e.name.endsWith(t))?`lookup`:null}function Fe(e){return Pe(e)!==null}var Ie=new Set([`junction`,`link`,`child`]);function H(e,t){return e.includes(`:`)?e:`${t.slice(0,t.lastIndexOf(`:`))}:${e}`}function U(e,t){let n=[],r=e.get(t);for(;r&&!n.includes(r.id);)n.push(r.id),r=r.extends?e.get(H(r.extends,r.id)):void 0;return n}function Le(e,t){let n=e.packages.flatMap(e=>e.models),r=new Map(n.map(e=>[e.id,e])),i=new Set(U(r,t));return i.size?n.filter(e=>{if(i.has(e.id))return!1;let t=Pe(e);return!t||!Ie.has(t)?!1:e.fields.some(t=>V.has(t.type)&&t.related&&i.has(H(t.related,e.id)))}):[]}function Re(e,t){let n=e.fields.find(n=>V.has(n.type)&&n.related&&t.has(H(n.related,e.id)));return n?{model:e,fk:n.name}:void 0}function ze(e,t,n){let r=e.packages.flatMap(e=>e.models),i=new Map(r.map(e=>[e.id,e])),a=new Set(U(i,n));if(!a.size)return[];let o=t.filter(e=>e.models.includes(n));if(!o.length)return Le(e,n).flatMap(e=>{let t=Re(e,a);return t?[t]:[]});let s=new Map;for(let e of o){let t=new Set(e.nav.map(e=>e.model));for(let n of e.models){let e=i.get(n);if(!e||t.has(n)||a.has(n)||s.has(n))continue;let r=Re(e,a);r&&s.set(n,r)}}return[...s.values()]}function Be(e,t){let n=e.packages.flatMap(e=>e.models),r=new Map(n.map(e=>[e.id,e])),i=new Set(U(r,t));if(!i.size)return[];let a=[];for(let e of n)if(!i.has(e.id))for(let t of e.fields)V.has(t.type)&&t.related&&i.has(H(t.related,e.id))&&a.push({model:e,fk:t.name});return a}function Ve(e,t){let n=e.packages.flatMap(e=>e.models),r=new Map(n.map(e=>[e.id,e])),i=r.get(t);return i?i.fields.flatMap(e=>{if(!V.has(e.type)||!e.related)return[];let t=r.get(H(e.related,i.id));return t?[{model:t,fk:e.name}]:[]}):[]}function He(e,t){return e.some(e=>e.nav.some(e=>e.model===t))}function Ue(e,t){let n=e;for(let e of t)if(n.length>e.length&&n.startsWith(e)){n=n.slice(e.length);break}let r=n.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).toLowerCase(),i=/[^aeiou]y$/.test(r)?`${r.slice(0,-1)}ies`:/(s|x|ch|sh)$/.test(r)?`${r}es`:`${r}s`;return i.charAt(0).toUpperCase()+i.slice(1)}function We(e,t){let n=e.packages.flatMap(e=>e.models),r=new Map(n.map(e=>[e.id,e]));return U(r,t).flatMap(e=>{let t=r.get(e);return t?[t.name]:[]})}function Ge(e,t,n){let r=We(e,t);return Le(e,t).filter(e=>n(e)&&r.some(t=>e.name.startsWith(t)))}function W(e){return e.group?.id??e.id}function Ke(e){let t=new Map;for(let n of e){let e=W(n),r=t.get(e);r?r.recipes.push(n):t.set(e,{id:e,label:n.group?.label??n.label,recipes:[n]})}return[...t.values()]}function G(e){return e.section??{id:W(e),label:e.group?.label??e.label}}function qe(e){let t=new Map;for(let n of e){let e=G(n),r=t.get(e.id);r?r.recipes.push(n):t.set(e.id,{...e,recipes:[n]})}return[...t.values()]}function Je(e){let t=new Set(e.map(e=>G(e).id)),n={};for(let r of e){let e=W(r),i=G(r).id;e!==i&&!t.has(e)&&(n[e]=i)}return n}function Ye(e,t,n){return`item:${e}:${t}${n?`:${n}`:``}`}function Xe(e,t){return e?.trim()||t.description?.trim()||`Your ${Ze(t.name)} records, all in one place.`}function Ze(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).toLowerCase()}var Qe={id:`more`,label:`More`,icon:`layers`,description:`Extra records you added one at a time.`},$e=`fileText`;function et(e){let t=e.description?.trim();if(t)return t.split(/(?<=[.!?])\s/)[0]??t;let n=e.fields.filter(e=>!e.system).length;return`${n} ${n===1?`field`:`fields`}`}function tt(e,t){let n=new Set(t.flatMap(e=>e.models));return e.packages.flatMap(t=>N(t).filter(e=>!n.has(e.id)).map(n=>({id:n.id,name:n.name,label:j(n.name),packageId:t.id,description:et(n),described:!!n.description?.trim(),plumbing:Fe(n),fieldNames:n.fields.map(e=>e.name),includes:Le(e,n.id).map(e=>j(e.name))})))}function nt(e){return e.described?e.description:`${j(e.packageId)} · ${e.description}`}function rt(e,t){return t?[...e]:e.filter(e=>!e.plumbing)}function it(e){return[...new Set(e.map(e=>e.packageId))]}function at(e,t,n){let r=t.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if(n&&e.packageId!==n)return!1;if(!r.length)return!0;let t=[e.name,e.label,e.description,e.packageId,...e.fieldNames].join(` `).toLowerCase();return r.every(e=>t.includes(e))})}function ot(e){return e.flatMap(e=>{let t=A(e);return t?.model.exposed?[{id:Ye(t.pkg.id,t.model.name),packageId:t.pkg.id,modelName:t.model.name,label:j(t.model.name),icon:$e,description:Xe(void 0,t.model)}]:[]})}var st={"@happyvertical/smrt-commerce:Customer":{profileId:`Links this customer to their profile record, where their name and contact details are kept.`,creditLimit:`The most this customer may owe you at one time. Leave it empty or at zero if you do not set limits.`,paymentTerms:`How long the customer has to pay, written the way you would say it, for example "Net 30".`,taxExempt:`Turn this on if you do not charge this customer sales tax.`,taxId:`The customer's tax or VAT number, kept on file for tax-exempt sales.`,defaultShippingAddress:`Where you usually send this customer's goods, so you do not retype it on every order.`,defaultBillingAddress:`Where you send this customer's invoices.`,status:`Whether this is a current customer, for example active or inactive.`,customerType:`The kind of customer, for example an individual or a business.`,notes:`Anything worth remembering about this customer.`},"@happyvertical/smrt-commerce:Vendor":{profileId:`Links this vendor to their profile record, where their name and contact details are kept.`,leadTimeDays:`How many days the vendor usually takes between your order and delivery.`,minimumOrderAmount:`The smallest order the vendor will accept.`,paymentTerms:`How long you have to pay this vendor, written the way you would say it, for example "Net 30".`,currency:`The currency this vendor bills you in.`,defaultContactEmail:`The email address you normally use to reach this vendor.`,defaultContactPhone:`The phone number you normally use to reach this vendor.`,status:`Whether you still buy from this vendor, for example active or inactive.`,notes:`Anything worth remembering about this vendor.`,payoutAddresses:`Where payments to this vendor should be sent.`},"@happyvertical/smrt-commerce:Order":{status:`Where the order stands, for example draft, accepted or completed.`,customerId:`The customer this order is for.`,subtotal:`The order amount before tax.`,taxAmount:`The tax charged on the order.`,totalAmount:`What the customer pays in all, tax included.`,currency:`The currency of the order's amounts.`,issueDate:`The date the order was placed.`,dueDate:`The date payment is expected. An order still open after this date counts as overdue.`,expiryDate:`The last day the order's price or offer is good for.`,reference:`Your own number or note for finding this order later, such as the customer's purchase order number.`,notes:`Anything worth remembering about this order.`,terms:`The conditions agreed with the customer, such as deposits, delivery or payment conditions.`,channelId:`Where the order came from, for example your shop or a marketplace.`},"@happyvertical/smrt-commerce:PurchaseOrder":{status:`Where the purchase stands, for example draft, accepted or completed.`,vendorId:`The vendor you are buying from.`,subtotal:`The order amount before tax.`,taxAmount:`The tax charged on the order.`,totalAmount:`What you pay in all, tax included.`,currency:`The currency of the order's amounts.`,issueDate:`The date you placed the order.`,dueDate:`The date the goods or the payment are due.`,expiryDate:`The last day the vendor's offer is good for.`,reference:`Your own number or note for finding this order later, such as the vendor's quote number.`,notes:`Anything worth remembering about this purchase.`,terms:`The conditions agreed with the vendor, such as payment or delivery conditions.`,channelId:`Where the order was placed, for example a vendor's website or a phone call.`},"@happyvertical/smrt-products:Product":{name:`What you call the product, as customers will see it.`,price:`What one costs, in dollars and cents.`,description:`A few words on what the product is and who it is for.`},"@happyvertical/smrt-products:ProductVariant":{productId:`The product this choice belongs to. Set for you when you save the product.`,axisName:`What the product varies by, for example size or color.`,allowedValues:`The values on offer for it, for example S, M and L.`},"@happyvertical/smrt-products:Sku":{productId:`The product this item is a version of. Set for you when you save the product.`,code:`The short code that identifies this exact size and color. Made for you from the product name.`,attributes:`Which size and color this item is. Set for you from the grid.`},"@happyvertical/smrt-inventory:StockLevel":{skuId:`The item being counted. Set for you when you save the product.`,locationId:`Where it is kept. New stock goes to the main warehouse.`,state:`Whether the count is available to sell. New stock starts as available.`,qty:`How many you have on hand.`},"@happyvertical/smrt-inventory:InventoryLocation":{code:`A short code for the place stock is kept, for example MAIN.`,name:`What you call the place, for example Main warehouse.`,kind:`What sort of place it is, for example a warehouse or a shop floor.`},"@happyvertical/smrt-commerce:Estimate":{status:`Where the estimate stands, for example draft, sent, accepted or completed.`,customerId:`The customer this estimate is for.`,subtotal:`The estimate amount before tax.`,taxAmount:`The tax charged on the estimate.`,totalAmount:`What the customer pays in all, tax included.`,currency:`The currency of the estimate's amounts.`,issueDate:`The date the estimate was issued or starts.`,dueDate:`The date payment is expected.`,expiryDate:`The last day the estimate is good for, or the day it ends.`,reference:`Your own number or note for finding this estimate later.`,notes:`Anything worth remembering about this estimate.`,terms:`The conditions agreed with the customer, such as deposits, delivery or payment conditions.`,channelId:`Where the estimate came from, for example your shop or a marketplace.`},"@happyvertical/smrt-commerce:WholesaleOrder":{status:`Where the wholesale order stands, for example draft, sent, accepted or completed.`,customerId:`The customer this wholesale order is for.`,subtotal:`The wholesale order amount before tax.`,taxAmount:`The tax charged on the wholesale order.`,totalAmount:`What the customer pays in all, tax included.`,currency:`The currency of the wholesale order's amounts.`,issueDate:`The date the wholesale order was issued or starts.`,dueDate:`The date payment is expected.`,expiryDate:`The last day the wholesale order is good for, or the day it ends.`,reference:`Your own number or note for finding this wholesale order later.`,notes:`Anything worth remembering about this wholesale order.`,terms:`The conditions agreed with the customer, such as deposits, delivery or payment conditions.`,channelId:`Where the wholesale order came from, for example your shop or a marketplace.`},"@happyvertical/smrt-commerce:Agreement":{status:`Where the agreement stands, for example draft, sent, accepted or completed.`,customerId:`The customer this agreement is for.`,subtotal:`The agreement amount before tax.`,taxAmount:`The tax charged on the agreement.`,totalAmount:`What the customer pays in all, tax included.`,currency:`The currency of the agreement's amounts.`,issueDate:`The date the agreement was issued or starts.`,dueDate:`The date payment is expected.`,expiryDate:`The last day the agreement is good for, or the day it ends.`,reference:`Your own number or note for finding this agreement later.`,notes:`Anything worth remembering about this agreement.`,terms:`The conditions agreed with the customer, such as deposits, delivery or payment conditions.`,channelId:`Where the agreement came from, for example your shop or a marketplace.`},"@happyvertical/smrt-commerce:Lease":{status:`Where the lease stands, for example draft, sent, accepted or completed.`,customerId:`The customer this lease is for.`,subtotal:`The lease amount before tax.`,taxAmount:`The tax charged on the lease.`,totalAmount:`What the customer pays in all, tax included.`,currency:`The currency of the lease's amounts.`,issueDate:`The date the lease was issued or starts.`,dueDate:`The date payment is expected.`,expiryDate:`The last day the lease is good for, or the day it ends.`,reference:`Your own number or note for finding this lease later.`,notes:`Anything worth remembering about this lease.`,terms:`The conditions agreed with the customer, such as deposits, delivery or payment conditions.`,channelId:`Where the lease came from, for example your shop or a marketplace.`},"@happyvertical/smrt-commerce:LicenseSale":{status:`Where the licence sale stands, for example draft, sent, accepted or completed.`,customerId:`The customer this licence sale is for.`,subtotal:`The licence sale amount before tax.`,taxAmount:`The tax charged on the licence sale.`,totalAmount:`What the customer pays in all, tax included.`,currency:`The currency of the licence sale's amounts.`,issueDate:`The date the licence sale was issued or starts.`,dueDate:`The date payment is expected.`,expiryDate:`The last day the licence sale is good for, or the day it ends.`,reference:`Your own number or note for finding this licence sale later.`,notes:`Anything worth remembering about this licence sale.`,terms:`The conditions agreed with the customer, such as deposits, delivery or payment conditions.`,channelId:`Where the licence sale came from, for example your shop or a marketplace.`},"@happyvertical/smrt-commerce:Contract":{status:`Where the contract stands, for example draft, sent, accepted or completed.`,subtotal:`The contract amount before tax.`,taxAmount:`The tax charged on the contract.`,totalAmount:`What the customer pays in all, tax included.`,currency:`The currency of the contract's amounts.`,issueDate:`The date the contract was issued or starts.`,dueDate:`The date payment is expected.`,expiryDate:`The last day the contract is good for, or the day it ends.`,reference:`Your own number or note for finding this contract later.`,notes:`Anything worth remembering about this contract.`,terms:`The conditions agreed with the customer, such as deposits, delivery or payment conditions.`,channelId:`Where the contract came from, for example your shop or a marketplace.`,contractType:`The kind of contract: order, estimate, lease, agreement and so on.`},"@happyvertical/smrt-commerce:ContractLineItem":{contractId:`The order, quote or agreement this line belongs to.`,description:`What is being sold or bought on this line.`,quantity:`How many.`,unitPrice:`The price of one, before tax.`,taxRate:`The tax rate for this line, as a percentage (5 means 5%).`,amount:`The line total.`,productId:`The product this line is for, if it is one you list.`},"@happyvertical/smrt-inventory:StockMovement":{skuId:`The item that moved.`,locationId:`The place it moved at.`,fromState:`What it was before, for example available or damaged.`,toState:`What it became.`,qty:`How many moved.`,reasonCode:`Why it moved, for example adjustment, sale or return.`,note:`Anything worth remembering about this movement.`,occurredAt:`When it happened.`},"@happyvertical/smrt-commerce:Invoice":{customerId:`The customer being billed.`,contractId:`The order or agreement this invoice bills for, if any.`,invoiceNumber:`The number printed on the invoice.`,issueDate:`The date the invoice was issued.`,dueDate:`The date payment is expected.`,paidDate:`The date it was paid in full.`,subtotal:`The amount before tax.`,taxAmount:`The tax charged.`,totalAmount:`What the customer owes in all, tax included.`,amountPaid:`How much of the total has been paid so far.`,currency:`The currency of the invoice.`,status:`Where the invoice stands: draft, sent, viewed, paid, overdue or cancelled.`,notes:`Private notes, not shown to the customer.`,customerNotes:`A message shown to the customer on the invoice.`,terms:`The payment conditions, such as Net 30.`},"@happyvertical/smrt-commerce:InvoiceLineItem":{invoiceId:`The invoice this line belongs to.`,description:`What is being billed on this line.`,quantity:`How many.`,unitPrice:`The price of one, before tax.`,taxRate:`The tax rate for this line, as a percentage (5 means 5%).`,amount:`The line total.`},"@happyvertical/smrt-commerce:Payment":{contractId:`The order or agreement this payment is for, if any.`,customerId:`The customer who paid.`,amount:`How much was paid.`,currency:`The currency of the payment.`,method:`How it was paid: cash, check, card, bank transfer or other.`,status:`Whether the payment is pending, completed, failed or refunded.`,reference:`Your own note, such as a check number.`,paidAt:`When the money was received.`,notes:`Anything worth remembering about this payment.`},"@happyvertical/smrt-commerce:PaymentAllocation":{paymentId:`The payment being applied.`,invoiceId:`The invoice it settles.`,amount:`How much of the payment goes to this invoice.`,allocatedAt:`When it was applied.`,notes:`Anything worth remembering about this allocation.`},"@happyvertical/smrt-commerce:Fulfillment":{contractId:`The order being fulfilled.`,fulfillmentType:`How it gets to the customer: shipment, delivery, pickup, digital or service.`,status:`Where it stands: pending, processing, shipped, delivered or cancelled.`,trackingNumber:`The carrier's tracking number.`,carrier:`The company carrying it.`,shippedAt:`When it left you.`,deliveredAt:`When it arrived.`,notes:`Anything worth remembering about this shipment.`},"@happyvertical/smrt-commerce:FulfillmentLineItem":{fulfillmentId:`The shipment this line belongs to.`,contractLineItemId:`The order line being sent.`,quantityFulfilled:`How many of that line are in this shipment.`},"@happyvertical/smrt-ledgers:Account":{number:`The account number in your chart of accounts.`,name:`What the account is called.`,description:`What the account is used for.`,type:`asset, liability, equity, revenue or expense.`,active:`Turn this off to stop using the account without deleting it.`},"@happyvertical/smrt-ledgers:Journal":{number:`The journal's reference number.`,date:`The date of the transaction.`,description:`What the transaction was.`,status:`draft while you work on it, posted once final, or voided.`,postedAt:`When it was posted.`},"@happyvertical/smrt-ledgers:JournalEntry":{journalId:`The journal this entry belongs to.`,accountId:`The account this entry changes.`,debit:`The amount debited. Leave zero on a credit.`,credit:`The amount credited. Leave zero on a debit.`,currency:`The currency of the amounts.`,memo:`A note on this entry.`},"@happyvertical/smrt-projects:Project":{title:`The project's name.`,description:`What the project is about.`,owner:`Who owns or runs the project.`,url:`A link to the project elsewhere.`},"@happyvertical/smrt-projects:Issue":{projectId:`The project this issue belongs to.`,title:`A short summary of the issue.`,body:`The full description.`,state:`open or closed.`,author:`Who raised the issue.`,labels:`The labels attached to the issue.`,assignees:`The people working on it.`},"@happyvertical/smrt-projects:Label":{projectId:`The project this label belongs to.`,name:`The label's name, for example bug.`,color:`The label's colour.`,description:`What the label means.`},"@happyvertical/smrt-projects:Comment":{issueId:`The issue this comment is on.`,body:`The comment text.`,author:`Who wrote it.`},"@happyvertical/smrt-events:Event":{name:`What the event is called.`,seriesId:`The series this event is part of, if any.`,typeId:`The kind of event.`,placeId:`Where it takes place.`,description:`What the event is about.`,startDate:`When it starts.`,endDate:`When it ends.`,allDay:`Turn this on for an event that lasts all day.`,status:`scheduled, in progress, completed, cancelled or postponed.`},"@happyvertical/smrt-events:EventType":{name:`What this kind of event is called, for example workshop.`,description:`What this kind of event is for.`},"@happyvertical/smrt-events:EventSeries":{name:`What the series is called.`,typeId:`The kind of event in this series.`,organizerId:`Who runs the series.`,description:`What the series is about.`,startDate:`When the series begins.`,endDate:`When the series ends.`,recurrence:`How often it repeats.`},"@happyvertical/smrt-events:EventParticipant":{eventId:`The event the person takes part in.`,profileId:`The person taking part.`,role:`What they do there, for example speaker or attendee.`},"@happyvertical/smrt-sales:Lead":{name:`What you call this lead.`,contactName:`The person to talk to.`,email:`Their email address.`,phone:`Their phone number.`,organizationName:`The company they are with.`,ownerRepId:`The sales representative who owns this lead.`,status:`Where the lead stands, for example new or qualified.`},"@happyvertical/smrt-sales:Opportunity":{name:`What you call this deal.`,leadId:`The lead it came from.`,ownerRepId:`The sales representative who owns this deal.`,pipelineId:`The pipeline it moves through.`,stageId:`The stage it is at now.`,expectedValueCents:`What you expect the deal to be worth, in cents.`,currency:`The currency of that value.`,probability:`How likely it is to close, as a decimal (0.5 is 50%).`,expectedCloseAt:`When you expect it to close.`,status:`open, won or lost.`},"@happyvertical/smrt-sales:PipelineDefinition":{key:`A short code for the pipeline.`,name:`What the pipeline is called.`,isDefault:`Turn this on to use it for new deals.`,status:`Whether the pipeline is in use.`,metadata:`Extra details kept with the pipeline.`},"@happyvertical/smrt-sales:PipelineStage":{pipelineId:`The pipeline this stage belongs to.`,key:`A short code for the stage.`,name:`What the stage is called.`,sortOrder:`Where it comes in the pipeline.`,probability:`How likely a deal at this stage is to close, as a decimal.`,isWon:`Turn this on for the stage that means the deal is won.`,isLost:`Turn this on for the stage that means the deal is lost.`},"@happyvertical/smrt-sales:SalesActivity":{subjectKind:`What the activity is about: a lead or an opportunity.`,subjectId:`The lead or opportunity it is about.`,activityKind:`The kind of activity, for example call, note or email.`,summary:`What happened or what needs doing.`,dueAt:`When it is due.`,completedAt:`When it was done.`}};function ct(e,t){let n=new Map(e.map(e=>[e.id,e])),r=[...Object.keys(t.recipes),...t.order].filter(e=>!n.has(e));if(r.length>0)throw Error(`Recipes only declared locally, not in a smrt package: ${[...new Set(r)].join(`, `)}`);let i=[...t.order,...e.map(e=>e.id).filter(e=>!t.order.includes(e))];return[...new Set(i)].map(e=>{let r=n.get(e),i=t.recipes[e];return i?{...r,...i}:r})}var lt={order:[`commerce.customers`,`commerce.purchases`,`commerce.sales`,`commerce.vendors`,`inventory.stock`,`products.simple`,`products.clothing`,`products.ingredients`,`commerce.estimates`,`commerce.wholesale`,`commerce.invoicing`,`commerce.fulfillment`,`commerce.agreements`,`commerce.leases`,`commerce.licenses`,`ledgers.bookkeeping`,`projects.tracker`,`events.calendar`,`sales.pipeline`],recipes:{"commerce.customers":{forms:[{id:`customer.default`,kind:`field-map`,label:`Customer`,kindLabel:`Customer`,model:`@happyvertical/smrt-commerce:Customer`,records:[{as:`profileType`,model:`@happyvertical/smrt-profiles:ProfileType`,match:{name:`Customer`}},{as:`profile`,model:`@happyvertical/smrt-profiles:Profile`,match:{id:{ref:`customer`,field:`profileId`}},values:{typeId:{ref:`profileType`}}},{as:`customer`,model:`@happyvertical/smrt-commerce:Customer`,values:{profileId:{ref:`profile`}}}],fields:[{id:`name`,label:`Name`,to:`profile.name`,required:!0},{id:`email`,label:`Email`,to:`profile.email`},{id:`status`,label:`Status`,to:`customer.status`,default:`active`},{id:`customerType`,label:`Customer type`,to:`customer.customerType`,default:`dtc`},{id:`paymentTerms`,label:`Payment terms`,to:`customer.paymentTerms`},{id:`creditLimit`,label:`Credit limit`,to:`customer.creditLimit`},{id:`taxExempt`,label:`Tax exempt`,to:`customer.taxExempt`},{id:`taxId`,label:`Tax ID`,to:`customer.taxId`},{id:`shippingAddress`,label:`Shipping address`,to:`customer.defaultShippingAddress`},{id:`billingAddress`,label:`Billing address`,to:`customer.defaultBillingAddress`},{id:`notes`,label:`Notes`,to:`customer.notes`}]}]},"commerce.vendors":{forms:[{id:`vendor.default`,kind:`field-map`,label:`Vendor`,kindLabel:`Vendor`,model:`@happyvertical/smrt-commerce:Vendor`,records:[{as:`profileType`,model:`@happyvertical/smrt-profiles:ProfileType`,match:{name:`Vendor`}},{as:`profile`,model:`@happyvertical/smrt-profiles:Profile`,match:{id:{ref:`vendor`,field:`profileId`}},values:{typeId:{ref:`profileType`}}},{as:`vendor`,model:`@happyvertical/smrt-commerce:Vendor`,values:{profileId:{ref:`profile`}}}],fields:[{id:`name`,label:`Name`,to:`profile.name`,required:!0},{id:`email`,label:`Email`,to:`profile.email`},{id:`status`,label:`Status`,to:`vendor.status`,default:`active`},{id:`currency`,label:`Currency`,to:`vendor.currency`,default:`USD`},{id:`paymentTerms`,label:`Payment terms`,to:`vendor.paymentTerms`},{id:`leadTimeDays`,label:`Lead time (days)`,to:`vendor.leadTimeDays`},{id:`minimumOrderAmount`,label:`Minimum order`,to:`vendor.minimumOrderAmount`},{id:`contactEmail`,label:`Contact email`,to:`vendor.defaultContactEmail`},{id:`contactPhone`,label:`Contact phone`,to:`vendor.defaultContactPhone`},{id:`notes`,label:`Notes`,to:`vendor.notes`},{id:`payoutAddresses`,label:`Payout addresses`,to:`vendor.payoutAddresses`}]}]},"inventory.stock":{extends:[{form:`product.simple`,records:[{as:`sku`,model:`@happyvertical/smrt-products:Sku`,match:{productId:{ref:`product`}},values:{code:`{product.name|slug}`,name:`{product.name}`,attributes:`{}`,active:!0}},{as:`location`,model:`@happyvertical/smrt-inventory:InventoryLocation`,match:{code:`MAIN`},values:{name:`Main warehouse`,kind:`warehouse`}},{as:`stock`,model:`@happyvertical/smrt-inventory:StockLevel`,match:{skuId:{ref:`sku`},locationId:{ref:`location`},state:`available`}}],fields:[{id:`quantity`,label:`Quantity`,to:`stock.qty`,default:0}]},{form:`product.clothing`,records:[{as:`location`,model:`@happyvertical/smrt-inventory:InventoryLocation`,match:{code:`MAIN`},values:{name:`Main warehouse`,kind:`warehouse`}},{as:`stock`,model:`@happyvertical/smrt-inventory:StockLevel`,match:{skuId:{ref:`sku`},locationId:{ref:`location`},state:`available`}}],fields:[{id:`quantity`,label:`Quantity`,to:`stock.qty`,default:0}]}]},"products.simple":{forms:[{id:`product.simple`,kind:`field-map`,label:`Simple product`,kindLabel:`Simple`,model:`@happyvertical/smrt-products:Product`,records:[{as:`product`,model:`@happyvertical/smrt-products:Product`}],fields:[{id:`name`,label:`Name`,to:`product.name`,required:!0},{id:`price`,label:`Price`,to:`product.price`},{id:`description`,label:`Description`,to:`product.description`}]}]},"products.clothing":{forms:[{id:`product.clothing`,kind:`variant-grid`,label:`Clothing item`,kindLabel:`Clothing`,model:`@happyvertical/smrt-products:Product`,product:{as:`product`,model:`@happyvertical/smrt-products:Product`},fields:[{id:`name`,label:`Name`,to:`product.name`,required:!0},{id:`price`,label:`Price`,to:`product.price`}],axes:[{name:`size`,label:`Sizes`,values:[`XS`,`S`,`M`,`L`,`XL`]},{name:`color`,label:`Colors`,values:[]}],variants:`@happyvertical/smrt-products:ProductVariant`,skus:`@happyvertical/smrt-products:Sku`}]}}};function ut(e){return e.fields.filter(e=>!e.system)}var dt=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase();function ft(e,t){return/Type$/.test(t.name)&&Array.isArray(t.enum)&&t.enum.length>0&&!!e.extends&&t.enum.includes(dt(e.name))}function pt(e){return e.some(e=>e.ui?.basic===!0)}function mt(e){return e!=null&&e!==``}function ht(e){if(e==null)return null;try{return{value:JSON.parse(e)}}catch{return null}}function K(e,t,n=[]){let r=ut(e),i=pt(r),a=new Map(n.filter(t=>t.objectRef===e.id).map(e=>[e.fieldName,e]));return r.map((n,r)=>{let o=t?.fields?.[n.name]??{},s=ft(e,n),c=o.visibility??(s?`hidden`:!i||n.ui?.basic===!0?`basic`:`advanced`),l=o.label??M(n),u=o.help??null,d=o.order??n.ui?.order??r,f=o.locked??n.ui?.locked??s,p=dt(e.name),m=n.default===void 0?s&&n.enum?.includes(p)?p:void 0:n.default,h=`default`in o||m!==void 0,g=`default`in o?o.default:m,_=a.get(n.name);if(_&&(!f||_.locked===!1)){_.visibility&&(c=_.visibility),_.label&&(l=_.label),_.help!==void 0&&(u=_.help||null),typeof _.displayOrder==`number`&&(d=_.displayOrder);let e=ht(_.defaultValue);e&&(h=!0,g=e.value),typeof _.locked==`boolean`&&(f=_.locked)}let v,y=o.required??n.required;return y&&c!==`basic`&&!(h&&mt(g))&&(c=`basic`,v=!0),{field:n,visibility:c,label:l,help:u,order:d,group:n.ui?.group??null,locked:f,required:y,hasDefault:h,default:g,...v?{visibilityForced:v}:{}}}).map((e,t)=>({entry:e,index:t})).sort((e,t)=>e.entry.order-t.entry.order||e.index-t.index).map(({entry:e})=>e)}function gt(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===null?e:void 0}function _t(e){return e.filter(e=>e.visibility===`basic`).map(e=>{let{default:t,...n}=e.field,r=e.hasDefault?gt(e.default):void 0;return{...n,required:e.required,...r===void 0?{}:{default:r},label:e.label,...e.help?{help:e.help}:{}}})}function vt(e){let t={};for(let n of e)n.visibility!==`basic`&&n.hasDefault&&n.default!==void 0&&(t[n.field.name]=n.default);return t}var yt=[`api`,`mcp`,`cli`],bt={api:`REST`,mcp:`MCP`,cli:`CLI`};function xt(e,t){return(t===`api`?e.rest.length:t===`mcp`?e.mcp.length:e.cli.length)>0}function q(e,t,n=[]){let r={};for(let i of yt){let a=xt(e,i),o=t?.exposure?.[i]===!1;r[i]={available:a,on:a&&!o&&!n.includes(i),locked:!a||o}}return r}function St(e,t){let n=t.mcp.on;return{...e,rest:t.api.on?e.rest:[],mcp:n?e.mcp:[],cli:t.cli.on?e.cli:[],methods:e.methods.map(e=>({...e,aiCallable:e.aiCallable&&n}))}}function Ct(e,t,n=[]){return K(e,t,n).filter(e=>t?.fields?.[e.field.name]?.visibility!==`hidden`)}function wt(e){return e.required||e.locked}function Tt(e,t,n,r){let i={};for(let r of Ct(e,t,n))i[r.field.name]={use:r.visibility===`basic`,label:r.label,help:r.help??``,default:r.hasDefault?r.default:null,order:r.order};let a=q(e,t,r);return{fields:i,exposure:{api:a.api.on,mcp:a.mcp.on,cli:a.cli.on}}}var Et=(e,t)=>JSON.stringify(e??null)===JSON.stringify(t??null);function Dt(e,t,n){let r=Ct(e,t),i=[];for(let t of r){let r=n.fields[t.field.name];if(!r||t.locked)continue;let a={objectRef:e.id,fieldName:t.field.name,scopeType:`app`},o=wt(t)?!0:r.use;o!==(t.visibility===`basic`)&&(a.visibility=o?`basic`:`hidden`),r.label.trim()&&r.label!==t.label&&(a.label=r.label.trim()),r.help!==(t.help??``)&&(a.help=r.help||null),Et(r.default,t.hasDefault?t.default:null)||(a.defaultValue=JSON.stringify(r.default??null)),r.order!==t.order&&(a.displayOrder=r.order),Object.keys(a).length>3&&i.push(a)}return i}function Ot(e,t,n){let r=q(e,t);return yt.filter(e=>r[e].on&&!n.exposure[e])}var kt=st,J=ct(ie.packages.flatMap(e=>e.recipes??[]),lt),At=new Map(J.map(e=>[e.id,e]));function jt(e){return At.get(e)}var Y=At,Mt=Ke(J);function Nt(e){return Mt.find(t=>t.id===e)}function Pt(e){let t=e.models[0];return t?A(t)?.pkg:void 0}function Ft(e){return e.nav.flatMap(e=>{let t=A(e.model);return t?[{label:e.label,icon:e.icon??`fileText`,description:Xe(e.description,t.model),...e.key?{key:e.key}:{},...e.noun?{noun:e.noun}:{},...e.filter?{filter:e.filter}:{},model:t.model,packageId:t.pkg.id}]:[]})}function It(e,t,n){return J.some(r=>Ft(r).some(r=>r.key===n&&r.packageId===e&&r.model.name===t))}function Lt(e){return`/m/${e.packageId}/${e.model.name}/${e.key?`${e.key}/`:``}`}function Rt(e){return e.models.flatMap(e=>{let t=A(e);return t?[{model:t.model,packageId:t.pkg.id}]:[]})}function zt(e,t=[]){let n=e.nav.length>0;return Rt(e).map(({model:r})=>({id:r.id,name:r.name,...n?{}:{glossary:!1},descriptions:{...Object.fromEntries(r.fields.flatMap(e=>e.description?[[e.name,e.description]]:[])),...kt[r.id]},fields:K(r,e.options?.[r.id],t).map(e=>({name:e.field.name,label:e.label,help:e.help,visibility:e.visibility}))}))}function Bt(e){return[...new Set(e)].sort()}function X(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 Bt(n)}function Vt(e,t,n){let r=new Set(e),i=t.filter(e=>!r.has(e)),a=new Set(i);return i.filter(e=>{let t=n.get(e);return t?t.requires.some(e=>r.has(e))?!0:(t.requiresAny??[]).some(e=>e.some(e=>r.has(e))&&!e.some(e=>a.has(e))):!1})}function Ht(e,t,n){return Vt([e],t,n)}function Ut(e,t){return Bt([...e].filter(e=>t.has(e)))}var Wt={currency:`USD`,taxRate:0,paymentTerms:``,pricesIncludeTax:!1,taxRounding:`line`},Z=`@happyvertical/smrt-commerce:`,Q={currency:[`Order`,`PurchaseOrder`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`,`Lease`].map(e=>({model:`${Z}${e}`,field:`currency`})),taxRate:[`InvoiceLineItem`,`ContractLineItem`].map(e=>({model:`${Z}${e}`,field:`taxRate`})),paymentTerms:[...[`Order`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`,`Lease`].map(e=>({model:`${Z}${e}`,field:`terms`})),{model:`${Z}Customer`,field:`paymentTerms`}],pricesIncludeTax:[`Invoice`,`Contract`].map(e=>({model:`${Z}${e}`,field:`lineAmountType`})),taxRounding:[`Invoice`,`Contract`].map(e=>({model:`${Z}${e}`,field:`taxRoundingScope`}))};function Gt(e){return Object.values(Q).some(t=>t.some(t=>t.model===e.objectRef&&t.field===e.fieldName))}var Kt=Object.keys(Q);function qt(e){if(e?.defaultValue!==void 0&&e.defaultValue!==null)try{return JSON.parse(e.defaultValue)}catch{return}}function Jt(e,t,n){return e.find(e=>e.scopeType===`app`&&e.objectRef===t&&e.fieldName===n)}function Yt(e){let t={...Wt},n=(t,n)=>{for(let{model:r,field:i}of Q[t]){let t=qt(Jt(e.policies,r,i));if(typeof t===n)return t}},r=n(`currency`,`string`),i=n(`taxRate`,`number`),a=n(`paymentTerms`,`string`),o=n(`pricesIncludeTax`,`string`),s=n(`taxRounding`,`string`);return typeof r==`string`&&(t.currency=r),typeof i==`number`&&(t.taxRate=i),typeof a==`string`&&(t.paymentTerms=a),(o===`inclusive`||o===`exclusive`)&&(t.pricesIncludeTax=o===`inclusive`),(s===`line`||s===`document`)&&(t.taxRounding=s),t}function Xt(e){return Q.taxRate.some(({model:t,field:n})=>typeof qt(Jt(e.policies,t,n))==`number`)}function Zt(e,t,n){let r=A(t)?.model;if(!r)return;let i=K(r,e.recipes.map(e=>Y.get(e)?.options?.[t]).find(Boolean),[]).find(e=>e.field.name===n);return i?.hasDefault?i.default:void 0}var Qt=e=>e==null||e===``;function $t(e,t){let n=e.policies.map(e=>({...e}));for(let r of Kt){let i=t[r],a=r===`paymentTerms`?String(i).trim():r===`currency`?String(i).trim().toUpperCase():r===`pricesIncludeTax`?i?`inclusive`:`exclusive`:i;for(let{model:t,field:i}of Q[r]){let o=Zt(e,t,i),s=!Qt(a)&&!(!Qt(o)&&o===a)&&!(Qt(o)&&r===`taxRate`&&a===0),c=Jt(n,t,i);if(s){let e=JSON.stringify(a);c?c.defaultValue=e:n.push({objectRef:t,fieldName:i,scopeType:`app`,defaultValue:e})}else c&&(delete c.defaultValue,Object.keys(c).length<=3&&(n=n.filter(e=>e!==c)))}}return{...e,policies:n}}function en(e){return{...Wt,...e}}var tn=()=>({ids:[],rows:[],narrowed:{},features:[],unavailableRecipes:[],unavailableFeatures:[]});function $(e){let t=new Set([...e.ids.flatMap(e=>Y.get(e)?.models??[]),...e.features]);return{...e,rows:e.rows.filter(e=>t.has(e.objectRef)||Gt(e)),narrowed:Object.fromEntries(Object.entries(e.narrowed).filter(([e])=>t.has(e)))}}var nn=(e,t)=>({...e,ids:X([...e.ids,...t],Y)});function rn(e,t){let n=new Set(t),r=e.ids.filter(e=>!n.has(e));return $({...e,ids:X(r,Y)})}var an=(e,t)=>e.features.includes(t)?e:{...e,features:[...e.features,t].sort()},on=(e,t)=>$({...e,features:e.features.filter(e=>e!==t)}),sn=(e,t)=>Ht(t,e.ids,Y);function cn(e,t){for(let n of e.ids){let e=Y.get(n)?.options?.[t];if(e)return e}}function ln(e,t,n,r){let i={...e.narrowed};return r.length?i[t]=[...r]:delete i[t],{...e,rows:[...e.rows.filter(e=>e.objectRef!==t),...n],narrowed:i}}function un(e){let t=[...e.rows].sort((e,t)=>e.objectRef.localeCompare(t.objectRef)||e.fieldName.localeCompare(t.fieldName)),n=Object.fromEntries(Object.keys(e.narrowed).sort().filter(t=>e.narrowed[t].length).map(t=>[t,[...e.narrowed[t]].sort()])),r={recipes:[...e.ids,...e.unavailableRecipes].sort(),features:[...e.features,...e.unavailableFeatures].sort(),policies:t.map(e=>({...e}))};return Object.keys(n).length&&(r.exposure=n),r}function dn(e){let t=[...new Set(e.features)],n=e=>!!A(e)?.model.exposed;return $({ids:X(e.recipes,Y),rows:e.policies.map(e=>({...e})),narrowed:Object.fromEntries(Object.entries(e.exposure??{}).map(([e,t])=>[e,[...t]])),features:t.filter(n).sort(),unavailableRecipes:[...new Set(e.recipes.filter(e=>!Y.has(e)))].sort(),unavailableFeatures:t.filter(e=>!n(e)).sort()})}var fn=new class{#e=b(C([]));get ids(){return e(this.#e)}set ids(e){k(this.#e,e,!0)}#t=b(C([]));get rows(){return e(this.#t)}set rows(e){k(this.#t,e,!0)}#n=b(C({}));get narrowed(){return e(this.#n)}set narrowed(e){k(this.#n,e,!0)}#r=b(C([]));get features(){return e(this.#r)}set features(e){k(this.#r,e,!0)}#i=b(C([]));get unavailableRecipes(){return e(this.#i)}set unavailableRecipes(e){k(this.#i,e,!0)}#a=b(C([]));get unavailableFeatures(){return e(this.#a)}set unavailableFeatures(e){k(this.#a,e,!0)}get data(){return{ids:this.ids,rows:this.rows,narrowed:this.narrowed,features:this.features,unavailableRecipes:this.unavailableRecipes,unavailableFeatures:this.unavailableFeatures}}set(e){this.ids=e.ids,this.rows=e.rows,this.narrowed=e.narrowed,this.features=e.features,this.unavailableRecipes=e.unavailableRecipes,this.unavailableFeatures=e.unavailableFeatures}removeUnavailable(){this.unavailableRecipes=[],this.unavailableFeatures=[]}hasFeature(e){return this.features.includes(e)}addFeature(e){this.set(an(this.data,e))}removeFeature(e){this.set(on(this.data,e))}has(e){return this.ids.includes(e)}requiredBy(e){return sn(this.data,e)}add(...e){this.set(nn(this.data,e))}remove(...e){this.set(rn(this.data,e))}toggle(e){this.has(e)?this.remove(e):this.add(e)}clear(){this.set(tn())}hintsFor(e){return cn(this,e)}apply(e){let t=this.hintsFor(e.id),n=K(e,t,this.rows);return{model:St(e,q(e,t,this.narrowed[e.id]??[])),resolved:n,fields:_t(n),background:vt(n)}}save(e,t,n){this.set(ln(this.data,e,t,n))}reset(e){this.save(e,[],[])}snapshot(){return un(this.data)}load(e){this.set(dn(e))}};export{he as $,Dt as A,Ye as B,yt as C,wt as D,Ct as E,nt as F,Ve as G,W as H,at as I,Ge as J,He as K,rt as L,tt as M,ot as N,Ot as O,it as P,De as Q,qe as R,Mt as S,Tt as T,ze as U,G as V,Ue as W,Be as X,We as Y,ke as Z,Rt as _,Gt as a,J as b,$t as c,X as d,R as et,jt as f,Lt as g,zt as h,Xt as i,Qe as j,q as k,Ut as l,It as m,un as n,Yt as o,Nt as p,Fe as q,Q as r,en as s,fn as t,Vt as u,Ft as v,bt as w,Y as x,Pt as y,Je as z};
|