@happyvertical/smrt-planner 0.57.52 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/404.html +18 -18
- package/app/_app/immutable/chunks/{CXgRpFBO.js → BJ91fRVh.js} +1 -1
- package/app/_app/immutable/chunks/BS1Mt1uk.js +1 -0
- package/app/_app/immutable/chunks/{DieTGBbV.js → BWYTaJWK.js} +1 -1
- package/app/_app/immutable/chunks/{Der5kU-H.js → BqVNfB0l.js} +1 -1
- package/app/_app/immutable/chunks/{461IDKvN.js → BseSe55V.js} +1 -1
- package/app/_app/immutable/chunks/{CyTc54Xp.js → Bx4LayZq.js} +1 -1
- package/app/_app/immutable/chunks/{CArvuv9U.js → Bx9R-SRZ.js} +1 -1
- package/app/_app/immutable/chunks/{DhIzK2qb.js → CGIbVE8J.js} +1 -1
- package/app/_app/immutable/chunks/{CBnuSOKK.js → CVBY5DfH.js} +1 -1
- package/app/_app/immutable/chunks/{0CMQGCnw.js → CiMebbrR.js} +1 -1
- package/app/_app/immutable/chunks/{ClhMJXEf.js → Cr66tvwj.js} +1 -1
- package/app/_app/immutable/chunks/{BpGcTxSl.js → D-a3KitJ.js} +1 -1
- package/app/_app/immutable/chunks/{B_jvIFHH.js → D5jeKpta.js} +1 -1
- package/app/_app/immutable/chunks/{BDXut-Fg.js → D9Sgo9qk.js} +1 -1
- package/app/_app/immutable/chunks/{x6l6IW7T.js → DEcMBXAd.js} +1 -1
- package/app/_app/immutable/chunks/DJW050J4.js +1686 -0
- package/app/_app/immutable/chunks/{CzFr5Uqu.js → DMAvz6OX.js} +1 -1
- package/app/_app/immutable/chunks/{BqzI3Av3.js → DMIctWv9.js} +1 -1
- package/app/_app/immutable/chunks/{DpbvbKx4.js → DN8ism_E.js} +1 -1
- package/app/_app/immutable/chunks/DcO6ey8U.js +1 -0
- package/app/_app/immutable/chunks/{I0OwXlFn.js → Dcbo_pOT.js} +1 -1
- package/app/_app/immutable/chunks/{CC-VBbYj.js → DjNms-Yo.js} +1 -1
- package/app/_app/immutable/chunks/{GUdIW0gX.js → DnrPDAmA.js} +1 -1
- package/app/_app/immutable/chunks/{B4MeBXqv.js → DwBgRH4K.js} +1 -1
- package/app/_app/immutable/chunks/{D0JJJfZF.js → HQUuGK-d.js} +3 -3
- package/app/_app/immutable/chunks/{B90FTX_s.js → OiIeHBBe.js} +1 -1
- package/app/_app/immutable/chunks/{DYTFq5SX.js → PEIUyfhf.js} +2 -2
- package/app/_app/immutable/chunks/{4y77lz60.js → _X17wVs0.js} +1 -1
- package/app/_app/immutable/chunks/{CiGeGBWP.js → t2Kb7sV-.js} +1 -1
- package/app/_app/immutable/entry/{app.CF6EnCrq.js → app.V9RkyTZE.js} +2 -2
- package/app/_app/immutable/entry/start.DvkTfnam.js +1 -0
- package/app/_app/immutable/nodes/{0.CqsdNL0h.js → 0.DvK34E7N.js} +1 -1
- package/app/_app/immutable/nodes/{1.CalkhVQH.js → 1.BpOenJpi.js} +1 -1
- package/app/_app/immutable/nodes/{10.D9ochzKa.js → 10.BQpZlWj8.js} +1 -1
- package/app/_app/immutable/nodes/{11.Cb3MWA4i.js → 11.C2F5VZze.js} +1 -1
- package/app/_app/immutable/nodes/{12.zIY9YBJx.js → 12.DA3Ca46T.js} +1 -1
- package/app/_app/immutable/nodes/{13.CkISi5dX.js → 13.DfNeurws.js} +1 -1
- package/app/_app/immutable/nodes/{14.BI42nwm8.js → 14.3imCgXTz.js} +1 -1
- package/app/_app/immutable/nodes/{2.B7KJq_CZ.js → 2.CW_xOlE3.js} +3 -3
- package/app/_app/immutable/nodes/{3.BCDwOGjS.js → 3.s0CBrGuD.js} +1 -1
- package/app/_app/immutable/nodes/{4.tpTSnNbg.js → 4.C-e0212c.js} +1 -1
- package/app/_app/immutable/nodes/{5.CSlnwplv.js → 5.BvdScWAH.js} +1 -1
- package/app/_app/immutable/nodes/{6.CY_pFWpo.js → 6.DF2484fw.js} +1 -1
- package/app/_app/immutable/nodes/{7.C-nkapKk.js → 7.hHrJ2pFY.js} +1 -1
- package/app/_app/immutable/nodes/{8.BjNkzKl9.js → 8.BBeaS8wG.js} +1 -1
- package/app/_app/immutable/nodes/{9.NC3NC_1q.js → 9.9tk3hMnt.js} +1 -1
- package/app/_app/version.json +1 -1
- package/app/advanced-styles/index.html +21 -21
- package/app/ai/index.html +24 -24
- package/app/blueprint/index.html +19 -19
- package/app/cookbook/index.html +19 -19
- package/app/index.html +27 -27
- package/app/m/ads/AdDeliveryTier/index.html +23 -23
- package/app/m/ads/AdEvent/index.html +23 -23
- package/app/m/ads/AdFormat/index.html +23 -23
- package/app/m/ads/AdGroup/index.html +23 -23
- package/app/m/ads/AdVariation/index.html +23 -23
- package/app/m/analytics/AnalyticsDataStream/index.html +23 -23
- package/app/m/analytics/AnalyticsEvent/index.html +23 -23
- package/app/m/analytics/AnalyticsProperty/index.html +23 -23
- package/app/m/analytics/AnalyticsReport/index.html +23 -23
- package/app/m/approvals/ApprovalEvent/index.html +23 -23
- package/app/m/approvals/ApprovalPolicy/index.html +23 -23
- package/app/m/approvals/ApprovalRequest/index.html +23 -23
- package/app/m/assets/Asset/attachments/index.html +24 -24
- package/app/m/assets/Asset/index.html +23 -23
- package/app/m/assets/AssetAssociation/index.html +23 -23
- package/app/m/assets/AssetMetafield/index.html +23 -23
- package/app/m/assets/AssetStatus/index.html +23 -23
- package/app/m/assets/AssetType/index.html +23 -23
- package/app/m/assets/Folder/index.html +23 -23
- package/app/m/chat/AgentSession/index.html +23 -23
- package/app/m/chat/ChatMessage/index.html +23 -23
- package/app/m/chat/ChatParticipant/index.html +23 -23
- package/app/m/chat/ChatReaction/index.html +23 -23
- package/app/m/chat/ChatRoom/index.html +23 -23
- package/app/m/chat/ChatThread/index.html +23 -23
- package/app/m/chat/VoiceGatewayTurn/index.html +23 -23
- package/app/m/chat/VoiceSession/index.html +23 -23
- package/app/m/commerce/Agreement/index.html +23 -23
- package/app/m/commerce/Cart/index.html +23 -23
- package/app/m/commerce/Contract/index.html +23 -23
- package/app/m/commerce/ContractLineItem/index.html +23 -23
- package/app/m/commerce/Customer/index.html +23 -23
- package/app/m/commerce/DocumentTax/index.html +23 -23
- package/app/m/commerce/Estimate/index.html +23 -23
- package/app/m/commerce/Fulfillment/index.html +23 -23
- package/app/m/commerce/FulfillmentLineItem/index.html +23 -23
- package/app/m/commerce/HistoricalCustomerFunds/index.html +23 -23
- package/app/m/commerce/HistoricalCustomerFundsAllocation/index.html +23 -23
- package/app/m/commerce/HistoricalSalesLine/index.html +23 -23
- package/app/m/commerce/Invoice/index.html +23 -23
- package/app/m/commerce/InvoiceLineItem/index.html +23 -23
- package/app/m/commerce/Lease/index.html +23 -23
- package/app/m/commerce/LicenseSale/index.html +23 -23
- package/app/m/commerce/Order/index.html +23 -23
- package/app/m/commerce/Payment/index.html +23 -23
- package/app/m/commerce/PaymentAllocation/index.html +23 -23
- package/app/m/commerce/PaymentInstrument/index.html +23 -23
- package/app/m/commerce/PaymentIntent/index.html +23 -23
- package/app/m/commerce/Payout/index.html +23 -23
- package/app/m/commerce/ProductionOrder/index.html +23 -23
- package/app/m/commerce/PurchaseContract/index.html +23 -23
- package/app/m/commerce/PurchaseOrder/index.html +23 -23
- package/app/m/commerce/SalesContract/index.html +23 -23
- package/app/m/commerce/SupplierQuote/index.html +23 -23
- package/app/m/commerce/TaxCode/index.html +23 -23
- package/app/m/commerce/TaxComponent/index.html +23 -23
- package/app/m/commerce/TaxSettings/index.html +23 -23
- package/app/m/commerce/TaxSummaryReport/index.html +23 -23
- package/app/m/commerce/TenantPaymentAccount/index.html +23 -23
- package/app/m/commerce/Vendor/index.html +23 -23
- package/app/m/commerce/WholesaleOrder/index.html +23 -23
- package/app/m/content/Content/articles/index.html +24 -24
- package/app/m/content/Content/index.html +23 -23
- package/app/m/content/ContentContribution/index.html +23 -23
- package/app/m/content/ContentContributionAttachment/index.html +23 -23
- package/app/m/content/ContentContributionRevision/index.html +23 -23
- package/app/m/content/ContentContributionType/index.html +23 -23
- package/app/m/content/ContentContributor/index.html +23 -23
- package/app/m/content/ContentCorrection/index.html +23 -23
- package/app/m/content/ContentFeedSource/index.html +23 -23
- package/app/m/content/ContentGovernanceAssignment/index.html +23 -23
- package/app/m/content/ContentGovernancePolicy/index.html +23 -23
- package/app/m/content/ContentGovernanceProfile/index.html +23 -23
- package/app/m/content/ContentReference/index.html +23 -23
- package/app/m/content/ContentReview/index.html +23 -23
- package/app/m/content/ContentVersion/index.html +23 -23
- package/app/m/events/Event/index.html +23 -23
- package/app/m/events/EventParticipant/index.html +23 -23
- package/app/m/events/EventSeries/index.html +23 -23
- package/app/m/events/EventType/index.html +23 -23
- package/app/m/expenses/Expense/index.html +23 -23
- package/app/m/facts/Fact/index.html +23 -23
- package/app/m/facts/FactContent/index.html +23 -23
- package/app/m/facts/FactEvidence/index.html +23 -23
- package/app/m/facts/FactSource/index.html +23 -23
- package/app/m/facts/FactSubject/index.html +23 -23
- package/app/m/facts/FactTag/index.html +23 -23
- package/app/m/fields/FieldPolicy/index.html +23 -23
- package/app/m/fields/FieldPolicySuggestion/index.html +23 -23
- package/app/m/fields/FieldUsageCounter/index.html +23 -23
- package/app/m/human-resources/Employment/index.html +23 -23
- package/app/m/human-resources/EmploymentTerm/index.html +23 -23
- package/app/m/human-resources/HeldQualification/index.html +23 -23
- package/app/m/human-resources/Qualification/index.html +23 -23
- package/app/m/images/Image/index.html +23 -23
- package/app/m/inventory/InventoryLocation/index.html +23 -23
- package/app/m/inventory/Lot/index.html +23 -23
- package/app/m/inventory/LotCorrection/index.html +23 -23
- package/app/m/inventory/LotDocument/index.html +23 -23
- package/app/m/inventory/LotStockLevel/index.html +23 -23
- package/app/m/inventory/LotUsage/index.html +23 -23
- package/app/m/inventory/StockLevel/index.html +23 -23
- package/app/m/inventory/StockMovement/index.html +23 -23
- package/app/m/ledgers/Account/index.html +23 -23
- package/app/m/ledgers/Journal/index.html +23 -23
- package/app/m/ledgers/JournalEntry/index.html +23 -23
- package/app/m/ledgers/Ledger/index.html +23 -23
- package/app/m/manufacturing/Assembly/index.html +23 -23
- package/app/m/manufacturing/BillOfMaterials/index.html +23 -23
- package/app/m/manufacturing/BomLine/index.html +23 -23
- package/app/m/manufacturing/Operation/index.html +23 -23
- package/app/m/manufacturing/ProductionRun/index.html +23 -23
- package/app/m/manufacturing/ProductionRunCompletion/index.html +23 -23
- package/app/m/manufacturing/RoutingStep/index.html +23 -23
- package/app/m/marketing/Campaign/index.html +23 -23
- package/app/m/marketing/CampaignChannel/index.html +23 -23
- package/app/m/marketing/CampaignMetricSnapshot/index.html +23 -23
- package/app/m/messages/Account/index.html +23 -23
- package/app/m/messages/Attachment/index.html +23 -23
- package/app/m/messages/Blacklist/index.html +23 -23
- package/app/m/messages/Email/failed-sends/index.html +24 -24
- package/app/m/messages/Email/index.html +23 -23
- package/app/m/messages/Email/mailbox/index.html +24 -24
- package/app/m/messages/EmailAccount/index.html +23 -23
- package/app/m/messages/EmailAttachment/index.html +23 -23
- package/app/m/messages/EmailFolder/index.html +23 -23
- package/app/m/messages/Message/index.html +23 -23
- package/app/m/messages/MessagingEndpoint/index.html +23 -23
- package/app/m/messages/PersonaMessageRoute/index.html +23 -23
- package/app/m/messages/SlackAccount/index.html +23 -23
- package/app/m/messages/SlackMessage/index.html +23 -23
- package/app/m/messages/SlackMessage/slack-messages/index.html +24 -24
- package/app/m/messages/TelegramAccount/index.html +23 -23
- package/app/m/messages/Tweet/index.html +23 -23
- package/app/m/messages/TwitterAccount/index.html +23 -23
- package/app/m/messages/Whitelist/index.html +23 -23
- package/app/m/messages/ZulipAccount/index.html +23 -23
- package/app/m/places/Place/index.html +23 -23
- package/app/m/places/PlaceType/index.html +23 -23
- package/app/m/products/Category/index.html +23 -23
- package/app/m/products/Material/index.html +23 -23
- package/app/m/products/Product/index.html +23 -23
- package/app/m/products/Product/ingredients/index.html +24 -24
- package/app/m/products/ProductVariant/index.html +23 -23
- package/app/m/products/Sku/index.html +23 -23
- package/app/m/profiles/ApiKey/index.html +23 -23
- package/app/m/profiles/Bot/index.html +23 -23
- package/app/m/profiles/MagicLinkToken/index.html +23 -23
- package/app/m/profiles/NostrIdentity/index.html +23 -23
- package/app/m/profiles/OidcIdentity/index.html +23 -23
- package/app/m/profiles/Organization/index.html +23 -23
- package/app/m/profiles/Person/index.html +23 -23
- package/app/m/profiles/Profile/index.html +23 -23
- package/app/m/profiles/ProfileMetadata/index.html +23 -23
- package/app/m/profiles/ProfileMetafield/index.html +23 -23
- package/app/m/profiles/ProfileRelationship/index.html +23 -23
- package/app/m/profiles/ProfileRelationshipTerm/index.html +23 -23
- package/app/m/profiles/ProfileRelationshipType/index.html +23 -23
- package/app/m/profiles/ProfileType/index.html +23 -23
- package/app/m/projects/Comment/index.html +23 -23
- package/app/m/projects/Issue/index.html +23 -23
- package/app/m/projects/Label/index.html +23 -23
- package/app/m/projects/Project/index.html +23 -23
- package/app/m/projects/ProjectIntegration/index.html +23 -23
- package/app/m/projects/PullRequest/index.html +23 -23
- package/app/m/projects/Repository/index.html +23 -23
- package/app/m/properties/Property/index.html +23 -23
- package/app/m/properties/Zone/index.html +23 -23
- package/app/m/reports/RuntimeReport/index.html +23 -23
- package/app/m/reports/SmrtPrincipalReportRefreshTask/index.html +23 -23
- package/app/m/reports/SmrtReportLock/index.html +23 -23
- package/app/m/reports/SmrtReportRefreshTask/index.html +23 -23
- package/app/m/reports/SmrtReportRun/index.html +23 -23
- package/app/m/reports/SmrtReportSchedule/index.html +23 -23
- package/app/m/reports/SmrtReportWatermark/index.html +23 -23
- package/app/m/sales/Agreement/index.html +23 -23
- package/app/m/sales/AttributionException/index.html +23 -23
- package/app/m/sales/AttributionPolicy/index.html +23 -23
- package/app/m/sales/Commission/index.html +23 -23
- package/app/m/sales/CommissionAdjustment/index.html +23 -23
- package/app/m/sales/CommissionPayout/index.html +23 -23
- package/app/m/sales/CommissionPlan/index.html +23 -23
- package/app/m/sales/Earner/index.html +23 -23
- package/app/m/sales/EarnerSourceAttribution/index.html +23 -23
- package/app/m/sales/EarningEvent/index.html +23 -23
- package/app/m/sales/ExecutedAgreement/index.html +23 -23
- package/app/m/sales/Lead/index.html +23 -23
- package/app/m/sales/Opportunity/index.html +23 -23
- package/app/m/sales/OpportunityConversion/index.html +23 -23
- package/app/m/sales/PipelineDefinition/index.html +23 -23
- package/app/m/sales/PipelineStage/index.html +23 -23
- package/app/m/sales/Referral/index.html +23 -23
- package/app/m/sales/ReferralAgreement/index.html +23 -23
- package/app/m/sales/ReferralLink/index.html +23 -23
- package/app/m/sales/ReferralProgram/index.html +23 -23
- package/app/m/sales/ReferralTermSnapshot/index.html +23 -23
- package/app/m/sales/ReferralTouch/index.html +23 -23
- package/app/m/sales/Referrer/index.html +23 -23
- package/app/m/sales/SalesActivity/index.html +23 -23
- package/app/m/sales/SalesRepresentative/index.html +23 -23
- package/app/m/sites/Site/index.html +23 -23
- package/app/m/sites/SiteAgentBinding/index.html +23 -23
- package/app/m/social/OAuthState/index.html +23 -23
- package/app/m/social/SocialAccount/index.html +23 -23
- package/app/m/social/SocialPost/index.html +23 -23
- package/app/m/social/SocialPostAnalyticsSnapshot/index.html +23 -23
- package/app/m/subscriptions/BillingAdjustment/index.html +23 -23
- package/app/m/subscriptions/ClientCharge/index.html +23 -23
- package/app/m/subscriptions/CreditGrant/index.html +23 -23
- package/app/m/subscriptions/PricingRule/index.html +23 -23
- package/app/m/subscriptions/RetailCharge/index.html +23 -23
- package/app/m/subscriptions/SpendingPolicy/index.html +23 -23
- package/app/m/subscriptions/SubscriptionPlan/index.html +23 -23
- package/app/m/subscriptions/SubscriptionPlanVersion/index.html +23 -23
- package/app/m/subscriptions/TenantSubscription/index.html +23 -23
- package/app/m/subscriptions/TenantUsageMetric/index.html +23 -23
- package/app/m/support/ServiceTimeEntry/index.html +23 -23
- package/app/m/support/SupportAiRun/index.html +23 -23
- package/app/m/support/SupportAvailability/index.html +23 -23
- package/app/m/support/SupportCase/index.html +23 -23
- package/app/m/support/SupportCaseEvent/index.html +23 -23
- package/app/m/support/SupportChannelBinding/index.html +23 -23
- package/app/m/support/SupportCharge/index.html +23 -23
- package/app/m/support/SupportCompensation/index.html +23 -23
- package/app/m/support/SupportCompensationPlan/index.html +23 -23
- package/app/m/support/SupportEscalation/index.html +23 -23
- package/app/m/support/SupportInteraction/index.html +23 -23
- package/app/m/support/SupportPlan/index.html +23 -23
- package/app/m/support/SupportPolicy/index.html +23 -23
- package/app/m/support/SupportQualification/index.html +23 -23
- package/app/m/support/SupportServiceTarget/index.html +23 -23
- package/app/m/support/SupportSpecialist/index.html +23 -23
- package/app/m/support/SupportWorkLink/index.html +23 -23
- package/app/m/tags/Tag/index.html +23 -23
- package/app/m/tags/TagAlias/index.html +23 -23
- package/app/m/timesheets/AttendanceBreak/index.html +23 -23
- package/app/m/timesheets/AttendancePunch/index.html +23 -23
- package/app/m/timesheets/AttendanceSegment/index.html +23 -23
- package/app/m/timesheets/ServiceChargeSnapshot/index.html +23 -23
- package/app/m/timesheets/ServiceCompensationSnapshot/index.html +23 -23
- package/app/m/timesheets/ServiceTimeEntry/index.html +23 -23
- package/app/m/users/Group/index.html +23 -23
- package/app/m/users/GroupMember/index.html +23 -23
- package/app/m/users/GroupRole/index.html +23 -23
- package/app/m/users/Membership/index.html +23 -23
- package/app/m/users/MembershipOverride/index.html +23 -23
- package/app/m/users/Permission/index.html +23 -23
- package/app/m/users/Role/index.html +23 -23
- package/app/m/users/RolePermission/index.html +23 -23
- package/app/m/users/Session/index.html +23 -23
- package/app/m/users/Tenant/index.html +23 -23
- package/app/m/users/TenantIntegration/index.html +23 -23
- package/app/m/users/TenantPermissionOverride/index.html +23 -23
- package/app/m/users/User/index.html +23 -23
- package/app/m/video/Character/index.html +23 -23
- package/app/m/video/CharacterAsset/index.html +23 -23
- package/app/m/video/CompositeJob/index.html +23 -23
- package/app/m/video/Performer/index.html +23 -23
- package/app/m/video/PerformerAsset/index.html +23 -23
- package/app/m/video/Scene/index.html +23 -23
- package/app/m/video/SceneAsset/index.html +23 -23
- package/app/m/video/VideoComposition/index.html +23 -23
- package/app/m/video/VideoCompositionAsset/index.html +23 -23
- package/app/m/video/VideoSequence/index.html +23 -23
- package/app/m/video/VideoSequenceAsset/index.html +23 -23
- package/app/m/video/VideoShot/index.html +23 -23
- package/app/m/video/VideoShotAsset/index.html +23 -23
- package/app/m/video/VideoShotCharacter/index.html +23 -23
- package/app/m/video/VideoWorkflow/index.html +23 -23
- package/app/m/voice/VoiceOutput/index.html +23 -23
- package/app/m/voice/VoiceProfile/index.html +23 -23
- package/app/m/voice/VoiceSample/index.html +23 -23
- package/app/mcp.html +2 -2
- package/app/packages/ads/index.html +21 -21
- package/app/packages/analytics/index.html +21 -21
- package/app/packages/approvals/index.html +21 -21
- package/app/packages/assets/index.html +21 -21
- package/app/packages/chat/index.html +21 -21
- package/app/packages/comments/index.html +21 -21
- package/app/packages/commerce/index.html +21 -21
- package/app/packages/content/index.html +21 -21
- package/app/packages/events/index.html +21 -21
- package/app/packages/expenses/index.html +21 -21
- package/app/packages/facts/index.html +21 -21
- package/app/packages/fields/index.html +21 -21
- package/app/packages/human-resources/index.html +21 -21
- package/app/packages/images/index.html +21 -21
- package/app/packages/index.html +20 -20
- package/app/packages/ingestion/index.html +21 -21
- package/app/packages/inventory/index.html +21 -21
- package/app/packages/ledgers/index.html +21 -21
- package/app/packages/manufacturing/index.html +21 -21
- package/app/packages/marketing/index.html +21 -21
- package/app/packages/messages/index.html +21 -21
- package/app/packages/places/index.html +21 -21
- package/app/packages/preferences/index.html +21 -21
- package/app/packages/products/index.html +21 -21
- package/app/packages/profiles/index.html +21 -21
- package/app/packages/projects/index.html +21 -21
- package/app/packages/properties/index.html +21 -21
- package/app/packages/reactions/index.html +21 -21
- package/app/packages/reports/index.html +21 -21
- package/app/packages/sales/index.html +21 -21
- package/app/packages/sites/index.html +21 -21
- package/app/packages/social/index.html +21 -21
- package/app/packages/subscriptions/index.html +21 -21
- package/app/packages/support/index.html +21 -21
- package/app/packages/tags/index.html +21 -21
- package/app/packages/timesheets/index.html +21 -21
- package/app/packages/users/index.html +21 -21
- package/app/packages/video/index.html +21 -21
- package/app/packages/voice/index.html +21 -21
- package/app/packages/webhooks/index.html +21 -21
- package/app/recipes/account-access/help/index.html +21 -21
- package/app/recipes/account-access/index.html +23 -23
- package/app/recipes/activity/help/index.html +21 -21
- package/app/recipes/activity/index.html +23 -23
- package/app/recipes/ads.campaigns/help/index.html +21 -21
- package/app/recipes/ads.campaigns/index.html +23 -23
- package/app/recipes/affiliates.referrals/help/index.html +21 -21
- package/app/recipes/affiliates.referrals/index.html +23 -23
- package/app/recipes/agreements/help/index.html +21 -21
- package/app/recipes/agreements/index.html +23 -23
- package/app/recipes/analytics.reports/help/index.html +21 -21
- package/app/recipes/analytics.reports/index.html +23 -23
- package/app/recipes/approvals.requests/help/index.html +21 -21
- package/app/recipes/approvals.requests/index.html +23 -23
- package/app/recipes/assets/help/index.html +21 -21
- package/app/recipes/assets/index.html +23 -23
- package/app/recipes/billing/help/index.html +21 -21
- package/app/recipes/billing/index.html +23 -23
- package/app/recipes/chat.assistant/help/index.html +21 -21
- package/app/recipes/chat.assistant/index.html +23 -23
- package/app/recipes/comments/help/index.html +21 -21
- package/app/recipes/comments/index.html +23 -23
- package/app/recipes/commerce.customers/help/index.html +21 -21
- package/app/recipes/commerce.customers/index.html +23 -23
- package/app/recipes/commerce.estimates/help/index.html +21 -21
- package/app/recipes/commerce.estimates/index.html +23 -23
- package/app/recipes/commerce.purchases/help/index.html +21 -21
- package/app/recipes/commerce.purchases/index.html +23 -23
- package/app/recipes/commerce.sales/help/index.html +21 -21
- package/app/recipes/commerce.sales/index.html +23 -23
- package/app/recipes/commerce.vendors/help/index.html +21 -21
- package/app/recipes/commerce.vendors/index.html +23 -23
- package/app/recipes/commerce.wholesale/help/index.html +21 -21
- package/app/recipes/commerce.wholesale/index.html +23 -23
- package/app/recipes/content.articles/help/index.html +21 -21
- package/app/recipes/content.articles/index.html +23 -23
- package/app/recipes/events.calendar/help/index.html +21 -21
- package/app/recipes/events.calendar/index.html +23 -23
- package/app/recipes/expenses.tracking/help/index.html +21 -21
- package/app/recipes/expenses.tracking/index.html +23 -23
- package/app/recipes/fields.form-customization/help/index.html +21 -21
- package/app/recipes/fields.form-customization/index.html +23 -23
- package/app/recipes/human-resources.people/help/index.html +21 -21
- package/app/recipes/human-resources.people/index.html +23 -23
- package/app/recipes/human-resources.qualifications/help/index.html +21 -21
- package/app/recipes/human-resources.qualifications/index.html +23 -23
- package/app/recipes/ingestion/help/index.html +21 -21
- package/app/recipes/ingestion/index.html +23 -23
- package/app/recipes/integrations/help/index.html +21 -21
- package/app/recipes/integrations/index.html +23 -23
- package/app/recipes/inventory.stock/help/index.html +21 -21
- package/app/recipes/inventory.stock/index.html +23 -23
- package/app/recipes/ledgers.bookkeeping/help/index.html +21 -21
- package/app/recipes/ledgers.bookkeeping/index.html +23 -23
- package/app/recipes/manufacturing.assemblies/help/index.html +21 -21
- package/app/recipes/manufacturing.assemblies/index.html +23 -23
- package/app/recipes/manufacturing.production/help/index.html +21 -21
- package/app/recipes/manufacturing.production/index.html +23 -23
- package/app/recipes/marketing.campaigns/help/index.html +21 -21
- package/app/recipes/marketing.campaigns/index.html +23 -23
- package/app/recipes/messages/help/index.html +21 -21
- package/app/recipes/messages/index.html +23 -23
- package/app/recipes/places.locations/help/index.html +21 -21
- package/app/recipes/places.locations/index.html +23 -23
- package/app/recipes/products/help/index.html +21 -21
- package/app/recipes/products/index.html +23 -23
- package/app/recipes/projects.tracker/help/index.html +21 -21
- package/app/recipes/projects.tracker/index.html +23 -23
- package/app/recipes/reports.materialized/help/index.html +21 -21
- package/app/recipes/reports.materialized/index.html +23 -23
- package/app/recipes/reports.runtime/help/index.html +21 -21
- package/app/recipes/reports.runtime/index.html +23 -23
- package/app/recipes/sales.pipeline/help/index.html +21 -21
- package/app/recipes/sales.pipeline/index.html +23 -23
- package/app/recipes/social.posts/help/index.html +21 -21
- package/app/recipes/social.posts/index.html +23 -23
- package/app/recipes/subscriptions.plans/help/index.html +21 -21
- package/app/recipes/subscriptions.plans/index.html +23 -23
- package/app/recipes/support.tickets/help/index.html +21 -21
- package/app/recipes/support.tickets/index.html +23 -23
- package/app/recipes/tags.taxonomy/help/index.html +21 -21
- package/app/recipes/tags.taxonomy/index.html +23 -23
- package/app/recipes/team-collaboration/help/index.html +21 -21
- package/app/recipes/team-collaboration/index.html +23 -23
- package/app/recipes/timesheets.time-entries/help/index.html +21 -21
- package/app/recipes/timesheets.time-entries/index.html +23 -23
- package/app/recipes/video.library/help/index.html +21 -21
- package/app/recipes/video.library/index.html +23 -23
- package/app/recipes/voice.profiles/help/index.html +21 -21
- package/app/recipes/voice.profiles/index.html +23 -23
- package/app/s/custom-accounts/index.html +19 -19
- package/app/s/custom-appointments/index.html +19 -19
- package/app/s/custom-billing/index.html +19 -19
- package/app/s/custom-bookings/index.html +19 -19
- package/app/s/custom-buying/index.html +19 -19
- package/app/s/custom-checkout/index.html +19 -19
- package/app/s/custom-classes/index.html +19 -19
- package/app/s/custom-clients/index.html +19 -19
- package/app/s/custom-events/index.html +19 -19
- package/app/s/custom-fleet/index.html +19 -19
- package/app/s/custom-gigs/index.html +19 -19
- package/app/s/custom-giving/index.html +19 -19
- package/app/s/custom-instruments/index.html +19 -19
- package/app/s/custom-jobs/index.html +19 -19
- package/app/s/custom-kitchen/index.html +19 -19
- package/app/s/custom-lessons/index.html +19 -19
- package/app/s/custom-material/index.html +19 -19
- package/app/s/custom-meetings/index.html +19 -19
- package/app/s/custom-members/index.html +19 -19
- package/app/s/custom-merch/index.html +19 -19
- package/app/s/custom-money/index.html +19 -19
- package/app/s/custom-paint/index.html +19 -19
- package/app/s/custom-parts/index.html +19 -19
- package/app/s/custom-rentals/index.html +19 -19
- package/app/s/custom-roastery/index.html +19 -19
- package/app/s/custom-schedule/index.html +19 -19
- package/app/s/custom-shelf/index.html +19 -19
- package/app/s/custom-shop/index.html +19 -19
- package/app/s/custom-students/index.html +19 -19
- package/app/s/custom-wholesale/index.html +19 -19
- package/app/s/custom-work/index.html +19 -19
- package/app/s/custom-yard/index.html +19 -19
- package/app/s/section-access-control/index.html +19 -19
- package/app/s/section-account-security/index.html +19 -19
- package/app/s/section-accounting/index.html +19 -19
- package/app/s/section-activity/index.html +19 -19
- package/app/s/section-agreements/index.html +19 -19
- package/app/s/section-analytics/index.html +19 -19
- package/app/s/section-approvals/index.html +19 -19
- package/app/s/section-assets/index.html +19 -19
- package/app/s/section-billing/index.html +19 -19
- package/app/s/section-calendar/index.html +19 -19
- package/app/s/section-catalog/index.html +19 -19
- package/app/s/section-chat.assistant/index.html +19 -19
- package/app/s/section-comments/index.html +19 -19
- package/app/s/section-fields.form-customization/index.html +19 -19
- package/app/s/section-grow/index.html +19 -19
- package/app/s/section-ingestion/index.html +19 -19
- package/app/s/section-integrations/index.html +19 -19
- package/app/s/section-make/index.html +19 -19
- package/app/s/section-messages/index.html +19 -19
- package/app/s/section-more/index.html +19 -19
- package/app/s/section-operations/index.html +19 -19
- package/app/s/section-places/index.html +19 -19
- package/app/s/section-projects/index.html +19 -19
- package/app/s/section-publish/index.html +19 -19
- package/app/s/section-purchasing/index.html +19 -19
- package/app/s/section-reports.materialized/index.html +19 -19
- package/app/s/section-reports.runtime/index.html +19 -19
- package/app/s/section-sales/index.html +19 -19
- package/app/s/section-staff/index.html +19 -19
- package/app/s/section-support/index.html +19 -19
- package/app/s/section-taxonomy/index.html +19 -19
- package/app/s/section-team/index.html +19 -19
- package/app/s/section-work/index.html +19 -19
- package/dist/catalog/catalog.json +39 -39
- package/dist/core/index.js +41 -41
- package/dist/smrt-version.d.ts +1 -1
- package/dist/smrt-version.d.ts.map +1 -1
- package/dist/smrt-version.js +1 -1
- package/package.json +55 -55
- package/app/_app/immutable/chunks/6ZP_tTqa.js +0 -1
- package/app/_app/immutable/chunks/BqStfvSN.js +0 -1686
- package/app/_app/immutable/chunks/VNoQEL6R.js +0 -1
- package/app/_app/immutable/entry/start.DpUINOn1.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,B as t,Ct as n,Dt as r,Ft as i,G as a,H as o,L as s,O as c,Ot as l,P as u,Pt as d,U as f,W as p,X as m,Y as h,Z as g,_,a as v,b as y,bt as b,ct as x,ft as S,gt as C,ht as w,mt as T,pt as E,st as D,tt as O,v as k,vt as A,wt as j,xt as M,z as N}from"./DG3qFFTE.js";import"./xihTtKlq.js";import{bt as P,c as F,l as I,p as L}from"./BqStfvSN.js";import{i as R,o as z,x as B,y as V}from"./CGVkRTMI.js";import{a as ee,c as te,g as H,i as ne,l as re,m as U,o as ie,s as ae,y as W}from"./B90FTX_s.js";import{b as oe,t as G}from"./ClhMJXEf.js";import{r as K}from"./D_U_DYjx.js";import{a as q,c as J,d as Y,f as X,i as se,n as ce,o as le,p as ue,r as Z,s as de,u as fe}from"./I0OwXlFn.js";import{a as pe,c as me,i as he,l as ge,n as _e,o as ve,r as ye,s as be,t as xe,u as Se}from"./DhIzK2qb.js";function Ce(e){return e.form.kind===`field-map`}function we(e){return e.form.kind===`variant-grid`}function Te(e,t,n){let r=t.filter(t=>e.includes(t.id));return r.flatMap(e=>(e.forms??[]).filter(e=>e.model===n).map(t=>({recipeId:e.id,form:t,extensions:r.flatMap(e=>(e.extends??[]).filter(e=>e.form===t.id))})))}function Ee(e,t){return e.extensions.some(e=>(e.records??[]).some(e=>e.model===t))}function De(e){e instanceof HTMLElement&&e.querySelector(`[data-invalid] :is(input, select, textarea, button):not([type="hidden"])`)?.focus()}function Q(e){return{records:[...e.form.records,...e.extensions.flatMap(e=>e.records??[])],fields:[...e.form.fields,...e.extensions.flatMap(e=>e.fields??[])]}}function Oe(e,t){let{records:n,fields:r}=Q(e);return r.map(e=>({field:e,catalogField:Y(e,n,t),modelId:X(e,n)}))}function ke(e,t){return Object.fromEntries(Oe(e,t).map(({field:e,catalogField:t})=>[e.id,fe(e,t)]))}function Ae(e){let{records:t}=Q(e),n=t.findIndex(t=>t.model===e.form.model);return n<0?0:n}async function je(e,t,n,r){let{records:i}=Q(t),a=i[Ae(t)];if(!a)return{};let o=await e.get(n(a.model),r);return q(e,i,{[a.as]:o},n)}async function Me(e,t,n,r){let{fields:i}=Q(t),a=await je(e,t,n,r),o=ke(t,n);return{values:Object.fromEntries(i.map(e=>{let{alias:t,field:n}=de(e.to),r=a[t]?.[n];return[e.id,r===void 0?o[e.id]:r]})),rows:a}}function Ne(e,t,n,r,i={},a={}){let{records:o,fields:s}=Q(e),c=se(s,n),l=Ae(e),u=new Set;return o.map((e,o)=>{let d=le(s,e.as,n),f={...ue(e.values,c),...o===l?Object.fromEntries(Object.entries(a).map(([e,t])=>[e,J(t)])):{}},p=t(e.model),m=r===void 0?void 0:i[e.as];try{if(o===l&&r!==void 0){let t=Object.fromEntries(Object.entries(f).filter(([,e])=>ce(e)));return{op:`save`,as:e.as,model:p,id:r,values:{...d,...t}}}if(m)return{op:`save`,as:e.as,model:p,id:m.id,values:d};let t=e.match?ue(e.match,c):{},n=Object.values(t).some(e=>ce(e)&&!u.has(e.ref))?{}:t,i=Object.keys(n).length>0;return{op:`save`,as:e.as,model:p,...i?{match:n}:{},onCreate:f,values:d}}finally{u.add(e.as)}})}var $=e=>typeof e==`string`&&e!==``?e:void 0;function Pe(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e:{},n=$(t.country),r=$(t.state);return{...$(t.street1)?{street:t.street1}:{},...$(t.city)?{city:t.city}:{},...r?{province:n===`US`?`US-${r}`:r}:{},...$(t.postalCode)?{postalCode:t.postalCode}:{},...n?{country:n}:{}}}function Fe(e,t){let n=typeof t==`object`&&t&&!Array.isArray(t)?{...t}:{};for(let e of[`street1`,`city`,`state`,`postalCode`,`country`])delete n[e];let r=$(e.province);return{...n,...$(e.street)?{street1:e.street}:{},...$(e.city)?{city:e.city}:{},...r?{state:r.replace(/^US-/,``)}:{},...$(e.postalCode)?{postalCode:e.postalCode}:{},...$(e.country)?{country:e.country}:{}}}function Ie(e){return document.body.appendChild(e),e.showModal(),()=>{e.close(),e.remove()}}function Le(e){let t=[e.status,e.customerType].filter(Boolean).join(` · `);return{id:e.id,label:e.profile.name,...t?{detail:t}:{}}}function Re(e){return{id:e.id,label:e.profile.name,...e.status?{detail:e.status}:{}}}function ze(e,t){l(t,!0);let n=v(t,`value`,15,``),i=v(t,`label`,3,`Customer`),a=v(t,`required`,3,!1),o=v(t,`disabled`,3,!1),s=v(t,`createLabel`,3,`New customer`);z(e,{get name(){return t.name},get label(){return i()},get required(){return a()},get disabled(){return o()},get error(){return t.error},get onCreate(){return t.onCreate},get createLabel(){return s()},get onchange(){return t.onchange},search:async e=>(await t.search(e)).map(Le),resolve:async e=>{let n=await t.resolve(e);return n?{id:n.id,label:n.profile.name}:null},get value(){return n()},set value(e){n(e)}}),r()}function Be(e,t){l(t,!0);let n=v(t,`value`,15,``),i=v(t,`label`,3,`Vendor`),a=v(t,`required`,3,!1),o=v(t,`disabled`,3,!1),s=v(t,`createLabel`,3,`New vendor`);z(e,{get name(){return t.name},get label(){return i()},get required(){return a()},get disabled(){return o()},get error(){return t.error},get onCreate(){return t.onCreate},get createLabel(){return s()},get onchange(){return t.onchange},search:async e=>(await t.search(e)).map(Re),resolve:async e=>{let n=await t.resolve(e);return n?{id:n.id,label:n.profile.name}:null},get value(){return n()},set value(e){n(e)}}),r()}var Ve=[{name:`CustomerSelect`,selects:`@happyvertical/smrt-commerce:Customer`,kind:`customer`,component:ze},{name:`VendorSelect`,selects:`@happyvertical/smrt-commerce:Vendor`,kind:`vendor`,component:Be}];function He(e,t=Ve){return t.find(t=>t.selects===e)}var Ue=a(`<label class="plain svelte-1t0u16g"> <input type="text"/></label>`),We=a(`<dialog class="create svelte-1t0u16g"><!></dialog>`),Ge=a(`<!> <!>`,1);function Ke(a,s){l(s,!0);let d=v(s,`creatable`,3,!0),h=K(),T=n(()=>s.field.related??``),O=n(()=>P(e(T))?.model),j=n(()=>He(e(T))),F=n(()=>d()?Te(G.ids,oe,e(T)).find(Ce):void 0),I=n(()=>e(O)?.name.toLowerCase()??`record`),L=b(C(typeof s.value==`string`?s.value:``));x(()=>{let t=typeof s.value==`string`?s.value:``;t!==e(L)&&A(L,t,!0)});let R=b(!1),B=b(0);function V(){M(B),A(R,!0)}function H(e){A(R,!1),A(L,e.id,!0),s.onchange(e.id)}function U(e){A(L,e,!0),s.onchange(e===``?null:e)}var W=Ge(),q=E(W),J=t=>{var n=Ue(),r=S(n),a=w(r);_(a),i(n),D(()=>{o(r,`${s.label??``} `),k(a,`name`,s.name),a.required=s.required,y(a,e(L))}),m(`input`,a,e=>U(e.currentTarget.value)),f(t,n)},Y=t=>{let r=n(()=>e(j).component);var i=p(),a=E(i);{let t=n(()=>e(F)?V:void 0),i=n(()=>`New ${e(I)}`);u(a,()=>e(r),(n,r)=>{r(n,{get name(){return s.name},get label(){return s.label},get required(){return s.required},search:e=>ae(h,e),resolve:e=>ne(h,e),get onCreate(){return e(t)},get createLabel(){return e(i)},onchange:U,get value(){return e(L)},set value(e){A(L,e,!0)}})})}f(t,i)},X=t=>{let r=n(()=>e(j).component);var i=p(),a=E(i);{let t=n(()=>e(F)?V:void 0),i=n(()=>`New ${e(I)}`);u(a,()=>e(r),(n,r)=>{r(n,{get name(){return s.name},get label(){return s.label},get required(){return s.required},search:e=>re(h,e),resolve:e=>ie(h,e),get onCreate(){return e(t)},get createLabel(){return e(i)},onchange:U,get value(){return e(L)},set value(e){A(L,e,!0)}})})}f(t,i)},se=t=>{{let r=n(()=>e(F)?V:void 0),i=n(()=>`New ${e(I)}`);z(t,{get name(){return s.name},get label(){return s.label},get required(){return s.required},search:t=>te(h,e(O),t),resolve:t=>ee(h,e(O),t),get onCreate(){return e(r)},get createLabel(){return e(i)},onchange:U,get value(){return e(L)},set value(e){A(L,e,!0)}})}};t(q,t=>{e(O)?e(j)?.kind===`customer`?t(Y,1):e(j)?.kind===`vendor`?t(X,2):t(se,-1):t(J)});var ce=w(q,2),le=t=>{var n=We(),r=S(n);N(r,()=>e(B),t=>{ct(t,{get active(){return e(F)},onsaved:H,oncancel:()=>A(R,!1)})}),i(n),c(n,()=>Ie),D(()=>k(n,`aria-label`,`New ${e(I)}`)),g(`close`,n,()=>A(R,!1)),f(t,n)};t(ce,t=>{e(F)&&e(R)&&t(le)}),f(a,W),r()}h([`input`]);var qe=a(`<div class="percent svelte-n1ol00"><!> <span class="percent-sign svelte-n1ol00" aria-hidden="true">%</span></div>`),Je=a(`<input type="url" class="svelte-n1ol00"/>`),Ye=a(`<input type="number" step="1" class="svelte-n1ol00"/>`),Xe=a(`<input type="number" step="any" class="svelte-n1ol00"/>`),Ze=a(`<textarea rows="3" class="svelte-n1ol00"></textarea>`),Qe=a(`<input type="text" class="svelte-n1ol00"/>`),$e=a(`<!> <!>`,1),et=a(`<p class="field-error svelte-n1ol00" role="alert"> </p>`),tt=a(`<small class="svelte-n1ol00"> </small>`),nt=a(`<div class="field svelte-n1ol00"><!> <!> <!></div>`);function rt(a,s){l(s,!0);let c=v(s,`idPrefix`,3,`field`),u=v(s,`hideRequired`,3,!1),p=v(s,`creatable`,3,!0),h=n(()=>W(s.field,s.modelId)),b=n(()=>s.label??L(s.field.name)),x=n(()=>`${c()}-${s.field.name}`),C=n(()=>s.field.required&&!u()),O=n(()=>s.value===null||s.value===void 0?``:typeof s.value==`object`?JSON.stringify(s.value):String(s.value)),A=n(()=>[...e(C)||(s.field.enum??[]).includes(``)?[]:[{value:``,label:`(none)`}],...(s.field.enum??[]).map(e=>({value:e,label:e===``?`(none)`:I(e)}))]);function M(e){if(e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function N(e){try{return JSON.parse(e)}catch{return e}}let P=e=>e.slice(0,10);var F=nt(),z=S(F),ee=t=>{{let r=n(()=>s.value===!0);R(t,{get checked(){return e(r)},onchange:e=>s.onchange(e.currentTarget.checked),get label(){return e(b)}})}},te=t=>{Ke(t,{get field(){return s.field},get value(){return s.value},get onchange(){return s.onchange},get label(){return e(b)},get name(){return e(x)},get required(){return e(C)},get creatable(){return p()}})},H=t=>{pe(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},get options(){return e(A)},get value(){return e(O)},onchange:e=>s.onchange(e)})},ne=t=>{he(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},rows:4,get value(){return e(O)},onchange:e=>s.onchange(e)})},re=t=>{ye(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},type:`email`,get value(){return e(O)},onchange:e=>s.onchange(e)})},U=t=>{ve(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},get value(){return e(O)},onchange:e=>s.onchange(e)})},ie=t=>{{let r=n(()=>typeof s.value==`number`?s.value:null);me(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},currency:`USD`,min:0,get value(){return e(r)},onchange:e=>s.onchange(e)})}},ae=t=>{var r=qe(),a=S(r);{let t=n(()=>xe(s.value));be(a,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},min:0,step:.01,get value(){return e(t)},onchange:e=>s.onchange(_e(e))})}d(2),i(r),f(t,r)},oe=t=>{{let r=n(()=>P(e(O)));ge(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},includeTime:!1,get value(){return e(r)},onchange:e=>s.onchange(e?new Date(`${e}T00:00:00Z`).toISOString():``)})}},G=t=>{{let r=n(()=>Pe(s.value));Se(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},get value(){return e(r)},onchange:e=>s.onchange(Fe(e,s.value))})}},K=n=>{var r=$e(),i=E(r);B(i,{get for(){return e(x)},get label(){return e(b)},get required(){return e(C)}});var a=w(i,2),o=t=>{V(t,{get id(){return e(x)},get required(){return e(C)},get value(){return e(O)},onchange:e=>s.onchange(e.currentTarget.value)})},c=t=>{var n=Je();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),m(`input`,n,e=>s.onchange(e.currentTarget.value)),f(t,n)},l=t=>{var n=Ye();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),g(`focus`,n,e=>e.currentTarget.select()),m(`input`,n,e=>{let t=M(e.currentTarget.value);s.onchange(t===null?null:Math.trunc(t))}),f(t,n)},u=t=>{var n=Xe();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),g(`focus`,n,e=>e.currentTarget.select()),m(`input`,n,e=>s.onchange(M(e.currentTarget.value))),f(t,n)},d=t=>{var n=Ze();j(n),D(()=>{k(n,`id`,e(x)),y(n,e(O))}),m(`input`,n,e=>s.onchange(N(e.currentTarget.value))),f(t,n)},p=t=>{var n=Qe();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),m(`input`,n,e=>s.onchange(e.currentTarget.value)),f(t,n)};t(a,t=>{e(h)===`currency`?t(o):e(h)===`url`?t(c,1):e(h)===`integer`?t(l,2):e(h)===`decimal`?t(u,3):e(h)===`json`?t(d,4):t(p,-1)}),f(n,r)};t(z,t=>{e(h)===`boolean`?t(ee):e(h)===`relation`?t(te,1):e(h)===`enum`?t(H,2):e(h)===`textarea`?t(ne,3):e(h)===`email`?t(re,4):e(h)===`phone`?t(U,5):e(h)===`money`?t(ie,6):e(h)===`percent`?t(ae,7):e(h)===`datetime`?t(oe,8):e(h)===`address`?t(G,9):t(K,-1)});var q=w(z,2),J=t=>{var n=et(),r=T(n,!0);D(()=>{k(n,`id`,`${e(x)}-error`),o(r,s.error)}),f(t,n)};t(q,e=>{s.error&&e(J)});var Y=w(q,2),X=e=>{var t=tt(),n=T(t,!0);D(()=>o(n,s.help)),f(e,t)};t(Y,e=>{s.help&&e(X)}),i(F),D(()=>{k(F,`data-renderer`,e(h)),k(F,`data-invalid`,s.error?``:void 0)}),f(a,F),r()}h([`input`]);var it=a(`<p>Loading...</p>`),at=a(`<p class="error svelte-1rp3j7g" role="alert" data-error-summary=""> </p>`),ot=a(`<p class="error svelte-1rp3j7g" role="alert"> </p>`),st=a(`<form class="planner-form" novalidate=""><h3 class="svelte-1rp3j7g"> </h3> <!> <!> <!> <div class="actions svelte-1rp3j7g"><button type="submit" class="svelte-1rp3j7g">Save</button> <button type="button" class="secondary svelte-1rp3j7g">Cancel</button></div></form>`);function ct(a,c){l(c,!0);let u=K(),d=n(()=>Oe(c.active,Z).filter(({catalogField:e,modelId:t})=>!G.rows.some(n=>n.objectRef===t&&n.fieldName===e.name&&n.visibility===`hidden`))),h=b(C(ke(c.active,Z))),_=b(c.id===void 0),v=b(``),y=b(C({})),x=n(()=>e(d).map(({field:e,catalogField:t})=>({...t,name:e.id,label:e.label,required:e.required??t.required}))),k=n(()=>U(e(x),e(y))),j={};async function M(e){let t=await Me(u,c.active,Z,e);A(h,t.values,!0),j=t.rows,A(_,!0)}c.id!==void 0&&M(c.id);async function N(t){t.preventDefault();let n=t.currentTarget;if(A(v,``),A(y,H(e(x),e(h)),!0),Object.keys(e(y)).length>0)await O(),De(n);else try{let t=await u.apply(Ne(c.active,Z,e(h),c.id,j,c.preset)),n=Q(c.active).records[Ae(c.active)],r=n?t[n.as]:void 0;if(!r)throw Error(`Nothing was saved.`);c.onsaved(r)}catch(e){A(v,e instanceof Error?e.message:`Could not save.`,!0)}}var P=p(),I=E(P),L=e=>{var t=it();f(e,t)},R=r=>{var a=st(),l=S(a),u=T(l),p=w(l,2);s(p,17,()=>e(d),({field:e,catalogField:t,modelId:n})=>e.id,(t,r)=>{let i=()=>e(r).field,a=()=>e(r).catalogField,o=()=>e(r).modelId;{let r=n(()=>({...a(),required:i().required??a().required}));rt(t,{get modelId(){return o()},get field(){return e(r)},get label(){return i().label},get help(){return i().help},get idPrefix(){return c.active.form.id},get error(){return e(y)[i().id]},get value(){return e(h)[i().id]},onchange:t=>{e(h)[i().id]=t,delete e(y)[i().id]}})}});var _=w(p,2),b=t=>{var n=at(),r=T(n,!0);D(()=>o(r,e(k))),f(t,n)};t(_,t=>{e(k)&&t(b)});var x=w(_,2),C=t=>{var n=ot(),r=T(n,!0);D(()=>o(r,e(v))),f(t,n)};t(x,t=>{e(v)&&t(C)});var E=w(x,2),O=w(S(E),2);i(E),i(a),D(e=>o(u,`${c.id===void 0?`New`:`Edit`} ${e??``}`),[()=>F(c.active.form.label,c.noun,c.noun!==void 0)]),g(`submit`,a,N),m(`click`,O,function(...e){c.oncancel?.apply(this,e)}),f(r,a)};t(I,t=>{e(_)?t(R,-1):t(L)}),f(a,P),r()}h([`click`]);export{Ee as a,Te as i,rt as n,Ce as o,De as r,we as s,ct as t};
|
|
1
|
+
import{$ as e,B as t,Ct as n,Dt as r,Ft as i,G as a,H as o,L as s,O as c,Ot as l,P as u,Pt as d,U as f,W as p,X as m,Y as h,Z as g,_,a as v,b as y,bt as b,ct as x,ft as S,gt as C,ht as w,mt as T,pt as E,st as D,tt as O,v as k,vt as A,wt as j,xt as M,z as N}from"./DG3qFFTE.js";import"./xihTtKlq.js";import{bt as P,c as F,l as I,p as L}from"./DJW050J4.js";import{i as R,o as z,x as B,y as V}from"./CGVkRTMI.js";import{a as ee,c as te,g as H,i as ne,l as re,m as U,o as ie,s as ae,y as W}from"./OiIeHBBe.js";import{b as oe,t as G}from"./Cr66tvwj.js";import{r as K}from"./D_U_DYjx.js";import{a as q,c as J,d as Y,f as X,i as se,n as ce,o as le,p as ue,r as Z,s as de,u as fe}from"./Dcbo_pOT.js";import{a as pe,c as me,i as he,l as ge,n as _e,o as ve,r as ye,s as be,t as xe,u as Se}from"./CGIbVE8J.js";function Ce(e){return e.form.kind===`field-map`}function we(e){return e.form.kind===`variant-grid`}function Te(e,t,n){let r=t.filter(t=>e.includes(t.id));return r.flatMap(e=>(e.forms??[]).filter(e=>e.model===n).map(t=>({recipeId:e.id,form:t,extensions:r.flatMap(e=>(e.extends??[]).filter(e=>e.form===t.id))})))}function Ee(e,t){return e.extensions.some(e=>(e.records??[]).some(e=>e.model===t))}function De(e){e instanceof HTMLElement&&e.querySelector(`[data-invalid] :is(input, select, textarea, button):not([type="hidden"])`)?.focus()}function Q(e){return{records:[...e.form.records,...e.extensions.flatMap(e=>e.records??[])],fields:[...e.form.fields,...e.extensions.flatMap(e=>e.fields??[])]}}function Oe(e,t){let{records:n,fields:r}=Q(e);return r.map(e=>({field:e,catalogField:Y(e,n,t),modelId:X(e,n)}))}function ke(e,t){return Object.fromEntries(Oe(e,t).map(({field:e,catalogField:t})=>[e.id,fe(e,t)]))}function Ae(e){let{records:t}=Q(e),n=t.findIndex(t=>t.model===e.form.model);return n<0?0:n}async function je(e,t,n,r){let{records:i}=Q(t),a=i[Ae(t)];if(!a)return{};let o=await e.get(n(a.model),r);return q(e,i,{[a.as]:o},n)}async function Me(e,t,n,r){let{fields:i}=Q(t),a=await je(e,t,n,r),o=ke(t,n);return{values:Object.fromEntries(i.map(e=>{let{alias:t,field:n}=de(e.to),r=a[t]?.[n];return[e.id,r===void 0?o[e.id]:r]})),rows:a}}function Ne(e,t,n,r,i={},a={}){let{records:o,fields:s}=Q(e),c=se(s,n),l=Ae(e),u=new Set;return o.map((e,o)=>{let d=le(s,e.as,n),f={...ue(e.values,c),...o===l?Object.fromEntries(Object.entries(a).map(([e,t])=>[e,J(t)])):{}},p=t(e.model),m=r===void 0?void 0:i[e.as];try{if(o===l&&r!==void 0){let t=Object.fromEntries(Object.entries(f).filter(([,e])=>ce(e)));return{op:`save`,as:e.as,model:p,id:r,values:{...d,...t}}}if(m)return{op:`save`,as:e.as,model:p,id:m.id,values:d};let t=e.match?ue(e.match,c):{},n=Object.values(t).some(e=>ce(e)&&!u.has(e.ref))?{}:t,i=Object.keys(n).length>0;return{op:`save`,as:e.as,model:p,...i?{match:n}:{},onCreate:f,values:d}}finally{u.add(e.as)}})}var $=e=>typeof e==`string`&&e!==``?e:void 0;function Pe(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e:{},n=$(t.country),r=$(t.state);return{...$(t.street1)?{street:t.street1}:{},...$(t.city)?{city:t.city}:{},...r?{province:n===`US`?`US-${r}`:r}:{},...$(t.postalCode)?{postalCode:t.postalCode}:{},...n?{country:n}:{}}}function Fe(e,t){let n=typeof t==`object`&&t&&!Array.isArray(t)?{...t}:{};for(let e of[`street1`,`city`,`state`,`postalCode`,`country`])delete n[e];let r=$(e.province);return{...n,...$(e.street)?{street1:e.street}:{},...$(e.city)?{city:e.city}:{},...r?{state:r.replace(/^US-/,``)}:{},...$(e.postalCode)?{postalCode:e.postalCode}:{},...$(e.country)?{country:e.country}:{}}}function Ie(e){return document.body.appendChild(e),e.showModal(),()=>{e.close(),e.remove()}}function Le(e){let t=[e.status,e.customerType].filter(Boolean).join(` · `);return{id:e.id,label:e.profile.name,...t?{detail:t}:{}}}function Re(e){return{id:e.id,label:e.profile.name,...e.status?{detail:e.status}:{}}}function ze(e,t){l(t,!0);let n=v(t,`value`,15,``),i=v(t,`label`,3,`Customer`),a=v(t,`required`,3,!1),o=v(t,`disabled`,3,!1),s=v(t,`createLabel`,3,`New customer`);z(e,{get name(){return t.name},get label(){return i()},get required(){return a()},get disabled(){return o()},get error(){return t.error},get onCreate(){return t.onCreate},get createLabel(){return s()},get onchange(){return t.onchange},search:async e=>(await t.search(e)).map(Le),resolve:async e=>{let n=await t.resolve(e);return n?{id:n.id,label:n.profile.name}:null},get value(){return n()},set value(e){n(e)}}),r()}function Be(e,t){l(t,!0);let n=v(t,`value`,15,``),i=v(t,`label`,3,`Vendor`),a=v(t,`required`,3,!1),o=v(t,`disabled`,3,!1),s=v(t,`createLabel`,3,`New vendor`);z(e,{get name(){return t.name},get label(){return i()},get required(){return a()},get disabled(){return o()},get error(){return t.error},get onCreate(){return t.onCreate},get createLabel(){return s()},get onchange(){return t.onchange},search:async e=>(await t.search(e)).map(Re),resolve:async e=>{let n=await t.resolve(e);return n?{id:n.id,label:n.profile.name}:null},get value(){return n()},set value(e){n(e)}}),r()}var Ve=[{name:`CustomerSelect`,selects:`@happyvertical/smrt-commerce:Customer`,kind:`customer`,component:ze},{name:`VendorSelect`,selects:`@happyvertical/smrt-commerce:Vendor`,kind:`vendor`,component:Be}];function He(e,t=Ve){return t.find(t=>t.selects===e)}var Ue=a(`<label class="plain svelte-1t0u16g"> <input type="text"/></label>`),We=a(`<dialog class="create svelte-1t0u16g"><!></dialog>`),Ge=a(`<!> <!>`,1);function Ke(a,s){l(s,!0);let d=v(s,`creatable`,3,!0),h=K(),T=n(()=>s.field.related??``),O=n(()=>P(e(T))?.model),j=n(()=>He(e(T))),F=n(()=>d()?Te(G.ids,oe,e(T)).find(Ce):void 0),I=n(()=>e(O)?.name.toLowerCase()??`record`),L=b(C(typeof s.value==`string`?s.value:``));x(()=>{let t=typeof s.value==`string`?s.value:``;t!==e(L)&&A(L,t,!0)});let R=b(!1),B=b(0);function V(){M(B),A(R,!0)}function H(e){A(R,!1),A(L,e.id,!0),s.onchange(e.id)}function U(e){A(L,e,!0),s.onchange(e===``?null:e)}var W=Ge(),q=E(W),J=t=>{var n=Ue(),r=S(n),a=w(r);_(a),i(n),D(()=>{o(r,`${s.label??``} `),k(a,`name`,s.name),a.required=s.required,y(a,e(L))}),m(`input`,a,e=>U(e.currentTarget.value)),f(t,n)},Y=t=>{let r=n(()=>e(j).component);var i=p(),a=E(i);{let t=n(()=>e(F)?V:void 0),i=n(()=>`New ${e(I)}`);u(a,()=>e(r),(n,r)=>{r(n,{get name(){return s.name},get label(){return s.label},get required(){return s.required},search:e=>ae(h,e),resolve:e=>ne(h,e),get onCreate(){return e(t)},get createLabel(){return e(i)},onchange:U,get value(){return e(L)},set value(e){A(L,e,!0)}})})}f(t,i)},X=t=>{let r=n(()=>e(j).component);var i=p(),a=E(i);{let t=n(()=>e(F)?V:void 0),i=n(()=>`New ${e(I)}`);u(a,()=>e(r),(n,r)=>{r(n,{get name(){return s.name},get label(){return s.label},get required(){return s.required},search:e=>re(h,e),resolve:e=>ie(h,e),get onCreate(){return e(t)},get createLabel(){return e(i)},onchange:U,get value(){return e(L)},set value(e){A(L,e,!0)}})})}f(t,i)},se=t=>{{let r=n(()=>e(F)?V:void 0),i=n(()=>`New ${e(I)}`);z(t,{get name(){return s.name},get label(){return s.label},get required(){return s.required},search:t=>te(h,e(O),t),resolve:t=>ee(h,e(O),t),get onCreate(){return e(r)},get createLabel(){return e(i)},onchange:U,get value(){return e(L)},set value(e){A(L,e,!0)}})}};t(q,t=>{e(O)?e(j)?.kind===`customer`?t(Y,1):e(j)?.kind===`vendor`?t(X,2):t(se,-1):t(J)});var ce=w(q,2),le=t=>{var n=We(),r=S(n);N(r,()=>e(B),t=>{ct(t,{get active(){return e(F)},onsaved:H,oncancel:()=>A(R,!1)})}),i(n),c(n,()=>Ie),D(()=>k(n,`aria-label`,`New ${e(I)}`)),g(`close`,n,()=>A(R,!1)),f(t,n)};t(ce,t=>{e(F)&&e(R)&&t(le)}),f(a,W),r()}h([`input`]);var qe=a(`<div class="percent svelte-n1ol00"><!> <span class="percent-sign svelte-n1ol00" aria-hidden="true">%</span></div>`),Je=a(`<input type="url" class="svelte-n1ol00"/>`),Ye=a(`<input type="number" step="1" class="svelte-n1ol00"/>`),Xe=a(`<input type="number" step="any" class="svelte-n1ol00"/>`),Ze=a(`<textarea rows="3" class="svelte-n1ol00"></textarea>`),Qe=a(`<input type="text" class="svelte-n1ol00"/>`),$e=a(`<!> <!>`,1),et=a(`<p class="field-error svelte-n1ol00" role="alert"> </p>`),tt=a(`<small class="svelte-n1ol00"> </small>`),nt=a(`<div class="field svelte-n1ol00"><!> <!> <!></div>`);function rt(a,s){l(s,!0);let c=v(s,`idPrefix`,3,`field`),u=v(s,`hideRequired`,3,!1),p=v(s,`creatable`,3,!0),h=n(()=>W(s.field,s.modelId)),b=n(()=>s.label??L(s.field.name)),x=n(()=>`${c()}-${s.field.name}`),C=n(()=>s.field.required&&!u()),O=n(()=>s.value===null||s.value===void 0?``:typeof s.value==`object`?JSON.stringify(s.value):String(s.value)),A=n(()=>[...e(C)||(s.field.enum??[]).includes(``)?[]:[{value:``,label:`(none)`}],...(s.field.enum??[]).map(e=>({value:e,label:e===``?`(none)`:I(e)}))]);function M(e){if(e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function N(e){try{return JSON.parse(e)}catch{return e}}let P=e=>e.slice(0,10);var F=nt(),z=S(F),ee=t=>{{let r=n(()=>s.value===!0);R(t,{get checked(){return e(r)},onchange:e=>s.onchange(e.currentTarget.checked),get label(){return e(b)}})}},te=t=>{Ke(t,{get field(){return s.field},get value(){return s.value},get onchange(){return s.onchange},get label(){return e(b)},get name(){return e(x)},get required(){return e(C)},get creatable(){return p()}})},H=t=>{pe(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},get options(){return e(A)},get value(){return e(O)},onchange:e=>s.onchange(e)})},ne=t=>{he(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},rows:4,get value(){return e(O)},onchange:e=>s.onchange(e)})},re=t=>{ye(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},type:`email`,get value(){return e(O)},onchange:e=>s.onchange(e)})},U=t=>{ve(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},get value(){return e(O)},onchange:e=>s.onchange(e)})},ie=t=>{{let r=n(()=>typeof s.value==`number`?s.value:null);me(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},currency:`USD`,min:0,get value(){return e(r)},onchange:e=>s.onchange(e)})}},ae=t=>{var r=qe(),a=S(r);{let t=n(()=>xe(s.value));be(a,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},min:0,step:.01,get value(){return e(t)},onchange:e=>s.onchange(_e(e))})}d(2),i(r),f(t,r)},oe=t=>{{let r=n(()=>P(e(O)));ge(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},includeTime:!1,get value(){return e(r)},onchange:e=>s.onchange(e?new Date(`${e}T00:00:00Z`).toISOString():``)})}},G=t=>{{let r=n(()=>Pe(s.value));Se(t,{get name(){return e(x)},get label(){return e(b)},get required(){return e(C)},get value(){return e(r)},onchange:e=>s.onchange(Fe(e,s.value))})}},K=n=>{var r=$e(),i=E(r);B(i,{get for(){return e(x)},get label(){return e(b)},get required(){return e(C)}});var a=w(i,2),o=t=>{V(t,{get id(){return e(x)},get required(){return e(C)},get value(){return e(O)},onchange:e=>s.onchange(e.currentTarget.value)})},c=t=>{var n=Je();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),m(`input`,n,e=>s.onchange(e.currentTarget.value)),f(t,n)},l=t=>{var n=Ye();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),g(`focus`,n,e=>e.currentTarget.select()),m(`input`,n,e=>{let t=M(e.currentTarget.value);s.onchange(t===null?null:Math.trunc(t))}),f(t,n)},u=t=>{var n=Xe();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),g(`focus`,n,e=>e.currentTarget.select()),m(`input`,n,e=>s.onchange(M(e.currentTarget.value))),f(t,n)},d=t=>{var n=Ze();j(n),D(()=>{k(n,`id`,e(x)),y(n,e(O))}),m(`input`,n,e=>s.onchange(N(e.currentTarget.value))),f(t,n)},p=t=>{var n=Qe();_(n),D(()=>{k(n,`id`,e(x)),n.required=e(C),y(n,e(O))}),m(`input`,n,e=>s.onchange(e.currentTarget.value)),f(t,n)};t(a,t=>{e(h)===`currency`?t(o):e(h)===`url`?t(c,1):e(h)===`integer`?t(l,2):e(h)===`decimal`?t(u,3):e(h)===`json`?t(d,4):t(p,-1)}),f(n,r)};t(z,t=>{e(h)===`boolean`?t(ee):e(h)===`relation`?t(te,1):e(h)===`enum`?t(H,2):e(h)===`textarea`?t(ne,3):e(h)===`email`?t(re,4):e(h)===`phone`?t(U,5):e(h)===`money`?t(ie,6):e(h)===`percent`?t(ae,7):e(h)===`datetime`?t(oe,8):e(h)===`address`?t(G,9):t(K,-1)});var q=w(z,2),J=t=>{var n=et(),r=T(n,!0);D(()=>{k(n,`id`,`${e(x)}-error`),o(r,s.error)}),f(t,n)};t(q,e=>{s.error&&e(J)});var Y=w(q,2),X=e=>{var t=tt(),n=T(t,!0);D(()=>o(n,s.help)),f(e,t)};t(Y,e=>{s.help&&e(X)}),i(F),D(()=>{k(F,`data-renderer`,e(h)),k(F,`data-invalid`,s.error?``:void 0)}),f(a,F),r()}h([`input`]);var it=a(`<p>Loading...</p>`),at=a(`<p class="error svelte-1rp3j7g" role="alert" data-error-summary=""> </p>`),ot=a(`<p class="error svelte-1rp3j7g" role="alert"> </p>`),st=a(`<form class="planner-form" novalidate=""><h3 class="svelte-1rp3j7g"> </h3> <!> <!> <!> <div class="actions svelte-1rp3j7g"><button type="submit" class="svelte-1rp3j7g">Save</button> <button type="button" class="secondary svelte-1rp3j7g">Cancel</button></div></form>`);function ct(a,c){l(c,!0);let u=K(),d=n(()=>Oe(c.active,Z).filter(({catalogField:e,modelId:t})=>!G.rows.some(n=>n.objectRef===t&&n.fieldName===e.name&&n.visibility===`hidden`))),h=b(C(ke(c.active,Z))),_=b(c.id===void 0),v=b(``),y=b(C({})),x=n(()=>e(d).map(({field:e,catalogField:t})=>({...t,name:e.id,label:e.label,required:e.required??t.required}))),k=n(()=>U(e(x),e(y))),j={};async function M(e){let t=await Me(u,c.active,Z,e);A(h,t.values,!0),j=t.rows,A(_,!0)}c.id!==void 0&&M(c.id);async function N(t){t.preventDefault();let n=t.currentTarget;if(A(v,``),A(y,H(e(x),e(h)),!0),Object.keys(e(y)).length>0)await O(),De(n);else try{let t=await u.apply(Ne(c.active,Z,e(h),c.id,j,c.preset)),n=Q(c.active).records[Ae(c.active)],r=n?t[n.as]:void 0;if(!r)throw Error(`Nothing was saved.`);c.onsaved(r)}catch(e){A(v,e instanceof Error?e.message:`Could not save.`,!0)}}var P=p(),I=E(P),L=e=>{var t=it();f(e,t)},R=r=>{var a=st(),l=S(a),u=T(l),p=w(l,2);s(p,17,()=>e(d),({field:e,catalogField:t,modelId:n})=>e.id,(t,r)=>{let i=()=>e(r).field,a=()=>e(r).catalogField,o=()=>e(r).modelId;{let r=n(()=>({...a(),required:i().required??a().required}));rt(t,{get modelId(){return o()},get field(){return e(r)},get label(){return i().label},get help(){return i().help},get idPrefix(){return c.active.form.id},get error(){return e(y)[i().id]},get value(){return e(h)[i().id]},onchange:t=>{e(h)[i().id]=t,delete e(y)[i().id]}})}});var _=w(p,2),b=t=>{var n=at(),r=T(n,!0);D(()=>o(r,e(k))),f(t,n)};t(_,t=>{e(k)&&t(b)});var x=w(_,2),C=t=>{var n=ot(),r=T(n,!0);D(()=>o(r,e(v))),f(t,n)};t(x,t=>{e(v)&&t(C)});var E=w(x,2),O=w(S(E),2);i(E),i(a),D(e=>o(u,`${c.id===void 0?`New`:`Edit`} ${e??``}`),[()=>F(c.active.form.label,c.noun,c.noun!==void 0)]),g(`submit`,a,N),m(`click`,O,function(...e){c.oncancel?.apply(this,e)}),f(r,a)};t(I,t=>{e(_)?t(R,-1):t(L)}),f(a,P),r()}h([`click`]);export{Ee as a,Te as i,rt as n,Ce as o,De as r,we as s,ct as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,B as t,Ct as n,D as r,Dt as i,E as a,Ft as o,G as s,H as c,J as l,L as u,Ot as d,Pt as f,U as p,W as m,X as h,Y as g,a as _,b as v,bt as y,ct as b,ft as x,ht as S,mt as C,pt as w,st as T,v as E,vt as D}from"./DG3qFFTE.js";import"./xihTtKlq.js";import{n as O}from"./DK8Blf1Y.js";import{n as k}from"./v8gneLl4.js";import{b as A,i as j,x as M}from"./CGVkRTMI.js";import{A as N,D as P,E as F,O as I,T as L,_ as R,i as z,k as B,n as V,r as ee,t as H,v as U,w as te}from"./
|
|
1
|
+
import{$ as e,B as t,Ct as n,D as r,Dt as i,E as a,Ft as o,G as s,H as c,J as l,L as u,Ot as d,Pt as f,U as p,W as m,X as h,Y as g,a as _,b as v,bt as y,ct as b,ft as x,ht as S,mt as C,pt as w,st as T,v as E,vt as D}from"./DG3qFFTE.js";import"./xihTtKlq.js";import{n as O}from"./DK8Blf1Y.js";import{n as k}from"./v8gneLl4.js";import{b as A,i as j,x as M}from"./CGVkRTMI.js";import{A as N,D as P,E as F,O as I,T as L,_ as R,i as z,k as B,n as V,r as ee,t as H,v as U,w as te}from"./Bx9R-SRZ.js";import{nt as W}from"./Cr66tvwj.js";var ne=s(`<p class="notice svelte-19u3zp7" role="status"> </p>`),G=s(`<option> </option>`),re=s(`<label class="svelte-19u3zp7">Assistant mode <!></label> <p class="meta svelte-19u3zp7">Changing modes happens only when you choose it here.</p>`,1),ie=s(`<p class="status svelte-19u3zp7">Inference off</p> <p class="meta svelte-19u3zp7">Build, edit, validate and export your cookbook without a model. No
|
|
2
2
|
provider is contacted and no browser model is downloaded.</p>`,1),ae=s(`<p class="status svelte-19u3zp7">Server</p> <p class="meta svelte-19u3zp7">This site's server answers the assistant. What you type, and a short
|
|
3
3
|
summary of your plan, is sent to it. Nothing is downloaded.</p>`,1),oe=s(`<p class="meta svelte-19u3zp7">A key is saved for another address, so it is not used here. Paste it again for this address.</p>`),se=s(`<div class="field svelte-19u3zp7"><!> <!></div> <!> <p class="meta svelte-19u3zp7"> <button class="link svelte-19u3zp7" type="button">Forget the key</button></p>`,1),ce=s(`<p class="meta svelte-19u3zp7"><strong>Browser access.</strong> </p>`),le=s(`<p> </p>`),ue=s(`<p class="status svelte-19u3zp7" role="status"> </p>`),de=s(`<label class="svelte-19u3zp7">Model provider <!></label> <div class="field svelte-19u3zp7"><!> <!></div> <div class="field svelte-19u3zp7"><!> <!></div> <!> <!> <p class="meta svelte-19u3zp7">What you type, and a short summary of your plan, is sent to this
|
|
4
4
|
endpoint.</p> <!> <!> <div class="actions svelte-19u3zp7"><!> <!></div>`,1),fe=s(`<p role="status" class="svelte-19u3zp7">This browser has no WebGPU, which the model needs. Try a recent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,B as t,Ct as n,Dt as r,E as i,Ft as a,G as o,H as s,J as c,L as l,Ot as u,Pt as d,U as f,W as p,Y as m,a as h,bt as ee,d as g,ft as _,ht as v,mt as y,n as b,nt as te,o as x,pt as S,q as C,r as w,st as T,tt as ne,v as E,vt as re}from"./DG3qFFTE.js";import"./xihTtKlq.js";import"./BLUInGBV.js";import{t as ie}from"./Bq8E3AWP.js";import"./
|
|
1
|
+
import{$ as e,B as t,Ct as n,Dt as r,E as i,Ft as a,G as o,H as s,J as c,L as l,Ot as u,Pt as d,U as f,W as p,Y as m,a as h,bt as ee,d as g,ft as _,ht as v,mt as y,n as b,nt as te,o as x,pt as S,q as C,r as w,st as T,tt as ne,v as E,vt as re}from"./DG3qFFTE.js";import"./xihTtKlq.js";import"./BLUInGBV.js";import{t as ie}from"./Bq8E3AWP.js";import"./DJW050J4.js";import{n as D}from"./DK8Blf1Y.js";import{D as O,T as k,f as ae,h as oe}from"./HQUuGK-d.js";import{n as se}from"./v8gneLl4.js";import{o as A,u as j}from"./DIE02RSm.js";import{i as M}from"./CGVkRTMI.js";var N=new Set([`$$slots`,`$$events`,`$$legacy`]);function P(e,t){u(t,!0);let n=O(),i=x(t,N),a=null;w(()=>{a=n.registerFocusTool(i)}),b(()=>{a?.()}),r()}var ce=o(`<!> <!>`,1),le=o(`<span class="smrt-shell-layout-editor__muted svelte-xzk327"> </span>`),ue=o(`<div class="smrt-shell-layout-editor__row svelte-xzk327"><!></div>`),de=o(`<strong> </strong>`),fe=o(`<!> <!> <!> <!>`,1),F=o(`<span> </span> <!>`,1),I=o(`<div class="smrt-shell-layout-editor__preview"><h3 class="svelte-xzk327"> </h3> <div class="smrt-shell-layout-editor__preview-frame svelte-xzk327" role="group" inert=""><!></div></div>`),L=o(`<section class="smrt-shell-layout-editor svelte-xzk327" data-smrt-component="ShellLayoutEditor"><header class="svelte-xzk327"><div><h2 class="svelte-xzk327"> </h2> <p class="svelte-xzk327"> </p></div> <!></header> <fieldset class="smrt-shell-layout-editor__panels svelte-xzk327"><legend class="svelte-xzk327"> </legend> <!></fieldset> <div class="smrt-shell-layout-editor__body svelte-xzk327"><div class="smrt-shell-layout-editor__nav"><div class="smrt-shell-layout-editor__nav-head svelte-xzk327"><h3 class="svelte-xzk327"> </h3> <!></div> <!></div> <!></div></section>`);function R(o,m){let b=C();u(m,!0);let x=h(m,`preview`,3,!0),{t:w}=ie(),O=te(()=>m.controller??j()),N=`${b}-heading`,P=n(()=>O.sections),R=n(()=>O.panels),z=n(()=>O.applied),B=n(()=>e(P).map(e=>({id:e.id,label:e.heading??w(k[`ui.shell_layout_editor.top_level`]),fixed:e.group===null,root:e.group===null,hidden:e.hidden,custom:e.custom,titleVisible:e.titleVisible,count:e.items.length}))),V=n(()=>e(P).flatMap(e=>e.items.map(t=>({id:t.id,containerId:e.id,label:t.label}))));function H(e,t){t?O.show(e):O.hide(e)}let U=ee(void 0);function pe(t,n){let r=n.currentTarget;O.renameSection(t,r.value),r.value=e(B).find(e=>e.id===t)?.label??``}async function me(){let t=O.createSection(w(k[`ui.shell_layout_editor.new_section_label`]));if(!t)return;await ne();let n=e(U)?.querySelector(`input[data-section-name="${CSS.escape(t)}"]`);n?.focus(),n?.select()}function he(e,t,n){n>0&&!globalThis.confirm?.(w(k[`ui.shell_layout_editor.delete_confirm`],{label:t}))||O.deleteSection(e)}function ge(e){O.moveItem(e.item.id,e.target.containerId,e.target.index)}function _e(e){O.moveSection(e.container.id,e.target)}var W=L(),G=_(W),K=_(G),q=_(K),ve=y(q,!0),ye=v(q,2),be=y(ye,!0);a(K);var xe=v(K,2);{let t=n(()=>!O.customized);D(xe,{variant:`secondary`,size:`sm`,get disabled(){return e(t)},onclick:()=>O.reset(),children:(e,t)=>{d();var n=c();T(e=>s(n,e),[()=>w(k[`ui.shell_layout_editor.reset`])]),f(e,n)},$$slots:{default:!0}})}a(G);var J=v(G,2),Y=_(J),Se=y(Y,!0),Ce=v(Y,2);l(Ce,17,()=>e(R),e=>e.edge,(r,i)=>{var o=ue(),c=_(o),l=t=>{var r=ce(),a=S(r);{let t=n(()=>w(k[`ui.shell_layout_editor.show_panel`],{panel:e(i).label}));M(a,{interaction:!1,get checked(){return e(i).visible},get label(){return e(t)},onchange:t=>O.setPanel(e(i).edge,{visible:t.currentTarget.checked})})}var o=v(a,2);{let t=n(()=>e(i).initial===`expanded`),r=n(()=>!e(i).visible),a=n(()=>w(k[`ui.shell_layout_editor.start_expanded`],{panel:e(i).label}));M(o,{interaction:!1,get checked(){return e(t)},get disabled(){return e(r)},get label(){return e(a)},onchange:t=>O.setPanel(e(i).edge,{initial:t.currentTarget.checked?`expanded`:`collapsed`})})}f(t,r)},u=t=>{var n=le(),r=y(n,!0);T(e=>s(r,e),[()=>w(k[`ui.shell_layout_editor.panel_unavailable`],{panel:e(i).label})]),f(t,n)};t(c,t=>{e(i).available?t(l):t(u,-1)}),a(o),T(()=>E(o,`data-edge`,e(i).edge)),f(r,o)}),a(J);var X=v(J,2),Z=_(X),Q=_(Z),$=_(Q),we=y($,!0),Te=v($,2);D(Te,{variant:`secondary`,size:`sm`,onclick:me,children:(e,t)=>{d();var n=c();T(e=>s(n,e),[()=>w(k[`ui.shell_layout_editor.new_section`])]),f(e,n)},$$slots:{default:!0}}),a(Q);var Ee=v(Q,2);{let r=(r,i)=>{let a=()=>(i?.()).container,o=n(()=>e(B).find(e=>e.id===a().id));var c=p(),l=S(c),u=e=>{var t=de(),n=y(t,!0);T(()=>s(n,a().label)),f(e,t)},d=r=>{var i=fe(),s=S(i);{let t=n(()=>w(k[`ui.shell_layout_editor.section_name`],{label:a().label}));se(s,{class:`smrt-shell-layout-editor__name`,interaction:!1,get"data-section-name"(){return a().id},get"aria-label"(){return e(t)},get value(){return a().label},onchange:e=>pe(a().id,e)})}var c=v(s,2);{let t=n(()=>e(o)?.hidden?`eyeOff`:`eye`),r=n(()=>!e(o)?.hidden),i=n(()=>w(k[`ui.shell_layout_editor.show_entry`],{label:a().label}));A(c,{get icon(){return e(t)},get pressed(){return e(r)},get label(){return e(i)},onclick:()=>H(a().id,!!e(o)?.hidden)})}var l=v(c,2);{let t=n(()=>e(o)?.titleVisible===!1?`headingOff`:`heading`),r=n(()=>e(o)?.titleVisible??!0),i=n(()=>w(k[`ui.shell_layout_editor.show_title_for`],{label:a().label}));A(l,{get icon(){return e(t)},get pressed(){return e(r)},get label(){return e(i)},onclick:()=>O.setSectionTitleVisible(a().id,!(e(o)?.titleVisible??!0))})}var u=v(l,2),d=t=>{{let r=n(()=>w(k[`ui.shell_layout_editor.delete_section`],{label:a().label}));A(t,{icon:`trash`,get label(){return e(r)},onclick:()=>he(a().id,a().label,e(o).count)})}};t(u,t=>{e(o)?.custom&&t(d)}),f(r,i)};t(l,t=>{e(o)?.root?t(u):t(d,-1)}),f(r,c)},a=(t,r)=>{let a=()=>(r?.()).item,o=()=>(r?.()).container,c=n(()=>O.isHidden(a().id));var l=F(),u=S(l);let d;var p=y(u,!0),m=v(u,2);{let t=n(()=>e(c)?`eyeOff`:`eye`),r=n(()=>!e(c)),i=n(()=>w(k[`ui.shell_layout_editor.show_entry`],{label:a().label}));A(m,{get icon(){return e(t)},get pressed(){return e(r)},get label(){return e(i)},onclick:()=>H(a().id,e(c))})}T(e=>{d=i(u,1,`smrt-shell-layout-editor__label svelte-xzk327`,null,d,{"smrt-shell-layout-editor__muted":e}),s(p,a().label)},[()=>e(c)||O.isHidden(o().id)]),f(t,l)},o=n(()=>w(k[`ui.shell_layout_editor.sortable_label`]));oe(Ee,{get containers(){return e(B)},get items(){return e(V)},get label(){return e(o)},reorderContainers:!0,onmove:ge,oncontainermove:_e,containerHeader:r,item:a,$$slots:{containerHeader:!0,item:!0}})}a(Z);var De=v(Z,2),Oe=t=>{var r=I(),i=_(r),o=y(i,!0),c=v(i,2),l=_(c);{let t=n(()=>w(k[`ui.shell_layout_editor.preview_label`]));ae(l,{get items(){return e(z).nav},get groups(){return e(z).groups},get iconComponent(){return m.iconComponent},get"aria-label"(){return e(t)}})}a(c),a(r),T((e,t)=>{s(o,e),E(c,`aria-label`,t)},[()=>w(k[`ui.shell_layout_editor.preview`]),()=>w(k[`ui.shell_layout_editor.preview_label`])]),f(t,r)};t(De,e=>{x()&&e(Oe)}),a(X),a(W),g(W,e=>re(U,e),()=>e(U)),T((e,t,n,r)=>{E(W,`aria-labelledby`,N),E(q,`id`,N),s(ve,e),s(be,t),s(Se,n),s(we,r)},[()=>w(k[`ui.shell_layout_editor.heading`]),()=>w(k[`ui.shell_layout_editor.description`]),()=>w(k[`ui.shell_layout_editor.panels`]),()=>w(k[`ui.shell_layout_editor.navigation`])]),f(o,W),r()}m([`click`]);export{P as n,R as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./DG3qFFTE.js";import"./xihTtKlq.js";import"./DJW050J4.js";import"./HQUuGK-d.js";import"./v8gneLl4.js";import"./DN8ism_E.js";import"./CGVkRTMI.js";function e(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}export{e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,D as n,E as r,J as i,M as a,N as o,P as s,Q as c,S as l,T as u,Y as d,Z as f,at as p,bt as m,ct as h,dt as g,et as _,ft as ee,gt as v,it as y,j as te,k as b,lt as x,mt as ne,rt as re,st as S,ut as C,w,x as T,y as E,z as ie}from"./BqStfvSN.js";var D=e=>{let t=m(e);if(!t)throw Error(`The catalog has no model ${e}`);return t.model};function O(e){return String(e??``).toUpperCase().replace(/[^A-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}var k=/\{([A-Za-z_][\w]*\.[A-Za-z_][\w]*)(?:\|(slug))?\}/g;function A(e,t){return e.replace(k,(e,n,r)=>{let i=t[n],a=i==null?``:String(i);return r===`slug`?O(a):a})}function j(e,t,n=e=>e){return typeof e==`string`?A(e,t):typeof e==`object`&&e?{ref:n(e.ref),...e.field?{field:e.field}:{}}:e}function M(e,t,n){return Object.fromEntries(Object.entries(e??{}).map(([e,r])=>[e,j(r,t,n)]))}function N(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:null}function P(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=F(e.to);return r.alias===t?[[r.field,N(n[e.id])]]:[]}))}function F(e){let t=e.indexOf(`.`);if(t<1||t===e.length-1)throw Error(`A form field maps to "alias.field", got "${e}"`);return{alias:e.slice(0,t),field:e.slice(t+1)}}function I(e,t,n){let{alias:r,field:i}=F(e.to),a=t.find(e=>e.as===r);if(!a)throw Error(`Form field ${e.id} maps to unknown ${r}`);let o=n(a.model).fields.find(e=>e.name===i);if(!o)throw Error(`${a.model} has no field ${i} (form field ${e.id})`);return o}function L(e,t){let{alias:n}=F(e.to),r=t.find(e=>e.as===n);if(!r)throw Error(`Form field ${e.id} maps to unknown ${n}`);return r.model}function R(e,t){return e.default===void 0?t.default===void 0?t.type===`text`?``:null:t.default:e.default}function z(e,t){return Object.fromEntries(e.map(e=>[e.to,t[e.id]]))}var B=(e,t)=>e===t;async function V(e,t,n,r){let i={...n};for(let n of t){if(n.as in i)continue;if(!n.match){i[n.as]=void 0;continue}let t={},a=!0;for(let[e,r]of Object.entries(n.match))if(typeof r==`object`&&r){let n=i[r.ref];n||(a=!1),t[e]=r.field?n?.[r.field]:n?.id}else t[e]=r;i[n.as]=a?(await e.list(r(n.model))).find(e=>Object.entries(t).every(([t,n])=>B(e[t],n))):void 0}return i}var H=4,U=(e,t)=>e.fields.some(e=>e.name===t);function W(e,r,i,o,s){let c=l(n(`${o}:${e.id}:${i.id}`)),d=U(e,`debit`)&&U(e,`credit`),f=d?2*(1+Math.floor(c()*2)):1+Math.floor(c()*H),p=_(e),m=1e3*(1+Math.floor(c()*90));return Array.from({length:f},(l,f)=>{let h=n(`${i.id}:${f}`)%997,g={...u(e,h,o,s),id:w(`${e.id}:${i.id}:${f}`),[r]:i.id};if(U(e,`sortOrder`)&&(g.sortOrder=f),p){let n=e.fields.find(e=>e.related?.endsWith(`:Product`)&&e.name in g),r=a(),{products:o}=r,l=n?o[t(n,{modelId:e.id,index:h,rows:s})%o.length]:o[h%o.length],u=b(h);u?(U(e,`description`)&&(g.description=u.description),g.unitPrice=u.price,n&&(g[n.name]=``)):n&&l&&(U(e,`description`)&&(g.description=l.name),g.unitPrice=l.price);let[d,p]=u?.quantity??l?.quantity??r.lineQuantity??[1,5],m=d+Math.floor(c()*(p-d+1));U(e,`quantity`)&&(g.quantity=m),Object.assign(g,ae(e,i,f,m,Number(g.unitPrice??0))),g.amount=C(g)}if(d){let e=f%2==0;g.debit=e?m/100:0,g.credit=e?0:m/100}return g})}function G(e){return n(`discount:${e.id}`)%3==0}function K(e,t){return Math.round(e*t/1e3)*100}function q(e,t){return t>0&&n(`tax-override:${e.id}:${t}`)%7==0}function J(e,t,r=o().currency){let i=n(`tax-override-kind:${e.id}:${t}`)%4,a=x(r);if(a&&i<2)return a;let s=i%2==0?`exempt`:`zero-rated`;return S.find(e=>e.kind===s)}function ae(e,t,r,i,a){let o={},s=r===0&&G(t),c=n(`discount-kind:${t.id}`)%2==0;U(e,`discountType`)&&(o.discountType=s?c?`percent`:`amount`:`none`),U(e,`discountRate`)&&(o.discountRate=s&&c?`10`:null),U(e,`discount`)&&(o.discount=s&&!(c&&U(e,`discountType`))?K(i,a):0),!U(e,`discountType`)&&o.discount&&(o.discountType=`amount`);let l=q(t,r)?J(t,r):void 0;return U(e,`taxMode`)&&(o.taxMode=l?`override`:`inherit`),U(e,`taxCodeId`)&&(o.taxCodeId=l?.id??null),o}function oe(e,t){let n={...e,...t};return`discount`in t&&!(`discountType`in t)&&n.discountType===`amount`&&(n.discountType=`percent`,n.discountRate=`10`,n.discount=0),`discountRate`in t&&n.discountType===`percent`&&(n.discountType=`none`,n.discountRate=null,n.discount=0),n}var se=[`@happyvertical/smrt-commerce:Order`,`@happyvertical/smrt-commerce:Invoice`],Y=2500;function ce(e,t,n){n===2&&se.includes(t.id)&&typeof e.subtotal==`number`&&typeof e.totalAmount==`number`&&(t.fields.some(e=>e.name===`status`&&e.enum?.includes(`draft`))&&(e.status=`draft`),e.subtotal+=Y,e.totalAmount+=Y)}function le(e,t,n,r){if(!n.length||!n.every(e=>`unitPrice`in e))return[...n];let i=y(t,e,n,r);return Object.assign(e,i.row),i.lines}var X=e=>typeof e==`number`&&Number.isFinite(e)?e:0,ue=e=>e.status!==`draft`&&e.status!==`cancelled`&&X(e.totalAmount)>0;function de(e,t,r,i){let a=new Map(r.map(e=>[e.id,X(e.totalAmount)])),o=[];for(let s of t){if(s.status!==`completed`){s.status!==`refunded`&&(s.paidAt=null);continue}let t=l(n(`${i}:alloc:${s.id}`)),c=r.filter(e=>ue(e)&&e.customerId===s.customerId&&(a.get(e.id)??0)>0).slice(0,t()<.3?2:1);if(c.length===0)continue;let d=c.map((e,n)=>{let r=a.get(e.id)??0,i=n>0||t()<.6?r:Math.min(r,Math.max(100,Math.round(r*(.3+t()*.4)/100)*100));return a.set(e.id,r-i),{inv:e,part:i}}),f=Math.max(...d.map(({inv:e})=>Date.parse(String(e.issueDate)))),p=new Date(Math.max(f,Math.min(f+(1+Math.floor(t()*20))*E,T))).toISOString();s.amount=d.reduce((e,t)=>e+t.part,0),s.paidAt=p,`contractId`in s&&d[0]?.inv.contractId&&(s.contractId=d[0].inv.contractId);for(let{inv:t,part:n}of d)o.push({...u(e.model,o.length,i),id:w(`${e.model.id}:${s.id}:${t.id}`),[e.paymentFk]:s.id,[e.invoiceFk]:t.id,amount:n,allocatedAt:p})}return o}function Z(e){return typeof e==`object`&&!!e&&typeof e.ref==`string`}var Q=`smrt-planner:data:v6:`,fe=`@happyvertical/smrt-commerce:TaxCode`,pe=`@happyvertical/smrt-commerce:TaxComponent`,me=[`taxable`,`zero-rated`,`exempt`,`out-of-scope`];function he(e,t){return!!e.fields.find(e=>e.name===`status`)?.enum?.includes(`draft`)&&typeof t.status==`string`&&t.status!==``&&t.status!==`draft`}var $=`${Q}_created`;function ge(e){if(e)try{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r?.startsWith(`smrt-planner:data:v6:`)&&t.push(r)}for(let n of t)e.removeItem(n)}catch{}}function _e(t={}){let n=t.seed??1,a=t.rowsPerModel??8,l=new Set(t.empty??[]),u=new Map,m=new Set,b=t.storage??null,x=e=>`${Q}${e.id}`,S=e=>{if(b)try{let t=b.getItem(x(e));if(t===null)return;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(e=>typeof e==`object`&&!!e&&typeof e.id==`string`))return n}catch{}},C=0;if(b)try{C=Number(b.getItem($))||0}catch{C=0}let E=new Map,D=e=>{let n=E.get(e);return n||(n=t.children?.links(e)??[],E.set(e,n)),n},O,k,A=e=>{if(!O){O=new Map;for(let e of t.children?.models??[])for(let t of D(e.id)){let n=O.get(t.model.id)??[];n.push({parent:e,fk:t.fk}),O.set(t.model.id,n)}k=new Map(O);for(let[e,t]of O){let n=e.slice(e.lastIndexOf(`:`)+1).toLowerCase(),r=t.find(e=>n.startsWith(e.fk.replace(/Id$/,``).toLowerCase()))?.fk??t[0]?.fk;O.set(e,t.filter(e=>e.fk===r))}}return O.get(e)??[]},j=t=>{if(!e(t))return;A(t.id);let n=k?.get(t.id)??[],r=d(t)?.name,a=i(t)?.name,o=n.find(e=>e.fk===r)?.parent,s=n.find(e=>e.fk===a)?.parent;return o&&s&&r&&a?{model:t,paymentFk:r,invoiceFk:a,payment:o,invoice:s}:void 0},M=(n,r)=>{if(!p(n))return r;let i=D(n.id).find(t=>e(t.model)),a=i&&j(i.model);if(!i||!a)return r;let o=new Map(P(a.payment).map(e=>[e.id,e])),s=P(i.model).filter(e=>e[i.fk]===r.id&&o.get(String(e[a.paymentFk]))?.status===`completed`).map(e=>({amount:Number(e.amount??0),at:String(e.allocatedAt??``)})),c=re(r,s,(t.now??(()=>T))()),l={...r,amountPaid:c.amountPaid,status:c.status};return n.fields.some(e=>e.name===`paidDate`)&&(l.paidDate=c.paidDate),l},N=(e,t)=>{let n=P(e),r=n.findIndex(e=>e.id===t);r>=0&&(n[r]=M(e,n[r]))},P=e=>{let i=u.get(e.id);if(i)return i;let o=S(e);if(o){u.set(e.id,o);for(let t of D(e.id))P(t.model);return o}let s=l.has(e.id)?void 0:t.samples?.[e.id];if(s){let t=[];return u.set(e.id,t),t.push(...s.make(s.from.map(P),n)),t}let c=j(e),d=c?[]:A(e.id),f=l.has(e.id)||d.length||c?[]:r(e,te(e.id,a),n,a);u.set(e.id,f);for(let t of D(e.id))P(t.model);if(c&&!l.has(e.id)){for(let e of D(c.invoice.id))_(e.model)&&P(e.model);let e=P(c.invoice);f.push(...de(c,P(c.payment),e,n)),e.forEach((t,n)=>{e[n]=M(c.invoice,t)})}if(!l.has(e.id))for(let{parent:r,fk:i}of d){let o=t.defaults?.(e)??{};P(r).forEach((t,s)=>{let c=W(e,i,t,n,a).map(e=>oe(e,o));_(e)?(f.push(...le(t,r,c,L(r,t))),ce(t,r,s)):f.push(...c)})}return f},F=new Map((t.children?.models??[]).map(e=>[e.id,e])),I=e=>{let t=ee(e),n=F.get(fe),r=F.get(pe),i=n?P(n):[];if(!i.length)return t;let a=new Map(t.flatMap(e=>e.components.map(e=>[e.id,e])));for(let e of r?P(r):[])a.set(e.id,{id:e.id,key:e.id,name:String(e.name??``),percent:String(e.percent??`0`),recoverable:e.recoverable===!0});let o=i.map(e=>{let t=[];try{t=JSON.parse(String(e.componentsJson??`[]`))}catch{t=[]}let n=(Array.isArray(t)?t:[]).flatMap(e=>{let t=e&&typeof e==`object`?a.get(String(e.taxComponentId)):void 0;return t?[t]:[]}),r=me.includes(String(e.kind))?e.kind:`taxable`,i=[`sales`,`purchases`,`both`].includes(String(e.appliesTo))?e.appliesTo:`both`;return{id:e.id,code:String(e.code??``),name:String(e.name??``),kind:r,appliesTo:i,active:e.active!==!1,components:n}}),s=new Map(o.map(e=>[e.id,e]));if(t.some(e=>s.has(e.id))){let n=h(e);return[...t.filter(e=>s.has(e.id)||e.id===n.id).map(e=>s.get(e.id)??e),...o.filter(e=>!t.some(t=>t.id===e.id))]}return[...t,...o]},L=(e,t)=>{let n=o(),r=s()??.05,i=I(r),a=e.fields.find(e=>e.name===`customerId`&&e.related),l=a?.related?F.get(a.related):void 0,d=l?P(l).find(e=>e.id===t.customerId):void 0,p=e=>{for(let[t,n]of u){if(!t.endsWith(`:Product`))continue;let r=n.find(t=>t.id===e);if(r)return r}},m=e=>typeof e==`string`&&e?e:null;return{lineAmountType:f(t,n.pricesIncludeTax?`inclusive`:`exclusive`),roundingScope:c(t,n.taxRounding),currency:g(t.currency,g(n.currency)),codes:i,appDefaultCodeId:h(r).id,customerTaxExempt:d?.taxExempt===!0,partyCodeId:m(d?.defaultTaxCodeId),productCodeOf:e=>m(p(e)?.defaultSalesTaxCodeId)}},R=e=>{if(!b)return;let t=e=>{let t=j(e);return t?[t.payment,t.invoice]:[]},n=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent),...t(e),...D(e.id).flatMap(e=>t(e.model))];try{for(let e of n){let t=u.get(e.id);t&&b.setItem(x(e),JSON.stringify(t))}b.setItem($,String(C))}catch{}},z=e=>D(e.id).find(t=>_(t.model)&&A(t.model.id).some(n=>n.parent.id===e.id&&n.fk===t.fk)),B=(e,t,n=!1)=>{let r=z(e);if(!r)return!1;let i=P(e),a=i.findIndex(e=>e.id===t);if(a<0)return!1;let o=P(r.model),s=o.filter(e=>e[r.fk]===t),c=i[a];if(he(e,c)){if(n)throw new v(`FROZEN_DOCUMENT`,`This ${e.name.toLowerCase()} has been issued, so its lines can no longer change.`);return!0}let l=y(e,c,s,L(e,c));i[a]=l.row;for(let e of l.lines){let t=o.findIndex(t=>t.id===e.id);t>=0&&(o[t]=e)}return!0},V=(e,t)=>{let n=t;if(z(e)&&(B(e,t.id),n=P(e).find(e=>e.id===t.id)??n),_(e)){let r=A(e.id).some(({parent:e,fk:n})=>B(e,t[n],!0)),i=P(e),a=i.findIndex(e=>e.id===t.id);if(!r&&a>=0){let e=o(),n=s()??.05;i[a]=ne([t],{lineAmountType:e.pricesIncludeTax?`inclusive`:`exclusive`,roundingScope:e.taxRounding,currency:g(e.currency),codes:I(n),appDefaultCodeId:h(n).id}).lines[0]}n=P(e).find(e=>e.id===t.id)??n}p(e)&&(N(e,t.id),n=P(e).find(e=>e.id===t.id)??n);let r=j(e);r&&N(r.invoice,t[r.invoiceFk]);for(let n of D(e.id)){let r=j(n.model);if(r&&r.payment.id===e.id)for(let e of P(n.model))e[r.paymentFk]===t.id&&N(r.invoice,e[r.invoiceFk])}return n},H=e=>{let t=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent)];return new Map(t.map(e=>[e.id,P(e).map(e=>({...e}))]))},U=e=>{for(let[t,n]of e){let e=u.get(t);e&&e.splice(0,e.length,...n)}},G=(e,n)=>({...n,...t.defaults?.(e)??{}}),K=e=>w(`${e.id}:new:${n}:${C++}`),q=(e,t)=>Object.entries(t).every(([t,n])=>e[t]===n);return{async list(e){return P(e).map(t=>G(e,t))},async listWhere(e,t,n){return P(e).filter(e=>String(e[t]??``)===n).map(t=>G(e,t))},async get(e,t){let n=P(e).find(e=>e.id===t);return n?G(e,n):void 0},async create(e,n){let r={...t.defaults?.(e)??{},...n,id:K(e)},i=H(e);P(e).push(r);let a;try{a=V(e,r)}catch(e){throw U(i),C--,e}return R(e),{...a}},async update(e,t,n){let r=P(e),i=r.findIndex(e=>e.id===t);if(i<0)return;let a=H(e),o=r[i],s={...o,...n,id:t};r[i]=s;let c;try{if(c=V(e,s),_(e))for(let{parent:t,fk:n}of A(e.id))o[n]!==s[n]&&B(t,o[n],!0)}catch(e){throw U(a),e}return R(e),{...c}},async delete(e,t){let n=P(e),r=n.findIndex(e=>e.id===t);if(r<0)return!1;let i=H(e),[a]=n.splice(r,1);try{let t=j(e);t&&a&&N(t.invoice,a[t.invoiceFk]);for(let{parent:t,fk:n}of A(e.id))_(e)&&a&&B(t,a[n],!0)}catch(e){throw U(i),e}return R(e),!0},reset(){ie(),u.clear(),C=0,ge(b);for(let e of[...m])e()},onReset(e){return m.add(e),()=>{m.delete(e)}},async apply(e){let n=new Map,r=C,i=new Map,a=e=>{i.set(e.id,e);let t=P(e);return n.has(e.id)||n.set(e.id,t.map(e=>({...e}))),t},o={},s=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!Z(t))return[e,t];let n=o[t.ref];if(!n)throw Error(`Unknown record reference ${t.ref}`);return[e,t.field?n[t.field]:n.id]}));try{for(let n of e){let e=a(n.model),r=s(n.match);if(n.op===`delete`){let t=e.filter(e=>n.id===void 0?q(e,r):e.id===n.id);if(n.id===void 0&&Object.keys(r).length===0)throw Error(`A delete needs an id or a match`);for(let n of t)e.splice(e.indexOf(n),1);continue}let i=s(n.values),c=-1;if(n.id!==void 0){if(c=e.findIndex(e=>e.id===n.id),c<0)throw Error(`No ${n.model.name} with id ${n.id}`)}else Object.keys(r).length>0&&(c=e.findIndex(e=>q(e,r)));let l;if(c>=0){let t=e[c];l={...t,...i,id:t.id},e[c]=l}else l={...t.defaults?.(n.model)??{},...r,...s(n.onCreate),...i,id:K(n.model)},e.push(l);n.as&&(o[n.as]={...l})}}catch(e){for(let[e,t]of n)u.set(e,t);throw C=r,e}for(let e of i.values())R(e);return o}}}export{V as a,N as c,I as d,L as f,z as i,O as l,Z as n,P as o,M as p,D as r,F as s,_e as t,R as u};
|
|
1
|
+
import{$ as e,A as t,D as n,E as r,J as i,M as a,N as o,P as s,Q as c,S as l,T as u,Y as d,Z as f,at as p,bt as m,ct as h,dt as g,et as _,ft as ee,gt as v,it as y,j as te,k as b,lt as x,mt as ne,rt as re,st as S,ut as C,w,x as T,y as E,z as ie}from"./DJW050J4.js";var D=e=>{let t=m(e);if(!t)throw Error(`The catalog has no model ${e}`);return t.model};function O(e){return String(e??``).toUpperCase().replace(/[^A-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}var k=/\{([A-Za-z_][\w]*\.[A-Za-z_][\w]*)(?:\|(slug))?\}/g;function A(e,t){return e.replace(k,(e,n,r)=>{let i=t[n],a=i==null?``:String(i);return r===`slug`?O(a):a})}function j(e,t,n=e=>e){return typeof e==`string`?A(e,t):typeof e==`object`&&e?{ref:n(e.ref),...e.field?{field:e.field}:{}}:e}function M(e,t,n){return Object.fromEntries(Object.entries(e??{}).map(([e,r])=>[e,j(r,t,n)]))}function N(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:null}function P(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=F(e.to);return r.alias===t?[[r.field,N(n[e.id])]]:[]}))}function F(e){let t=e.indexOf(`.`);if(t<1||t===e.length-1)throw Error(`A form field maps to "alias.field", got "${e}"`);return{alias:e.slice(0,t),field:e.slice(t+1)}}function I(e,t,n){let{alias:r,field:i}=F(e.to),a=t.find(e=>e.as===r);if(!a)throw Error(`Form field ${e.id} maps to unknown ${r}`);let o=n(a.model).fields.find(e=>e.name===i);if(!o)throw Error(`${a.model} has no field ${i} (form field ${e.id})`);return o}function L(e,t){let{alias:n}=F(e.to),r=t.find(e=>e.as===n);if(!r)throw Error(`Form field ${e.id} maps to unknown ${n}`);return r.model}function R(e,t){return e.default===void 0?t.default===void 0?t.type===`text`?``:null:t.default:e.default}function z(e,t){return Object.fromEntries(e.map(e=>[e.to,t[e.id]]))}var B=(e,t)=>e===t;async function V(e,t,n,r){let i={...n};for(let n of t){if(n.as in i)continue;if(!n.match){i[n.as]=void 0;continue}let t={},a=!0;for(let[e,r]of Object.entries(n.match))if(typeof r==`object`&&r){let n=i[r.ref];n||(a=!1),t[e]=r.field?n?.[r.field]:n?.id}else t[e]=r;i[n.as]=a?(await e.list(r(n.model))).find(e=>Object.entries(t).every(([t,n])=>B(e[t],n))):void 0}return i}var H=4,U=(e,t)=>e.fields.some(e=>e.name===t);function W(e,r,i,o,s){let c=l(n(`${o}:${e.id}:${i.id}`)),d=U(e,`debit`)&&U(e,`credit`),f=d?2*(1+Math.floor(c()*2)):1+Math.floor(c()*H),p=_(e),m=1e3*(1+Math.floor(c()*90));return Array.from({length:f},(l,f)=>{let h=n(`${i.id}:${f}`)%997,g={...u(e,h,o,s),id:w(`${e.id}:${i.id}:${f}`),[r]:i.id};if(U(e,`sortOrder`)&&(g.sortOrder=f),p){let n=e.fields.find(e=>e.related?.endsWith(`:Product`)&&e.name in g),r=a(),{products:o}=r,l=n?o[t(n,{modelId:e.id,index:h,rows:s})%o.length]:o[h%o.length],u=b(h);u?(U(e,`description`)&&(g.description=u.description),g.unitPrice=u.price,n&&(g[n.name]=``)):n&&l&&(U(e,`description`)&&(g.description=l.name),g.unitPrice=l.price);let[d,p]=u?.quantity??l?.quantity??r.lineQuantity??[1,5],m=d+Math.floor(c()*(p-d+1));U(e,`quantity`)&&(g.quantity=m),Object.assign(g,ae(e,i,f,m,Number(g.unitPrice??0))),g.amount=C(g)}if(d){let e=f%2==0;g.debit=e?m/100:0,g.credit=e?0:m/100}return g})}function G(e){return n(`discount:${e.id}`)%3==0}function K(e,t){return Math.round(e*t/1e3)*100}function q(e,t){return t>0&&n(`tax-override:${e.id}:${t}`)%7==0}function J(e,t,r=o().currency){let i=n(`tax-override-kind:${e.id}:${t}`)%4,a=x(r);if(a&&i<2)return a;let s=i%2==0?`exempt`:`zero-rated`;return S.find(e=>e.kind===s)}function ae(e,t,r,i,a){let o={},s=r===0&&G(t),c=n(`discount-kind:${t.id}`)%2==0;U(e,`discountType`)&&(o.discountType=s?c?`percent`:`amount`:`none`),U(e,`discountRate`)&&(o.discountRate=s&&c?`10`:null),U(e,`discount`)&&(o.discount=s&&!(c&&U(e,`discountType`))?K(i,a):0),!U(e,`discountType`)&&o.discount&&(o.discountType=`amount`);let l=q(t,r)?J(t,r):void 0;return U(e,`taxMode`)&&(o.taxMode=l?`override`:`inherit`),U(e,`taxCodeId`)&&(o.taxCodeId=l?.id??null),o}function oe(e,t){let n={...e,...t};return`discount`in t&&!(`discountType`in t)&&n.discountType===`amount`&&(n.discountType=`percent`,n.discountRate=`10`,n.discount=0),`discountRate`in t&&n.discountType===`percent`&&(n.discountType=`none`,n.discountRate=null,n.discount=0),n}var se=[`@happyvertical/smrt-commerce:Order`,`@happyvertical/smrt-commerce:Invoice`],Y=2500;function ce(e,t,n){n===2&&se.includes(t.id)&&typeof e.subtotal==`number`&&typeof e.totalAmount==`number`&&(t.fields.some(e=>e.name===`status`&&e.enum?.includes(`draft`))&&(e.status=`draft`),e.subtotal+=Y,e.totalAmount+=Y)}function le(e,t,n,r){if(!n.length||!n.every(e=>`unitPrice`in e))return[...n];let i=y(t,e,n,r);return Object.assign(e,i.row),i.lines}var X=e=>typeof e==`number`&&Number.isFinite(e)?e:0,ue=e=>e.status!==`draft`&&e.status!==`cancelled`&&X(e.totalAmount)>0;function de(e,t,r,i){let a=new Map(r.map(e=>[e.id,X(e.totalAmount)])),o=[];for(let s of t){if(s.status!==`completed`){s.status!==`refunded`&&(s.paidAt=null);continue}let t=l(n(`${i}:alloc:${s.id}`)),c=r.filter(e=>ue(e)&&e.customerId===s.customerId&&(a.get(e.id)??0)>0).slice(0,t()<.3?2:1);if(c.length===0)continue;let d=c.map((e,n)=>{let r=a.get(e.id)??0,i=n>0||t()<.6?r:Math.min(r,Math.max(100,Math.round(r*(.3+t()*.4)/100)*100));return a.set(e.id,r-i),{inv:e,part:i}}),f=Math.max(...d.map(({inv:e})=>Date.parse(String(e.issueDate)))),p=new Date(Math.max(f,Math.min(f+(1+Math.floor(t()*20))*E,T))).toISOString();s.amount=d.reduce((e,t)=>e+t.part,0),s.paidAt=p,`contractId`in s&&d[0]?.inv.contractId&&(s.contractId=d[0].inv.contractId);for(let{inv:t,part:n}of d)o.push({...u(e.model,o.length,i),id:w(`${e.model.id}:${s.id}:${t.id}`),[e.paymentFk]:s.id,[e.invoiceFk]:t.id,amount:n,allocatedAt:p})}return o}function Z(e){return typeof e==`object`&&!!e&&typeof e.ref==`string`}var Q=`smrt-planner:data:v6:`,fe=`@happyvertical/smrt-commerce:TaxCode`,pe=`@happyvertical/smrt-commerce:TaxComponent`,me=[`taxable`,`zero-rated`,`exempt`,`out-of-scope`];function he(e,t){return!!e.fields.find(e=>e.name===`status`)?.enum?.includes(`draft`)&&typeof t.status==`string`&&t.status!==``&&t.status!==`draft`}var $=`${Q}_created`;function ge(e){if(e)try{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r?.startsWith(`smrt-planner:data:v6:`)&&t.push(r)}for(let n of t)e.removeItem(n)}catch{}}function _e(t={}){let n=t.seed??1,a=t.rowsPerModel??8,l=new Set(t.empty??[]),u=new Map,m=new Set,b=t.storage??null,x=e=>`${Q}${e.id}`,S=e=>{if(b)try{let t=b.getItem(x(e));if(t===null)return;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(e=>typeof e==`object`&&!!e&&typeof e.id==`string`))return n}catch{}},C=0;if(b)try{C=Number(b.getItem($))||0}catch{C=0}let E=new Map,D=e=>{let n=E.get(e);return n||(n=t.children?.links(e)??[],E.set(e,n)),n},O,k,A=e=>{if(!O){O=new Map;for(let e of t.children?.models??[])for(let t of D(e.id)){let n=O.get(t.model.id)??[];n.push({parent:e,fk:t.fk}),O.set(t.model.id,n)}k=new Map(O);for(let[e,t]of O){let n=e.slice(e.lastIndexOf(`:`)+1).toLowerCase(),r=t.find(e=>n.startsWith(e.fk.replace(/Id$/,``).toLowerCase()))?.fk??t[0]?.fk;O.set(e,t.filter(e=>e.fk===r))}}return O.get(e)??[]},j=t=>{if(!e(t))return;A(t.id);let n=k?.get(t.id)??[],r=d(t)?.name,a=i(t)?.name,o=n.find(e=>e.fk===r)?.parent,s=n.find(e=>e.fk===a)?.parent;return o&&s&&r&&a?{model:t,paymentFk:r,invoiceFk:a,payment:o,invoice:s}:void 0},M=(n,r)=>{if(!p(n))return r;let i=D(n.id).find(t=>e(t.model)),a=i&&j(i.model);if(!i||!a)return r;let o=new Map(P(a.payment).map(e=>[e.id,e])),s=P(i.model).filter(e=>e[i.fk]===r.id&&o.get(String(e[a.paymentFk]))?.status===`completed`).map(e=>({amount:Number(e.amount??0),at:String(e.allocatedAt??``)})),c=re(r,s,(t.now??(()=>T))()),l={...r,amountPaid:c.amountPaid,status:c.status};return n.fields.some(e=>e.name===`paidDate`)&&(l.paidDate=c.paidDate),l},N=(e,t)=>{let n=P(e),r=n.findIndex(e=>e.id===t);r>=0&&(n[r]=M(e,n[r]))},P=e=>{let i=u.get(e.id);if(i)return i;let o=S(e);if(o){u.set(e.id,o);for(let t of D(e.id))P(t.model);return o}let s=l.has(e.id)?void 0:t.samples?.[e.id];if(s){let t=[];return u.set(e.id,t),t.push(...s.make(s.from.map(P),n)),t}let c=j(e),d=c?[]:A(e.id),f=l.has(e.id)||d.length||c?[]:r(e,te(e.id,a),n,a);u.set(e.id,f);for(let t of D(e.id))P(t.model);if(c&&!l.has(e.id)){for(let e of D(c.invoice.id))_(e.model)&&P(e.model);let e=P(c.invoice);f.push(...de(c,P(c.payment),e,n)),e.forEach((t,n)=>{e[n]=M(c.invoice,t)})}if(!l.has(e.id))for(let{parent:r,fk:i}of d){let o=t.defaults?.(e)??{};P(r).forEach((t,s)=>{let c=W(e,i,t,n,a).map(e=>oe(e,o));_(e)?(f.push(...le(t,r,c,L(r,t))),ce(t,r,s)):f.push(...c)})}return f},F=new Map((t.children?.models??[]).map(e=>[e.id,e])),I=e=>{let t=ee(e),n=F.get(fe),r=F.get(pe),i=n?P(n):[];if(!i.length)return t;let a=new Map(t.flatMap(e=>e.components.map(e=>[e.id,e])));for(let e of r?P(r):[])a.set(e.id,{id:e.id,key:e.id,name:String(e.name??``),percent:String(e.percent??`0`),recoverable:e.recoverable===!0});let o=i.map(e=>{let t=[];try{t=JSON.parse(String(e.componentsJson??`[]`))}catch{t=[]}let n=(Array.isArray(t)?t:[]).flatMap(e=>{let t=e&&typeof e==`object`?a.get(String(e.taxComponentId)):void 0;return t?[t]:[]}),r=me.includes(String(e.kind))?e.kind:`taxable`,i=[`sales`,`purchases`,`both`].includes(String(e.appliesTo))?e.appliesTo:`both`;return{id:e.id,code:String(e.code??``),name:String(e.name??``),kind:r,appliesTo:i,active:e.active!==!1,components:n}}),s=new Map(o.map(e=>[e.id,e]));if(t.some(e=>s.has(e.id))){let n=h(e);return[...t.filter(e=>s.has(e.id)||e.id===n.id).map(e=>s.get(e.id)??e),...o.filter(e=>!t.some(t=>t.id===e.id))]}return[...t,...o]},L=(e,t)=>{let n=o(),r=s()??.05,i=I(r),a=e.fields.find(e=>e.name===`customerId`&&e.related),l=a?.related?F.get(a.related):void 0,d=l?P(l).find(e=>e.id===t.customerId):void 0,p=e=>{for(let[t,n]of u){if(!t.endsWith(`:Product`))continue;let r=n.find(t=>t.id===e);if(r)return r}},m=e=>typeof e==`string`&&e?e:null;return{lineAmountType:f(t,n.pricesIncludeTax?`inclusive`:`exclusive`),roundingScope:c(t,n.taxRounding),currency:g(t.currency,g(n.currency)),codes:i,appDefaultCodeId:h(r).id,customerTaxExempt:d?.taxExempt===!0,partyCodeId:m(d?.defaultTaxCodeId),productCodeOf:e=>m(p(e)?.defaultSalesTaxCodeId)}},R=e=>{if(!b)return;let t=e=>{let t=j(e);return t?[t.payment,t.invoice]:[]},n=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent),...t(e),...D(e.id).flatMap(e=>t(e.model))];try{for(let e of n){let t=u.get(e.id);t&&b.setItem(x(e),JSON.stringify(t))}b.setItem($,String(C))}catch{}},z=e=>D(e.id).find(t=>_(t.model)&&A(t.model.id).some(n=>n.parent.id===e.id&&n.fk===t.fk)),B=(e,t,n=!1)=>{let r=z(e);if(!r)return!1;let i=P(e),a=i.findIndex(e=>e.id===t);if(a<0)return!1;let o=P(r.model),s=o.filter(e=>e[r.fk]===t),c=i[a];if(he(e,c)){if(n)throw new v(`FROZEN_DOCUMENT`,`This ${e.name.toLowerCase()} has been issued, so its lines can no longer change.`);return!0}let l=y(e,c,s,L(e,c));i[a]=l.row;for(let e of l.lines){let t=o.findIndex(t=>t.id===e.id);t>=0&&(o[t]=e)}return!0},V=(e,t)=>{let n=t;if(z(e)&&(B(e,t.id),n=P(e).find(e=>e.id===t.id)??n),_(e)){let r=A(e.id).some(({parent:e,fk:n})=>B(e,t[n],!0)),i=P(e),a=i.findIndex(e=>e.id===t.id);if(!r&&a>=0){let e=o(),n=s()??.05;i[a]=ne([t],{lineAmountType:e.pricesIncludeTax?`inclusive`:`exclusive`,roundingScope:e.taxRounding,currency:g(e.currency),codes:I(n),appDefaultCodeId:h(n).id}).lines[0]}n=P(e).find(e=>e.id===t.id)??n}p(e)&&(N(e,t.id),n=P(e).find(e=>e.id===t.id)??n);let r=j(e);r&&N(r.invoice,t[r.invoiceFk]);for(let n of D(e.id)){let r=j(n.model);if(r&&r.payment.id===e.id)for(let e of P(n.model))e[r.paymentFk]===t.id&&N(r.invoice,e[r.invoiceFk])}return n},H=e=>{let t=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent)];return new Map(t.map(e=>[e.id,P(e).map(e=>({...e}))]))},U=e=>{for(let[t,n]of e){let e=u.get(t);e&&e.splice(0,e.length,...n)}},G=(e,n)=>({...n,...t.defaults?.(e)??{}}),K=e=>w(`${e.id}:new:${n}:${C++}`),q=(e,t)=>Object.entries(t).every(([t,n])=>e[t]===n);return{async list(e){return P(e).map(t=>G(e,t))},async listWhere(e,t,n){return P(e).filter(e=>String(e[t]??``)===n).map(t=>G(e,t))},async get(e,t){let n=P(e).find(e=>e.id===t);return n?G(e,n):void 0},async create(e,n){let r={...t.defaults?.(e)??{},...n,id:K(e)},i=H(e);P(e).push(r);let a;try{a=V(e,r)}catch(e){throw U(i),C--,e}return R(e),{...a}},async update(e,t,n){let r=P(e),i=r.findIndex(e=>e.id===t);if(i<0)return;let a=H(e),o=r[i],s={...o,...n,id:t};r[i]=s;let c;try{if(c=V(e,s),_(e))for(let{parent:t,fk:n}of A(e.id))o[n]!==s[n]&&B(t,o[n],!0)}catch(e){throw U(a),e}return R(e),{...c}},async delete(e,t){let n=P(e),r=n.findIndex(e=>e.id===t);if(r<0)return!1;let i=H(e),[a]=n.splice(r,1);try{let t=j(e);t&&a&&N(t.invoice,a[t.invoiceFk]);for(let{parent:t,fk:n}of A(e.id))_(e)&&a&&B(t,a[n],!0)}catch(e){throw U(i),e}return R(e),!0},reset(){ie(),u.clear(),C=0,ge(b);for(let e of[...m])e()},onReset(e){return m.add(e),()=>{m.delete(e)}},async apply(e){let n=new Map,r=C,i=new Map,a=e=>{i.set(e.id,e);let t=P(e);return n.has(e.id)||n.set(e.id,t.map(e=>({...e}))),t},o={},s=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!Z(t))return[e,t];let n=o[t.ref];if(!n)throw Error(`Unknown record reference ${t.ref}`);return[e,t.field?n[t.field]:n.id]}));try{for(let n of e){let e=a(n.model),r=s(n.match);if(n.op===`delete`){let t=e.filter(e=>n.id===void 0?q(e,r):e.id===n.id);if(n.id===void 0&&Object.keys(r).length===0)throw Error(`A delete needs an id or a match`);for(let n of t)e.splice(e.indexOf(n),1);continue}let i=s(n.values),c=-1;if(n.id!==void 0){if(c=e.findIndex(e=>e.id===n.id),c<0)throw Error(`No ${n.model.name} with id ${n.id}`)}else Object.keys(r).length>0&&(c=e.findIndex(e=>q(e,r)));let l;if(c>=0){let t=e[c];l={...t,...i,id:t.id},e[c]=l}else l={...t.defaults?.(n.model)??{},...r,...s(n.onCreate),...i,id:K(n.model)},e.push(l);n.as&&(o[n.as]={...l})}}catch(e){for(let[e,t]of n)u.set(e,t);throw C=r,e}for(let e of i.values())R(e);return o}}}export{V as a,N as c,I as d,L as f,z as i,O as l,Z as n,P as o,M as p,D as r,F as s,_e as t,R as u};
|