@action-state-group/capsule-viewer 0.25.0 → 0.26.1

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.
@@ -0,0 +1,3164 @@
1
+ // @ts-nocheck
2
+ // GENERATED by `go generate` in go/receipt (go/receipt/internal/writer) from
3
+ // go/receipt/receipt_unilateral.js and the four manifests. Do not edit by hand.
4
+ const root = {};
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ // The deal receipt modules, in the page: capsuleviewer.receipt.unilateral/v0,
7
+ // capsuleviewer.receipt.seller/v0 and capsuleviewer.receipt.bilateral/v0 (the
8
+ // x-deal-v0 modules, each with a Python twin) and capsuleviewer.receipt.deal/v1
9
+ // (the x-deal-v1 sealed report, no twin), as module-slot scripts (agent-action-capsule's presentation contract, as
10
+ // capsulectl.deal-view/v0 and capsuleviewer.history/v0 are).
11
+ //
12
+ // This file is the source of the four scripts the manifests pin
13
+ // (go/receipt/receipt_unilateral.js, receipt_seller.js, receipt_bilateral.js and
14
+ // receipt_deal.js; capsule-viewer#383 made go/receipt the one receipt renderer).
15
+ // `go generate` in go/receipt writes each one from
16
+ // it, filling the lines marked "@generated": the module it registers, its
17
+ // manifest, the words (compiled in from the example English wording pack,
18
+ // go/receipt/wording-en.json, whose id and sha256 the page names in L2) and the
19
+ // kit stylesheet (src/capsule_viewer/static/kit.css, pinned by the manifest's style_sha256).
20
+ // Each script carries the whole of this file and registers exactly one
21
+ // module: the page builder puts one script in the page per module it chose,
22
+ // and a script never registers a module the builder did not choose.
23
+ //
24
+ // It is the twin of the Python modules (capsule_viewer.receipt: model.py,
25
+ // module.py, seller.py, bilateral.py, role.py, frozen at 0.25.0), which stay the test oracle:
26
+ // js-tests/receipt_parity.test.js renders every receipt fixture both ways
27
+ // and fails on any difference in the model or the rendered result. Names
28
+ // below follow the Python ones, so a reader can hold the two side by side.
29
+ //
30
+ // It imports nothing and reads no wording pack. UTF-8, SHA-256 and JCS are
31
+ // computed here, synchronously. It never verifies: canRender and buildModel
32
+ // read the VerifiedBundleContext the page's runtime built (one verification
33
+ // run); the gate and every disclosure state arrive decided. Committed words
34
+ // are shown only when their opening recomputes to the sealed commitment (the
35
+ // presentation contract's sha256-jcs-nonce256, section 7.2). render draws
36
+ // into the host's L0, L1 and L2 with createElement and textContent: nothing
37
+ // from the bundle is parsed as HTML.
38
+ //
39
+ // What the page's runtime does not hand a module, and how this reads it:
40
+ // * the page's audience: resolution matched the manifest's audiences against
41
+ // it, and the module is not told which it was. A copy is shown as the
42
+ // audience its own sealed report names (a keep copy carries the PRIVATE
43
+ // banner, any other copy never does), never relabelled. The Python twin is
44
+ // given the page's audience and also declines a copy cut for another one.
45
+ // * the verifier's witness and countersignature results beyond the context:
46
+ // the page's verifier reports no witness result (so the witness rung says
47
+ // none was reported to this page), and each countersignature as it reports
48
+ // it.
49
+ // * a composition's carried copies as contexts of their own: the bilateral
50
+ // module asks the page's runtime to verify each carried copy
51
+ // (EvidenceGraph.buildVerifiedBundleContext), as the Python twin reads each
52
+ // copy's own verifier report. Nothing of one copy fills another.
53
+ (function (root) {
54
+ "use strict";
55
+ var KIND = "unilateral"; // @generated KIND
56
+ var MANIFEST = { "spec_version": "aac.presentation-manifest/v0", "id": "capsuleviewer.receipt.unilateral/v0", "presentation_api": "aac.presentation-api/v0", "runtime_min": "0.1.0", "trust_class": "trusted-executable", "requires": { "bundle_kind": "evidence-bundle/v2", "extensions": { "required": ["x-deal-v0"] } }, "forbids": { "profiles": ["spec_version:report/v1", "spec_version:evaluation-summary/v1", "result_version:evidence-result-v0"], "extensions": ["composed/v1", "x-history-selection/v0", "x-deal-seller/v0"] }, "audiences": ["keep", "counterparty", "adjudicator", "*"], "formats": ["html"], "fallback": false, "priority": 1, "executable": { "carrier": "module-slot", "script_sha256": "0000000000000000000000000000000000000000000000000000000000000000", "style_sha256": ["1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"] } }; // @generated MANIFEST
57
+ var WORDS = { "page.title": "Deal report", "badge.demo": "DEMO", "banner.private.label": "PRIVATE", "banner.private.text": "This is your own copy of this deal report, with everything this page shows. Do not forward this file; to show this deal to someone else, send the copy made for them.", "banner.shared.label": "Shared copy", "banner.shared.text": "The report owner's own record of this deal, included in this report because their \"Receipts in the settlement report\" setting is on. It is not the counterparty's copy.", "summary.standalone": "This report's text is carried in the file outside the log. capsulectl verify reported its signature check as: {status}. This page did not check the signature itself.", "depth.l1": "Why: what was asked, proposed, approved and done", "depth.l2": "Verify: the records, their places in the log and the checks", "l0.deal_type": "Deal", "l0.item": "Item", "l0.amount": "Amount", "l0.state": "Where it stands", "l0.state.missing": "not stated", "deal_type.purchase": "Purchase", "deal_type.sale": "Sale", "deal_type.booking": "Booking", "deal_type.subscription": "Subscription", "state.open": "Open", "state.cancelled": "Cancelled", "state.closed": "Closed", "shared.counterparty": "A shared copy for the other party. Left out of this copy: {kinds}.", "shared.adjudicator": "A shared copy for an adjudicator. Left out of this copy: {kinds}.", "rung.witness_verified": "Witness receipt checked: the verifier checked a witness receipt in this file. Which steps that receipt covers is not shown here; capsulectl verify reports it. It does not confirm what the agent did.", "rung.unwitnessed": "No outside time stamp: this copy carries no witness receipt.", "rung.witness_failed": "A witness receipt is in this file and did not verify.", "countersign.none": "Not countersigned in this copy. A signature from the other party, if there is one, is in their own copy.", "countersign.some": "Countersignatures, as the verifier reported them: {statuses}.", "section.authorized": "What you asked", "section.authorized.report": "What the owner asked", "section.proposed": "What the agent proposed, and how it was checked", "section.approved": "What you approved", "section.approved.report": "What the owner approved", "section.merchant": "The merchant's own evidence", "section.acted": "What the agent did", "section.lifecycle": "Where this deal stands", "section.statements.keep": "What your agent told the buyer", "section.statements.keep.report": "What the owner's agent told the buyer", "section.statements.counterparty": "What the seller's agent told you", "section.statements.counterparty.report": "What the seller's agent told the buyer", "section.statements.adjudicator": "What the seller's agent told the buyer", "section.told": "What your agent told whom", "section.told.report": "What the owner's agent told whom", "section.deadlines": "Cancel-by and due dates", "section.cancellation": "Your cancellation", "section.cancellation.report": "The owner's cancellation", "section.anomalies": "Problems spotted", "section.other": "Other steps", "section.claims": "What this does not claim", "section.records": "Every record in this receipt", "section.provenance": "Who sealed these records", "asked.opened": "✓ These are the exact words sealed when the deal opened.", "asked.committed": "Your words are sealed as a commitment, and their opening is not in this copy, so they are not checked here.", "asked.committed.report": "The owner's words are sealed as a commitment, and their opening is not in this copy, so they are not checked here.", "asked.mismatch": "⚠️ The words you asked could not be checked against the sealed record.", "asked.mismatch.report": "⚠️ The words the owner asked could not be checked against the sealed record.", "asked.withheld": "Withheld from this copy.", "asked.not_present": "The deal's opening step is not in this report.", "statement.opened": "✓ These are the exact words sealed when the agent said them; this page does not check that they are true.", "statement.mismatch": "⚠️ A statement here could not be checked against its sealed step.", "statement.committed": "A statement is sealed as a commitment; its opening is not in this copy.", "statement.withheld": "A statement's step is withheld from this copy.", "statement.not_present": "A statement's step is not in this report.", "class.condition": "Condition", "class.warranty": "Warranty", "class.refund_terms": "Refund terms", "class.delivery_promise": "Delivery promise", "class.other": "Other", "summary.sealed": "The text on this page was written by {producer} when the receipt was made and sealed as a record in this file; the verifier checked that record. It summarises the steps and is not the steps themselves.", "summary.lines": "The summary lines below, and each step's line, were written by {producer} and sealed with the receipt: they were checked as unchanged since, not that they are right. Under each item are the steps it was read from; each step's sealed record is checked.", "acted.nothing": "Nothing yet.", "merchant.none": "No merchant email is attached to this receipt.", "merchant.intro": "Two different things stand behind each email. The merchant's signature is checked against the merchant's published key, saved when the email was sealed; it shows what the merchant sent, and it does not depend on the agent. The receipt's seal shows these exact bytes were kept unchanged from that time on; it is the sealer's own record. Amounts, dates and order numbers below are read from the email by {producer} and may be misread.", "merchant.order": "Order {order}", "merchant.email": "Merchant email", "merchant.signature": "Merchant's signature: {text}", "merchant.seal": "Our seal: {text}", "merchant.key_supplied": "The merchant's key was supplied by hand, not read from the merchant's DNS.", "merchant.approved": "You approved", "merchant.approved.report": "The owner approved", "merchant.approved_basis": "You approved ({basis})", "merchant.approved_basis.report": "The owner approved ({basis})", "merchant.agent_reported": "The agent reported paying", "merchant.charged": "The merchant's email says (read from the email)", "merchant.charged_on": "Charged on (the email's date)", "merchant.cancel_by": "Cancel by (read from the email)", "merchant.items": "Items (read from the email)", "merchant.domains": "Signing domain", "merchant.key_size": "Merchant's key (sealed when the email was sealed)", "lifecycle.later": "{at} · confirms the close: {text}", "lifecycle.as_of": "{text} (as of {at})", "told.none": "Nothing about you was recorded as shared.", "told.none.report": "Nothing about the owner was recorded as shared.", "told.note": "Only what the agent sealed as shared is listed here; something it told without sealing it is not.", "cancellation.shows": "What this shows", "cancellation.not_shows": "What this does not show", "anomalies.agent": "Agent side", "anomalies.counterparty": "Counterparty side", "anomalies.none": "None reported.", "claims.tamper": "It is tamper-evident: it shows these records were not changed after they were sealed, not who made them.", "claims.reported": "It records what the agent reported. It does not show that what was reported was true.", "claims.merchant": "It does not prove the merchant shipped, delivered or refunded anything.", "claims.scope": "The verification below covers every step's sealed record and its place in this deal's log. The records carry fingerprints, not names or numbers; the words shown come from the device that sealed them. The seal key is on the agent's machine, so this shows the record was not changed after it was made, not who made it. It covers this skill's own records only, never the agent host's own store.", "claims.withheld": "Steps marked WITHHELD are proven present and unchanged, at their place in the log; what they say is not in this copy.", "step.position": "Step {n} · {at}", "step.unnumbered": "A step this receipt cites", "step.line": "The receipt's line: {text}", "verify.tested": "Checked by {verifier}: {checks}. This page shows its answer; it did not re-check anything itself.", "verify.tested_here": "Checked in this browser by {verifier}: {checks}.", "verify.check_one": "{name} ({outcome})", "verify.checks_all": "{checks} (all {outcome})", "verify.self_reported": "Reported by {verifier}: {checks}. This view shows that report; it did not re-check anything itself.", "verify.reported": "Checked by {verifier}. This page shows its answer; it did not re-check anything itself.", "money.test": "Test money: this deal's payment was on a simulated rail. No real money moved.", "record.short": "{head}…{tail}", "value.action.pay": "Pay", "value.action.commit": "Commit to the deal", "value.action.offer": "Make an offer", "value.action.share_contact": "Share contact details", "value.action_class.money.purchase": "Spend money on a purchase", "value.action_class.agreement.accept": "Accept an agreement", "value.action_class.marketplace.offer": "Make an offer in a marketplace", "value.action_class.disclosure.personal": "Share personal details", "value.action_class.external_commitment.other": "Another kind of commitment to an outside party", "value.result.pass": "Passed", "value.result.pause": "Paused to ask first", "value.disposition.do": "Go ahead", "value.disposition.ask": "Ask first", "value.approver.user": "The person, directly", "value.approver.human": "Another person", "value.approver.standing_intent": "The person's standing instructions to the agent", "value.approver.policy": "A policy", "value.choice.proceed": "Go ahead", "value.direction.out": "Money going out", "value.direction.in": "Money coming in", "value.rail.card": "Card", "value.rail.lightning": "Lightning", "value.rail.simulated": "Simulated (test money)", "value.judge.rules": "Rules", "value.rules.not_configured": "No rules checker was set for this check", "value.rules.evaluated": "Checked by the rules", "value.rules.not_evaluated": "The rules could not be checked", "value.rules.not_applicable": "No rules apply to this step", "value.result.deny": "Refused by the rules", "value.approver.agent_card": "The agent's card", "step.log": "seq {seq} · leaf {leaf} · {log}", "step.no_log": "no place in a log was supplied", "step.record": "Record", "step.type": "Recorded as", "step.key": "Signing key", "steps.summary": "The steps this was read from", "records.step": "Step", "records.kind": "Recorded as", "records.disclosure": "Disclosure", "records.log": "Place in the log", "records.id": "Record", "records.report": "the sealed report", "records.unknown": "not in this copy", "provenance.by": "Produced by {producers}.", "provenance.then": ", then ", "provenance.unrecorded": "a producer that did not record its version", "provenance.the_producer": "the producer", "wording.provenance": "This page's words: wording pack {id}, sha256 {sha}.", "fact.deal_type": "Deal type", "fact.allowed": "Allowed", "fact.item": "Item", "fact.quantity": "Quantity", "fact.price": "Price", "fact.expect_close_by": "Expected to close by", "fact.asked.item": "You asked for (item)", "fact.asked.item.report": "The owner asked for (item)", "fact.asked.quantity": "You asked for (quantity)", "fact.asked.quantity.report": "The owner asked for (quantity)", "fact.action": "Action", "fact.action_class": "Action class", "fact.amount": "Amount", "fact.authorized_max": "Most you allowed", "fact.authorized_max.report": "Most the owner allowed", "fact.material_fields_changed": "Material details changed", "fact.offer_fields_changed": "Offer details changed", "fact.result": "Check result", "fact.differences": "Differences found", "fact.judge": "Checked by", "fact.rules": "Rules", "fact.notes": "Notes", "fact.approver": "Approved by", "fact.choice": "Choice", "fact.direction": "Direction", "fact.rail": "Paid by", "fact.class": "Statement class", "fact.source_kind": "Said by", "rung.unreported": "No witness result was reported to this page.", "l2.bundle_digest": "The verifier's report is for the bundle with digest", "fact.disposition": "Disposition", "bilateral.title": "Deal report: both parties' copies", "bilateral.title.one_sided": "Deal report: one party's copy", "deal.agree": "Both copies name one deal: {deal}.", "deal.one": "This copy is for deal {deal}.", "deal.mismatch": "The copies name different deals ({deals}). They are not shown as one deal, and neither is picked.", "deal.unnamed": "A copy names no deal, so the copies are not shown as one deal.", "party.heading": "{role} copy ({member})", "party.role_undeclared": "Undeclared", "parts.own": "Each copy is shown from its own records. What one copy leaves out is never filled in from the other.", "joins.heading": "How the two copies line up", "joins.none": "The composition declares no join between the copies.", "sides.case.both": "Stamped by both sides: both records are here, and the verifier found they agree.", "sides.case.one_sided": "Your receipt only: the other side's record is missing.", "sides.case.one_sided.shared": "One side's record only: the other side's record is missing.", "sides.case.limit": "Your receipt only: the other side's record is not shared. That is the limit they set on what they share, and it says nothing against the deal.", "sides.case.limit.shared": "One side's record only: the other side's record is not shared. That is the limit they set on what they share, and it says nothing against the deal.", "sides.case.not_agreed": "Not stamped by both: the two records do not show one agreement.", "sides.ours": "Your side · in your book", "sides.ours.shared": "The report owner's side · in their book", "sides.theirs": "Their side · as received", "sides.half": "{role}'s side · as received", "sides.missing.heading": "Their side", "sides.missing.none": "No record. Nothing from their side is in this receipt.", "sides.missing.absence": "No record. Their side was asked on {start} and had not answered by {end}. The ask is on record.", "sides.missing.refusal.policy_declined": "Not shared. Their side was asked for its record, and on {date} signed a reply that its sharing policy does not allow it. This is a limit on what they share. They have not refused the deal.", "row.both": "stamped by both", "row.one_sided": "your receipt only", "row.none": "no record", "row.cannot_check": "this browser can't check the receipt", "row.did_not_verify": "the receipt did not verify: do not rely on it", "row.cannot_check_pointer": "Open the bundle in the offline viewer (capsule-viewer) to check it; this page shows no verdict for it.", "row.page.receipt": "Receipt: {label}", "row.page.records_tied": "{tied} of {total} records in the receipt are tied to a signed checkpoint.", "actions.heading": "Tell your agent:", "actions.dispute": "“Dispute this”", "actions.send": "“Send me this receipt”", "actions.show_theirs": "“Show me the other side's receipt”", "actions.ask_again": "“Ask their side again”", "actions.ask": "“Ask their side for their receipt”", "join.line": "{basis}: declared {declared}; the verifier derived {derived}.", "join.basis.pre_agreed_identifier": "Pre-agreed identifier", "join.basis.shared_artifact_digest": "Shared artifact digest", "join.basis.issued_receipt": "Issued receipt", "join.basis.same_interval": "Same interval", "join.state.agree": "agree", "join.state.mismatch": "mismatch", "join.state.unjoined": "unjoined", "join.state.one_sided": "one-sided", "join.state.not_derivable": "not derivable", "join.result.join_state_mismatch": "What was declared is not what the verifier derived.", "corroboration.corroborating": "They agree, and their declared custody differs: corroborating, on declared custody only.", "corroboration.redundant": "They agree, but redundantly, not corroborating ({reasons}).", "l2.composition": "How the copies were put together, as the verifier checked it", "seller.title": "Sale receipt", "seller.depth.l1": "Why: what was authorised, said, offered, accepted and handed over", "seller.l0.item": "Sold", "seller.l0.amount": "Amount agreed", "seller.l0.payment": "Payment", "seller.l0.handover": "Handed over", "seller.payment.not_recorded": "Not recorded in this copy", "seller.handover.seller_observed": "By the seller's own record (not confirmed by the buyer or a carrier)", "seller.handover.none": "Not recorded", "seller.outcome.completed": "Closed: matches what was agreed", "seller.outcome.mismatch": "Closed: differs from what was agreed", "seller.outcome.not_selected": "Closed: not selected", "seller.outcome.open": "Open", "seller.fact.allowed_actions": "The agent may", "seller.fact.outcome_id": "Kind of deal", "seller.floor.committed": "The lowest price is sealed as a commitment. Its opening is in this copy; this page does not open it.", "seller.floor.withheld": "The lowest price is not in this copy.", "seller.floor.not_present": "No lowest price is sealed in this copy.", "seller.section.authorised.keep": "What you authorised", "seller.section.authorised.keep.report": "What the owner authorised", "seller.section.authorised.counterparty": "What the seller authorised their agent to do", "seller.section.authorised.adjudicator": "What the seller authorised their agent to do", "seller.section.represented.keep": "What your agent told this buyer", "seller.section.represented.keep.report": "What the owner's agent told this buyer", "seller.section.represented.counterparty": "What the seller's agent told you", "seller.section.represented.counterparty.report": "What the seller's agent told the buyer", "seller.section.represented.adjudicator": "What the seller's agent told the buyer", "seller.represented.none": "No statement to the buyer is recorded in this copy.", "seller.section.offers": "Offers, and which replaced which", "seller.offers.none": "No offer is disclosed in this copy.", "seller.offers.action": "Proposed", "seller.offers.amount": "Amount", "seller.offers.status": "Status", "seller.offers.note": "A later offer that names an earlier one replaces it; the earlier one can no longer be accepted.", "seller.offer.accepted": "accepted by the buyer", "seller.offer.superseded": "replaced by a later offer", "seller.offer.open": "not replaced", "seller.action.offer": "Offer", "seller.action.commit": "Commit", "seller.section.accepted.keep": "What the buyer accepted", "seller.section.accepted.counterparty": "What you accepted", "seller.section.accepted.counterparty.report": "What the buyer accepted", "seller.section.accepted.adjudicator": "What the buyer accepted", "seller.accepted.none": "No acceptance is recorded in this copy.", "seller.accepted.offer": "The acceptance names the offer at step", "seller.accepted.offer_not_here": "The acceptance names an offer that is not disclosed in this copy.", "seller.accepted.digest": "Digest of the exact offer accepted:", "seller.accepted.words": "The seller's agent recorded this acceptance as an observation. The buyer's words are sealed as a commitment and are not shown here.", "seller.section.payment": "Payment", "seller.payment.none": "This copy carries no payment record. Evidence the seller's agent recorded is listed with its source; this page does not read what it is about.", "seller.evidence.source": "Evidence from", "seller.evidence.verified": "marked verified", "seller.evidence.unverified": "not verified", "seller.evidence.withheld": "An evidence step is withheld from this copy.", "seller.section.handover": "Handover, and who says so", "seller.provenance.seller_observed": "The seller's own record:", "seller.provenance.seller_observed.recorded": "recorded (a claim by the seller)", "seller.provenance.seller_observed.withheld": "withheld from this copy", "seller.provenance.seller_observed.not_present": "not recorded", "seller.provenance.carrier": "A carrier's confirmation:", "seller.provenance.carrier.not_present": "none in this copy", "seller.provenance.buyer_confirmed": "The buyer's confirmation:", "seller.provenance.buyer_confirmed.not_present": "none in this copy (only the buyer's own records can carry it)", "seller.delivered.item": "Handed over (item)", "seller.delivered.quantity": "Handed over (quantity)", "seller.delivered.price": "At the price", "seller.handover.note": "A handover recorded by the seller alone shows what the seller says was handed over, not that the buyer received it.", "seller.address.committed": "An address was given. Its record carries the field's class and a commitment to the value, not the value.", "seller.address.withheld": "The address given is not in this copy.", "seller.address.not_present": "No address is recorded as given in this copy.", "seller.section.given.keep": "What your agent gave this buyer", "seller.section.given.keep.report": "What the owner's agent gave this buyer", "seller.section.given.counterparty": "What the seller's agent gave you", "seller.section.given.counterparty.report": "What the seller's agent gave the buyer", "seller.section.given.adjudicator": "What the seller's agent gave the buyer", "seller.section.obligations": "Open obligations", "seller.obligations.none": "No open obligation is recorded in this copy.", "seller.not_selected": "The seller closed this thread without a sale to this buyer. Nothing was committed or handed over in it.", "seller.threads": "This copy covers one buyer's thread. Other buyers' threads of the same sale are not in it.", "seller.claims.handover": "It does not show that the buyer received anything: a handover recorded by the seller is the seller's claim.", "seller.section.chain": "Offers and what they replaced", "seller.chain.digest": "Record digest", "seller.chain.supersedes": "Replaces step", "seller.chain.superseded_by": "Replaced by step", "seller.section.commitments": "Commitments the disclosed records seal", "seller.commitment.field": "Field", "seller.commitment.value": "Commitment", "seller.commitment.state": "Opening", "seller.commitment.opened": "opened on this page", "seller.commitment.sealed": "not opened on this page", "seller.section.legs": "Settlement legs", "seller.leg.name": "Leg", "seller.leg.state": "In this copy", "seller.leg.agreement": "Agreement", "seller.leg.payment": "Payment", "seller.leg.handover": "Handover", "seller.leg.recorded": "recorded", "seller.leg.none": "not recorded", "seller.section.keys": "Signing keys", "seller.asked.opened": "✓ These are the seller's exact words, sealed when the sale opened.", "seller.asked.committed": "The seller's words are sealed as a commitment, and their opening is not in this copy, so they are not checked here.", "seller.asked.mismatch": "⚠️ The seller's words could not be checked against the sealed record.", "seller.asked.withheld": "The seller's words are withheld from this copy.", "seller.asked.not_present": "The sale's opening step is not in this copy.", "seller.fact.asked.item": "To sell (item)", "seller.fact.asked.quantity": "To sell (quantity)", "seller.fact.item": "Item", "seller.fact.price": "Asking price", "seller.shared.counterparty": "A shared copy for the buyer. What it leaves out is listed under Why.", "seller.shared.adjudicator": "A shared copy for an adjudicator. What it leaves out is listed under Why.", "seller.section.left_out": "What this copy leaves out", "class.address": "address", "class.credential": "login", "class.email": "email", "class.home_address": "home address", "class.id_document": "ID document", "class.name": "name", "class.other_contact": "contact details", "class.payment_card": "payment card", "class.phone": "phone", "class.pickup_area": "pickup area", "class.pickup_location": "pickup location", "class.verification_code": "verification code", "section.journey": "How it went", "journey_by.user": "You", "journey_by.user.report": "Owner", "journey_by.agent": "Your agent", "journey_by.agent.report": "Owner's agent", "journey_by.other": "The other side", "journey_by.unknown": "Someone", "journey_note": "Who moved, and each row's names, items and amounts, come from the report sealed in this file; open a row to see the step it came from. The rest of the wording comes from this page and is not sealed.", "journey.agent.act.cancel": "Cancelled", "journey.agent.act.commit": "Booked", "journey.agent.act.offer": "Made an offer", "journey.agent.act.other": "Done", "journey.agent.act.pay": "Paid {amount}", "journey.agent.act.pay.no_amount": "Paid", "journey.agent.act.pay.within": "Paid {amount} within your {limit} limit", "journey.agent.act.pay.within.report": "Paid {amount} within the owner's {limit} limit", "journey.agent.act.sign": "Signed", "journey.agent.asked_seller": "Asked the seller", "journey.agent.checked": "Checked", "journey.agent.chose": "Chose for you", "journey.agent.chose.report": "Chose for the owner", "journey.agent.chose.item": "Chose {item} for you", "journey.agent.chose.item.report": "Chose {item} for the owner", "journey.agent.couldnt": "Couldn't ({reason})", "journey.agent.couldnt.who": "Couldn't ({who} {reason})", "journey.agent.options": "Showed you {count} options", "journey.agent.options.report": "Showed the owner {count} options", "journey.agent.paused": "Waited for your OK", "journey.agent.paused.report": "Waited for the owner's OK", "journey.agent.recommended": "Recommended", "journey.agent.searched": "Searched", "journey.agent.told": "Told {who} your {classes}", "journey.agent.told.report": "Told {who} the owner's {classes}", "journey.other.changed": "Seller changed", "journey.other.said": "Seller said", "journey.reason.blocked": "blocked", "journey.reason.cannot_ship_here": "can't ship here", "journey.reason.out_of_stock": "out of stock", "journey.reason.payment_declined": "payment declined", "journey.reason.sign_in_required": "sign-in", "journey.reason.site_error": "site error", "journey.user.approved.commit": "OK'd agreeing to {amount}", "journey.user.approved.offer": "OK'd offering {amount}", "journey.user.approved.other": "OK'd it", "journey.user.approved.pay": "OK'd paying {amount}", "journey.user.approved.share_contact": "OK'd sharing your {classes}", "journey.user.approved.share_contact.report": "OK'd sharing the owner's {classes}", "journey.user.asked": "Asked", "journey.user.called_off": "Called off", "journey.user.changed": "Changed what you asked", "journey.user.changed.report": "Changed what the owner asked", "journey.user.declined.commit": "Said no to agreeing to {amount}", "journey.user.declined.offer": "Said no to offering {amount}", "journey.user.declined.other": "Said no", "journey.user.declined.pay": "Said no to paying {amount}", "journey.user.declined.share_contact": "Said no to sharing your {classes}", "journey.user.declined.share_contact.report": "Said no to sharing the owner's {classes}", "journey.user.narrowed": "Narrowed", "journey.user.picked": "Picked", "journey.user.raised": "Raised", "journey.user.switched": "Switched to {who}", "journey.user.switched.item": "Switched to {item}", "deal.title": "Receipt report", "deal.depth.l1": "Terms: what each term stands at", "deal.state.started": "Started", "deal.state.awaiting_agreement": "Awaiting agreement", "deal.state.not_started": "Not started", "deal.report.scope": "A report that passes the check shows who signed it and which deal it covers. It does not show that each term's status is correct. It is the holder's own record of the deal.", "deal.settled": "Settled: every term has both sides saying the same, is uncontested, or is ruled with its remedy made, as the holder computed it.", "deal.start.by": "Started by: {by}.", "deal.start.by.offerer_in_time": "the offerer, in time", "deal.start.by.acceptor_named": "the acceptor, as named", "deal.start.by.first_act": "the first act", "deal.local": "Holder's time only: this result rests on a record with no time from a named witness, so when it happened is the holder's own word.", "deal.rows.not_started": "Nothing is agreed yet, so there are no terms to show.", "deal.rows.withheld": "The holder has not shared each term's status with this reader.", "deal.rows.none": "The agreement lists no terms.", "deal.rows.note": "Each status is the one the holder computed. This page shows it and does not compute it.", "deal.as_of": "As the holder computed it at {at}. This is not a time any witness attests.", "deal.no_time": "no time", "deal.date.not_set": "not set", "deal.section.rows": "Terms", "deal.section.basis": "The records each term's status rests on", "deal.section.rests": "What this report rests on", "deal.col.row": "Term", "deal.col.owed_by": "Owed by", "deal.col.status": "Status", "deal.col.due": "Due", "deal.col.window_end": "Contest window ends", "deal.col.detail": "Detail", "deal.col.record": "Record", "deal.col.side": "Side", "deal.col.time": "Time", "deal.basis.none": "No record is listed for any term.", "deal.status.not_reached": "Not reached", "deal.status.not_due": "Not due", "deal.status.no_statement": "No statement", "deal.status.waiting": "Waiting for the other side", "deal.status.uncontested": "Uncontested", "deal.status.agreed_so_far": "Both say the same so far", "deal.status.agreed": "Both say the same", "deal.status.in_disagreement": "Statements differ", "deal.status.in_dispute": "In dispute", "deal.status.ruled": "Ruled", "deal.value.met": "met", "deal.value.not_met": "not met", "deal.remedy.none": "none ordered", "deal.remedy.due": "due", "deal.remedy.made": "recorded as made", "deal.remedy.not_honoured": "not honoured", "deal.remedy.not_counted": "a payment, ordered by the ruling; not checked yet", "deal.row.remedy_made": "The owing side has recorded making it (not checked).", "deal.check.passed": "passed", "deal.check.failed": "failed", "deal.check.not_run": "not run", "deal.check.not_recomputed": "not recomputed", "deal.row.value": "Statement: {value}", "deal.row.remedy": "Remedy: {remedy}", "deal.row.ruling": "Ruling: {value}, against the {side}", "deal.row.check": "Payment check: {check}", "deal.pack_digest": "The terms pack the agreement cites, by digest:", "deal.rests.own": "The holder's own log held {size} records.", "deal.rests.counterparty": "The other side's log was counted to {counted} records.", "deal.rests.fork": "The other side's log forks at record {at}.", "deal.rests.layer": "The other side keeps its own record of this deal.", "deal.rests.no_layer": "The other side does not keep its own record of this deal.", "deal.rests.witnesses": "Witnesses the agreement names: {count}.", "deal.named_witness.yes": "yes", "deal.named_witness.no": "no", "deal.col.named_witness": "Time from a named witness", "deal.row.ruling.bare": "Ruling: {value}", "deal.side.buyer": "buyer", "deal.side.seller": "seller", "deal.section.legs": "Payment records the terms' statuses rest on", "deal.col.leg_side": "Side, as the report names it", "deal.col.leg": "Leg", "deal.col.leg_status": "Status as recorded", "deal.col.amount": "Amounts as recorded", "deal.col.observed": "Observed at (as recorded)", "deal.col.payment_ref": "Payment reference", "deal.legs.note": "Each line is a payment record a term relies on, shown as the record states it. This page does not check who signed each record, does not match the legs and does not judge the payment; the payment check above is the only verdict.", "deal.col.sealer": "Sealer, as recorded", "deal.legs.note.withheld": "This copy withholds the terms, so these payment records are not tied to a term. They are the records the report's holder says its terms rest on, shown as each states it. This page does not check who signed them and does not judge the payment.", "deal.legs.none.withheld": "This copy withholds the terms. Among the records the report's holder says they rest on, there is no payment record.", "deal.legs.none": "No payment record is among the records the terms' statuses rest on." }; // @generated WORDS
58
+ var PACK = { "id": "capsuleviewer.receipt.wording.example-en/v0", "sha256": "0d649dc9709c816635971bda70e1c653e4c4f9a737ab82d2e2637b62d8233875" }; // @generated PACK
59
+ var KIT_CSS = "/* SPDX-License-Identifier: Apache-2.0 */\n/*\n * kit.css -- the presentation component kit's stylesheet.\n *\n * The token block below is generated from capsule_viewer/kit/tokens.py\n * (python -m capsule_viewer.kit tokens --write); tests/test_kit_tokens.py\n * fails if the two disagree. Every colour in the component rules is a\n * var(--cv-*) reference -- the same test refuses a literal colour outside the\n * generated block.\n *\n * Phone behaviour lives here, in the primitives: each responsive component is\n * its own size container and reflows on ITS width (@container), so a module\n * that places a MetricGrid or DataTable in a narrow column gets the phone\n * layout without writing a media query. Nothing in the kit scrolls the page\n * sideways: long tokens (digests, ids) wrap anywhere.\n */\n/* BEGIN GENERATED TOKENS (capsule_viewer.kit.tokens) -- do not edit by hand */\n:root {\n --cv-font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n --cv-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;\n --cv-font-size-sm: 0.8125rem;\n --cv-font-size-md: 0.9375rem;\n --cv-font-size-lg: 1.125rem;\n --cv-line-height: 1.5;\n --cv-space-1: 0.25rem;\n --cv-space-2: 0.5rem;\n --cv-space-3: 0.75rem;\n --cv-space-4: 1rem;\n --cv-space-5: 1.5rem;\n --cv-radius: 0.5rem;\n --cv-radius-pill: 999px;\n --cv-color-text: #1b1f27;\n --cv-color-text-muted: #4d5564;\n --cv-color-surface: #ffffff;\n --cv-color-surface-sunken: #f4f5f7;\n --cv-color-border: #d3d7de;\n --cv-color-accent: #2445a8;\n --cv-color-positive-fg: #17603a;\n --cv-color-positive-bg: #e6f3eb;\n --cv-color-negative-fg: #a31d1d;\n --cv-color-negative-bg: #fbe9e9;\n --cv-color-caution-fg: #6f4700;\n --cv-color-caution-bg: #fcf1dc;\n --cv-color-neutral-fg: #3d4452;\n --cv-color-neutral-bg: #eceef2;\n --cv-color-info-fg: #1f3c94;\n --cv-color-info-bg: #e7ecfb;\n}\n/* END GENERATED TOKENS */\n\n.cv-kit { font-family: var(--cv-font-sans); font-size: var(--cv-font-size-md); line-height: var(--cv-line-height); color: var(--cv-color-text); background: var(--cv-color-surface); overflow-wrap: anywhere; }\nbody.cv-kit { margin: 0; }\n.cv-page { max-width: 60rem; margin: 0 auto; padding: var(--cv-space-5) var(--cv-space-4); }\n.cv-kit *, .cv-kit *::before, .cv-kit *::after { box-sizing: border-box; }\n.cv-kit :where(h1, h2, h3, h4, p, ul, ol, dl, dd, figure) { margin: 0; padding: 0; }\n.cv-kit :where(ul, ol) { list-style: none; }\n.cv-mono { font-family: var(--cv-font-mono); font-size: var(--cv-font-size-sm); }\n.cv-muted { color: var(--cv-color-text-muted); }\n\n/* Section */\n.cv-section { margin: 0 0 var(--cv-space-5); }\n.cv-section__title { font-size: var(--cv-font-size-lg); font-weight: 600; margin-bottom: var(--cv-space-3); }\n.cv-section__body { display: flex; flex-direction: column; gap: var(--cv-space-3); min-width: 0; }\n\n/* MetricGrid: as many columns as fit, never narrower than the label needs; one column on a phone. */\n.cv-metrics-wrap { container-type: inline-size; }\n.cv-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr)); gap: var(--cv-space-3); }\n.cv-metric { min-width: 0; border: 1px solid var(--cv-color-border); border-radius: var(--cv-radius); padding: var(--cv-space-3); background: var(--cv-color-surface-sunken); }\n.cv-metric__label { font-size: var(--cv-font-size-sm); color: var(--cv-color-text-muted); }\n.cv-metric__value { font-size: var(--cv-font-size-lg); font-weight: 600; }\n.cv-metric__note { font-size: var(--cv-font-size-sm); color: var(--cv-color-text-muted); }\n@container (max-width: 24rem) { .cv-metrics { grid-template-columns: 1fr; } }\n\n/* DataTable: a real table when there is room; stacked label/value rows when there is not. */\n.cv-table-wrap { container-type: inline-size; }\n.cv-table { width: 100%; border-collapse: collapse; font-size: var(--cv-font-size-sm); }\n.cv-table caption { text-align: left; font-weight: 600; padding-bottom: var(--cv-space-2); }\n.cv-table th, .cv-table td { text-align: left; vertical-align: top; padding: var(--cv-space-2); border-bottom: 1px solid var(--cv-color-border); min-width: 0; }\n.cv-table th { color: var(--cv-color-text-muted); font-weight: 600; background: var(--cv-color-surface-sunken); }\n/* A column header is one short word: never broken mid-word to squeeze a wide table (\"Ste\" over \"p\"). */\n.cv-table th { overflow-wrap: normal; }\n@container (max-width: 40rem) {\n .cv-table, .cv-table tbody, .cv-table tr, .cv-table td { display: block; width: 100%; }\n .cv-table caption { display: block; }\n .cv-table thead { display: none; }\n .cv-table tr { border: 1px solid var(--cv-color-border); border-radius: var(--cv-radius); margin-bottom: var(--cv-space-2); }\n .cv-table td { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--cv-space-2); }\n .cv-table td::before { content: attr(data-label); color: var(--cv-color-text-muted); font-weight: 600; }\n .cv-table tr > td:last-child { border-bottom: 0; }\n}\n\n/* CalendarGrid: always seven columns; the cells shrink, the text wraps. */\n.cv-calendar { font-size: var(--cv-font-size-sm); }\n.cv-calendar__title { font-weight: 600; margin-bottom: var(--cv-space-2); }\n.cv-calendar__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }\n.cv-calendar__dow { text-align: center; color: var(--cv-color-text-muted); font-weight: 600; padding: var(--cv-space-1) 0; }\n.cv-calendar__day { min-width: 0; min-height: 3rem; border: 1px solid var(--cv-color-border); border-radius: 4px; padding: 2px var(--cv-space-1); background: var(--cv-color-surface); }\n.cv-calendar__day--blank { border-color: transparent; background: transparent; }\n.cv-calendar__num { font-weight: 600; }\n.cv-calendar__mark { display: block; font-size: 0.6875rem; line-height: 1.25; border-radius: 3px; padding: 0 2px; }\n\n/* Tones shared by badges, pills, calendar marks and verification outcomes. */\n.cv-tone--positive { color: var(--cv-color-positive-fg); background: var(--cv-color-positive-bg); }\n.cv-tone--negative { color: var(--cv-color-negative-fg); background: var(--cv-color-negative-bg); }\n.cv-tone--caution { color: var(--cv-color-caution-fg); background: var(--cv-color-caution-bg); }\n.cv-tone--neutral { color: var(--cv-color-neutral-fg); background: var(--cv-color-neutral-bg); }\n.cv-tone--info { color: var(--cv-color-info-fg); background: var(--cv-color-info-bg); }\n\n/* Receipt sides: ours blue, theirs amber (always \"as received\"), a missing side grey and dashed. No side is ever the negative tone: one side missing is not a finding. */\n.cv-sides { display: flex; flex-direction: column; gap: var(--cv-space-2); margin: 0 0 var(--cv-space-3); }\n.cv-sides__case { padding: var(--cv-space-1) var(--cv-space-3); border-radius: var(--cv-radius); font-weight: 600; font-size: var(--cv-font-size-sm); }\n.cv-half { min-width: 0; border-radius: var(--cv-radius); padding: var(--cv-space-1) var(--cv-space-3) var(--cv-space-2); border: 1px solid var(--cv-color-border); }\n.cv-half > .cv-section { margin-bottom: 0; }\n.cv-half__label { font-size: var(--cv-font-size-sm); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--cv-color-text-muted); margin-bottom: var(--cv-space-1); }\n.cv-half--ours { background: var(--cv-color-info-bg); border-color: var(--cv-color-info-fg); }\n.cv-half--theirs { background: var(--cv-color-caution-bg); border-color: var(--cv-color-caution-fg); }\n.cv-half--missing { background: var(--cv-color-neutral-bg); border: 1px dashed var(--cv-color-neutral-fg); }\n.cv-actions { display: flex; flex-wrap: wrap; column-gap: var(--cv-space-3); font-size: var(--cv-font-size-sm); font-weight: 600; color: var(--cv-color-info-fg); }\n.cv-actions__heading { font-weight: 400; color: var(--cv-color-text-muted); }\n\n/* DisclosureBadge and VerdictPill. The pill is scoped to the kit wrapper: the page shell's verification banner is a .cv-pill outside it, and a module's stylesheet must not restyle the banner (the frame check refuses the module). */\n.cv-badge, .cv-kit .cv-pill { display: inline-block; max-width: 100%; font-size: var(--cv-font-size-sm); font-weight: 600; border-radius: var(--cv-radius-pill); padding: 0 var(--cv-space-2); border: 1px solid currentColor; }\n.cv-badge { letter-spacing: 0.02em; }\n/* A state label breaks between words, never inside one. */\n.cv-badge, .cv-kit .cv-pill { overflow-wrap: normal; }\n.cv-refusal { color: var(--cv-color-negative-fg); background: var(--cv-color-negative-bg); border: 1px dashed currentColor; }\n\n/* CitationList */\n.cv-citations { display: flex; flex-direction: column; gap: var(--cv-space-2); counter-reset: cv-cite; }\n.cv-citation { counter-increment: cv-cite; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--cv-space-2); }\n.cv-citation::before { content: \"[\" counter(cv-cite) \"]\"; color: var(--cv-color-text-muted); }\n.cv-citation__ref { display: block; color: var(--cv-color-text-muted); }\n\n/* Drilldown: native details/summary -- opens with no script; prints open. */\n.cv-drilldown { border: 1px solid var(--cv-color-border); border-radius: var(--cv-radius); background: var(--cv-color-surface); }\n.cv-drilldown > summary { cursor: pointer; padding: var(--cv-space-2) var(--cv-space-3); font-weight: 600; color: var(--cv-color-accent); }\n.cv-drilldown__body { padding: 0 var(--cv-space-3) var(--cv-space-3); display: flex; flex-direction: column; gap: var(--cv-space-2); min-width: 0; }\n\n/* EvidenceDetails */\n.cv-evidence { display: flex; flex-direction: column; gap: var(--cv-space-2); }\n.cv-evidence__item { border-left: 3px solid var(--cv-color-border); padding-left: var(--cv-space-3); display: flex; flex-direction: column; gap: var(--cv-space-1); }\n.cv-evidence__head { display: flex; flex-wrap: wrap; gap: var(--cv-space-2); align-items: baseline; }\n.cv-evidence__label { font-weight: 600; }\n\n/* VerificationDetails */\n.cv-verification { display: flex; flex-direction: column; gap: var(--cv-space-2); }\n.cv-verification__outcome { border-radius: var(--cv-radius); padding: var(--cv-space-2) var(--cv-space-3); font-weight: 600; }\n.cv-checks { display: flex; flex-direction: column; gap: var(--cv-space-1); }\n.cv-check { display: flex; flex-wrap: wrap; gap: var(--cv-space-2); align-items: baseline; }\n\n/* PartyCard */\n.cv-party { border: 1px solid var(--cv-color-border); border-radius: var(--cv-radius); padding: var(--cv-space-3); background: var(--cv-color-surface-sunken); }\n.cv-party__role { font-size: var(--cv-font-size-sm); color: var(--cv-color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }\n.cv-party__name { font-weight: 600; }\n.cv-party__facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--cv-space-1) var(--cv-space-3); margin-top: var(--cv-space-2); font-size: var(--cv-font-size-sm); }\n.cv-party__facts dt { color: var(--cv-color-text-muted); }\n.cv-party-wrap { container-type: inline-size; }\n@container (max-width: 20rem) { .cv-party__facts { grid-template-columns: minmax(0, 1fr); } }\n\n/* Timeline: entries in the order given. */\n.cv-timeline { border-left: 2px solid var(--cv-color-border); padding-left: var(--cv-space-3); display: flex; flex-direction: column; gap: var(--cv-space-3); }\n.cv-timeline__at { display: block; color: var(--cv-color-text-muted); }\n.cv-timeline__label { font-weight: 600; }\n\n@media print {\n .cv-kit { background: none; }\n .cv-drilldown > summary { color: var(--cv-color-text); }\n /* A closed drilldown still prints its body (Chromium's details-content). */\n .cv-drilldown::details-content { content-visibility: visible; display: block; }\n .cv-section, .cv-metric, .cv-party, .cv-table tr, .cv-evidence__item { break-inside: avoid; }\n}\n"; // @generated KIT_CSS
60
+ // The seller copy's bundle extension kind (capsule_viewer.receipt_slot.SELLER_KIND).
61
+ var SELLER_KIND = "x-deal-seller/v0"; // @generated SELLER_KIND
62
+ var EXTENSION = "x-deal-v0";
63
+ // The v1 deal profile's extension and sealed report (evidencebook
64
+ // docs/design/461-deal-profile.md, section 9). A v1 page reads this and never x-deal-v0.
65
+ var EXTENSION_V1 = "x-deal-v1";
66
+ // Where capsulectl carries a copy's report when it is on no log (capsule-cli#294).
67
+ var STANDALONE_EXTENSION = "x-deal-report/v0";
68
+ var COMPOSED_KIND = "composed/v1";
69
+ var REPORT_TYPE = "deal_report";
70
+ var REPORT_ACTION_ID = "capsulectl-deal-report";
71
+ var ACCEPTANCE_KIND = "counterparty-acceptance-observation";
72
+ var DEPTHS = ["L0", "L1", "L2"];
73
+ var SHARED_AUDIENCES = ["counterparty", "adjudicator"];
74
+ var MAX_SAFE = 9007199254740991;
75
+ var VERIFIER = "the page's verifier (agent-action-capsule)";
76
+ var SECTION_BY_RECORD_TYPE = {
77
+ baseline: "authorized", check: "proposed", verdict: "proposed", approval: "approved",
78
+ action: "acted", claim: "statements", task_authority: "authorized",
79
+ };
80
+ var RECORD_TYPE_BY_TYPED = {
81
+ "proposed-action/v0": "check", "action-evaluation/v0": "verdict", "action-approval/v0": "approval",
82
+ "action-record/v0": "action", "task-authority/v0": "task_authority",
83
+ };
84
+ var SECTION_BY_STEP_KIND = {
85
+ open: "authorized", snapshot: "proposed", check: "proposed", approval: "approved", act: "acted", claim: "statements",
86
+ };
87
+ var EXPONENT = {};
88
+ ["BIF", "CLP", "DJF", "GNF", "ISK", "JPY", "KMF", "KRW", "PYG", "RWF", "UGX", "VND", "VUV", "XAF", "XOF", "XPF"].forEach(function (c) { EXPONENT[c] = 0; });
89
+ ["BHD", "IQD", "JOD", "KWD", "LYD", "OMR", "TND"].forEach(function (c) { EXPONENT[c] = 3; });
90
+ var MERCHANT_ROWS = ["approved", "agent_reported", "charged", "charged_on", "cancel_by", "domains", "key_size"];
91
+ var PROVENANCES = ["seller_observed", "carrier", "buyer_confirmed"];
92
+ var CUTS = { keep: ["keep", "counterparty"], counterparty: ["counterparty"], adjudicator: ["adjudicator"] };
93
+ // sides.CASE_TONE and sides.ACTIONS: a case's tone (never "negative": one
94
+ // side missing is not a finding) and the sentences a holder's page offers.
95
+ var CASE_TONE = { both: "positive", one_sided: "caution", limit: "neutral", not_agreed: "neutral" };
96
+ var ACTIONS = {
97
+ both: ["actions.dispute", "actions.send", "actions.show_theirs"],
98
+ one_sided: ["actions.send", "actions.ask_again"],
99
+ limit: ["actions.send"],
100
+ none: ["actions.send", "actions.ask"],
101
+ not_agreed: ["actions.dispute", "actions.send", "actions.show_theirs"],
102
+ };
103
+ // The kit's closed vocabularies (capsule_viewer.kit.components).
104
+ var DISCLOSURE_STATES = {
105
+ disclosed: ["DISCLOSED", "positive"],
106
+ committed: ["COMMITTED (opening not supplied)", "info"],
107
+ withheld: ["WITHHELD", "caution"],
108
+ not_present: ["NOT PRESENT", "neutral"],
109
+ };
110
+ var VERIFICATION_OUTCOMES = {
111
+ verified: ["Verified", "positive"],
112
+ incomplete: ["Incomplete", "caution"],
113
+ failed: ["Did not verify", "negative"],
114
+ not_checked: ["Not checked", "neutral"],
115
+ };
116
+ // The composition section's words: agent-action-capsule's composition view
117
+ // (capsule_viewer.composed, after ts/src/composed-view.ts).
118
+ var NOT_APPLICABLE = "—";
119
+ // module.py's TEST_RAIL, WITNESS_CHECK, _TIME_MARK, SHORT_HEAD and SHORT_TAIL.
120
+ var TEST_RAIL = "simulated";
121
+ var WITNESS_CHECK = "witnesses";
122
+ var TIME_MARK = "\u0000";
123
+ var SHORT_HEAD = 8, SHORT_TAIL = 4;
124
+ function isRail(f) { return f.name === "rail" && f.kind === "token"; }
125
+ // module.py's _test_money: every rail the steps name is the simulated one, and at least one is named.
126
+ function testMoney(model) {
127
+ var rails = [];
128
+ seq(model.steps).forEach(function (s) { s.facts.forEach(function (f) { if (isRail(f))
129
+ rails.push(f); }); });
130
+ return rails.length > 0 && rails.every(function (f) { return f.value === TEST_RAIL; });
131
+ }
132
+ var COMPOSED_SCOPE = "Composition closure covers the declared members only; it is not completeness of participation.";
133
+ var COMPOSED_CUSTODY = "Custody domains are labels declared by whoever composed this block. Identical labels make an agreeing pair " +
134
+ "redundant; distinct labels do not establish that two observers are independent.";
135
+ // ---- JSON as Python reads it ----------------------------------------------
136
+ // The Python twin reads decoded JSON with isinstance checks and Python
137
+ // truthiness; these are the same tests over JavaScript values.
138
+ function own(o, k) { return o !== null && typeof o === "object" && Object.prototype.hasOwnProperty.call(o, k); }
139
+ function isMap(v) { return v !== null && typeof v === "object" && !Array.isArray(v); }
140
+ function map(v) { return isMap(v) ? v : {}; }
141
+ function get(o, k) { return own(o, k) ? o[k] : null; }
142
+ function seq(v) { return Array.isArray(v) ? v : []; }
143
+ function str(v) { return typeof v === "string" ? v : null; }
144
+ function int(v) { return typeof v === "number" && Number.isInteger(v) ? v : null; }
145
+ function strings(v) {
146
+ if (typeof v === "string")
147
+ return [v];
148
+ return Array.isArray(v) ? v.filter(function (x) { return typeof x === "string"; }) : [];
149
+ }
150
+ // Python truthiness of a JSON value.
151
+ function truthy(v) {
152
+ if (v === null || v === undefined || v === false || v === 0 || v === "")
153
+ return false;
154
+ if (Array.isArray(v))
155
+ return v.length > 0;
156
+ if (typeof v === "object")
157
+ return Object.keys(v).length > 0;
158
+ return true;
159
+ }
160
+ // Python's `a or b`.
161
+ function or(a, b) { return truthy(a) ? a : b; }
162
+ function iter(v) {
163
+ // Python's `for x in v or ()` over a JSON value: an array's items, a
164
+ // string's characters, an object's keys.
165
+ if (!truthy(v))
166
+ return [];
167
+ if (Array.isArray(v))
168
+ return v;
169
+ if (typeof v === "string")
170
+ return Array.from(v);
171
+ if (isMap(v))
172
+ return Object.keys(v);
173
+ return [];
174
+ }
175
+ // Python's str() of a JSON scalar.
176
+ function pyStr(v) {
177
+ if (v === null || v === undefined)
178
+ return "None";
179
+ if (v === true)
180
+ return "True";
181
+ if (v === false)
182
+ return "False";
183
+ if (typeof v === "string")
184
+ return v;
185
+ if (typeof v === "number")
186
+ return Number.isInteger(v) ? String(v) : String(v);
187
+ return JSON.stringify(v);
188
+ }
189
+ // Python's sorted() order of strings: by code point.
190
+ function codepointCompare(a, b) {
191
+ var x = Array.from(a), y = Array.from(b);
192
+ for (var i = 0; i < Math.min(x.length, y.length); i++) {
193
+ var d = x[i].codePointAt(0) - y[i].codePointAt(0);
194
+ if (d !== 0)
195
+ return d;
196
+ }
197
+ return x.length - y.length;
198
+ }
199
+ function sortedKeys(o) { return Object.keys(o).sort(codepointCompare); }
200
+ function distinct(list) {
201
+ var out = [];
202
+ list.forEach(function (x) { if (out.indexOf(x) < 0)
203
+ out.push(x); });
204
+ return out;
205
+ }
206
+ function Unavailable(message) { this.name = "ReceiptUnavailable"; this.message = message; }
207
+ Unavailable.prototype = Object.create(Error.prototype);
208
+ // ---- SHA-256 (FIPS 180-4), UTF-8 and JCS, synchronous ----------------------
209
+ var K = [
210
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
211
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
212
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
213
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
214
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
215
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
216
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
217
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
218
+ ];
219
+ function sha256Hex(bytes) {
220
+ var len = bytes.length;
221
+ var padded = new Uint8Array(((len + 9 + 63) >> 6) << 6);
222
+ padded.set(bytes);
223
+ padded[len] = 0x80;
224
+ var bits = len * 8;
225
+ var view = new DataView(padded.buffer);
226
+ view.setUint32(padded.length - 8, Math.floor(bits / 0x100000000));
227
+ view.setUint32(padded.length - 4, bits >>> 0);
228
+ var h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
229
+ var w = new Array(64);
230
+ for (var off = 0; off < padded.length; off += 64) {
231
+ for (var i = 0; i < 16; i++)
232
+ w[i] = view.getUint32(off + i * 4);
233
+ for (i = 16; i < 64; i++) {
234
+ var x = w[i - 15], y = w[i - 2];
235
+ var s0 = ((x >>> 7) | (x << 25)) ^ ((x >>> 18) | (x << 14)) ^ (x >>> 3);
236
+ var s1 = ((y >>> 17) | (y << 15)) ^ ((y >>> 19) | (y << 13)) ^ (y >>> 10);
237
+ w[i] = (w[i - 16] + s0 + w[i - 7] + s1) | 0;
238
+ }
239
+ var a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], k = h[7];
240
+ for (i = 0; i < 64; i++) {
241
+ var S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
242
+ var t1 = (k + S1 + ((e & f) ^ (~e & g)) + K[i] + w[i]) | 0;
243
+ var S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
244
+ var t2 = (S0 + ((a & b) ^ (a & c) ^ (b & c))) | 0;
245
+ k = g;
246
+ g = f;
247
+ f = e;
248
+ e = (d + t1) | 0;
249
+ d = c;
250
+ c = b;
251
+ b = a;
252
+ a = (t1 + t2) | 0;
253
+ }
254
+ h[0] = (h[0] + a) | 0;
255
+ h[1] = (h[1] + b) | 0;
256
+ h[2] = (h[2] + c) | 0;
257
+ h[3] = (h[3] + d) | 0;
258
+ h[4] = (h[4] + e) | 0;
259
+ h[5] = (h[5] + f) | 0;
260
+ h[6] = (h[6] + g) | 0;
261
+ h[7] = (h[7] + k) | 0;
262
+ }
263
+ var out = "";
264
+ for (i = 0; i < 8; i++)
265
+ out += ("00000000" + (h[i] >>> 0).toString(16)).slice(-8);
266
+ return out;
267
+ }
268
+ function NotCanonical(message) { this.name = "NotCanonical"; this.message = message; }
269
+ NotCanonical.prototype = Object.create(Error.prototype);
270
+ // UTF-8; a lone surrogate has no UTF-8 form and is refused.
271
+ function utf8(s) {
272
+ var out = [];
273
+ for (var i = 0; i < s.length; i++) {
274
+ var c = s.charCodeAt(i);
275
+ if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {
276
+ var d = s.charCodeAt(i + 1);
277
+ if (d >= 0xdc00 && d <= 0xdfff) {
278
+ c = 0x10000 + ((c - 0xd800) << 10) + (d - 0xdc00);
279
+ i++;
280
+ }
281
+ }
282
+ if (c >= 0xd800 && c <= 0xdfff)
283
+ throw new NotCanonical("a string holds a lone surrogate");
284
+ if (c < 0x80)
285
+ out.push(c);
286
+ else if (c < 0x800)
287
+ out.push(0xc0 | (c >> 6), 0x80 | (c & 63));
288
+ else if (c < 0x10000)
289
+ out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
290
+ else
291
+ out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
292
+ }
293
+ return new Uint8Array(out);
294
+ }
295
+ function jcsString(s) {
296
+ utf8(s); // refuses a lone surrogate before JSON.stringify would escape it
297
+ return JSON.stringify(s);
298
+ }
299
+ // As capsule_viewer.digest.jcs: null, booleans, strings, safe integers,
300
+ // arrays and objects (members by UTF-16 code units, RFC 8785 3.2.3).
301
+ function jcs(v) {
302
+ if (v === null)
303
+ return "null";
304
+ if (v === true)
305
+ return "true";
306
+ if (v === false)
307
+ return "false";
308
+ if (typeof v === "string")
309
+ return jcsString(v);
310
+ if (typeof v === "number") {
311
+ if (!Number.isInteger(v))
312
+ throw new NotCanonical("a JSON float has no canonical form in this profile");
313
+ if (Math.abs(v) > MAX_SAFE)
314
+ throw new NotCanonical("integer " + v + " is outside +/-" + MAX_SAFE);
315
+ return String(v);
316
+ }
317
+ if (Array.isArray(v))
318
+ return "[" + v.map(jcs).join(",") + "]";
319
+ if (typeof v === "object") {
320
+ return "{" + Object.keys(v).sort().map(function (key) { return jcsString(key) + ":" + jcs(v[key]); }).join(",") + "}";
321
+ }
322
+ throw new NotCanonical(typeof v + " is not a JSON value");
323
+ }
324
+ function digestOf(value) { return sha256Hex(utf8(jcs(value))); }
325
+ // capsule_viewer.digest.record_digest: the digest a typed reference names.
326
+ function recordDigest(payload) {
327
+ try {
328
+ return digestOf(payload);
329
+ }
330
+ catch (e) {
331
+ if (e instanceof NotCanonical)
332
+ return null;
333
+ throw e;
334
+ }
335
+ }
336
+ // The presentation contract's text binding (section 7.2,
337
+ // sha256-jcs-nonce256): capsule_viewer.binding.check_opening.
338
+ var HEX64 = /^[0-9a-f]{64}$/;
339
+ function checkOpening(committed, nonce, text) {
340
+ if ((nonce === null || nonce === undefined) && (text === null || text === undefined))
341
+ return "committed";
342
+ if (!(typeof committed === "string" && HEX64.test(committed)))
343
+ return "mismatch";
344
+ if (!(typeof nonce === "string" && HEX64.test(nonce) && typeof text === "string"))
345
+ return "mismatch";
346
+ var recomputed;
347
+ try {
348
+ recomputed = digestOf({ nonce: nonce, text: text });
349
+ }
350
+ catch (e) {
351
+ if (e instanceof NotCanonical)
352
+ return "mismatch";
353
+ throw e;
354
+ }
355
+ return recomputed === committed ? "opened" : "mismatch";
356
+ }
357
+ // ---- the page's verifier: agent-action-capsule's VerifiedBundleContext ------
358
+ function claim(c) {
359
+ var o = map(c);
360
+ return { status: typeof o.status === "string" ? o.status : "", findings: Array.isArray(o.findings) ? o.findings : [] };
361
+ }
362
+ // The runtime's gate (presentation-registry.ts re-exports
363
+ // agent-action-capsule's bundleVerified; 0.16.0, verification-page.ts): a
364
+ // producer-selected bundle, whose interval coverage is withheld as
365
+ // selection_not_checkable (a Mesh node's receipt), passes the gate on its
366
+ // other checks, as the page's own verdict does (#383).
367
+ function producerSelection(v) {
368
+ var coverage = claim(v.intervalCoverage);
369
+ return coverage.status === "withheld" && coverage.findings.indexOf("selection_not_checkable") >= 0;
370
+ }
371
+ function bundleVerified(verification) {
372
+ var v = map(verification);
373
+ var membership = claim(v.perRecordMembership);
374
+ var results = map(v.capsuleResults);
375
+ return claim(v.graphClosure).status === "pass" &&
376
+ (claim(v.intervalCoverage).status === "pass" || producerSelection(v)) &&
377
+ (membership.status === "pass" || (membership.status === "fail" && membership.findings.length > 0 &&
378
+ membership.findings.every(function (f) { return typeof f === "string" && f.indexOf("membership_record_unbound:") === 0; }))) &&
379
+ Object.keys(results).every(function (id) { return map(results[id]).ok === true; }) &&
380
+ seq(v.disclosures).every(function (d) { return map(d).status === "disclosure_match" || map(d).status === "withheld"; });
381
+ }
382
+ var OUTCOME_OF = { pass: "verified", fail: "failed", withheld: "not_checked" };
383
+ // What the page's verifier reported, as the kit's VerificationResult.
384
+ function pageVerification(context) {
385
+ var v = map(map(context).verification);
386
+ var checks = [["graph closure", v.graphClosure], ["interval coverage", v.intervalCoverage], ["per record membership", v.perRecordMembership]]
387
+ .map(function (pair) {
388
+ var c = claim(pair[1]);
389
+ return { name: pair[0], outcome: own(OUTCOME_OF, c.status) ? OUTCOME_OF[c.status] : "failed", detail: c.findings.map(String).join(", ") };
390
+ });
391
+ var outcome = bundleVerified(v) ? "verified" : "failed";
392
+ // verifier_report._declined_only: capsulectl reads a composition holding a policy_declined
393
+ // refusal INCOMPLETE, which the page's claims do not show, so such a bundle is never
394
+ // "verified" here; the bilateral module still declines unless the refusal's signature
395
+ // verified (missingMember).
396
+ if (outcome === "verified" && declinedMember(map(map(context).bundle))) {
397
+ outcome = "incomplete";
398
+ checks.push({ name: "declined member", outcome: "not_checked", detail: "policy_declined" });
399
+ }
400
+ // The page's own check ran in full only when the runtime has a strict
401
+ // result: without Ed25519 a producer selection is read on its plain
402
+ // checks alone (agent-action-capsule's buildVerifiedBundleContext).
403
+ return { verifier: VERIFIER, outcome: outcome, checks: checks, here: map(context).strict !== undefined };
404
+ }
405
+ function declinedMember(bundle) {
406
+ var block = map(get(map(get(bundle, "extensions")), COMPOSED_KIND));
407
+ return seq(get(block, "members")).map(map).some(function (m) {
408
+ return get(m, "outcome") === "refusal" && get(map(get(m, "refusal")), "reason") === "policy_declined";
409
+ });
410
+ }
411
+ // capsulectl's status for the `extension` check (x-deal-v0, or x-deal-v1 for the
412
+ // deal module) when it names the report as standalone. A page runtime that does
413
+ // not interpret that extension reports none.
414
+ function reportChecked(verification, extension) {
415
+ var entry = seq(map(verification).extensions).map(map).find(function (e) { return e.kind === extension && e.report === "standalone"; });
416
+ return entry !== undefined && typeof entry.status === "string" ? entry.status : null;
417
+ }
418
+ function pageAssurance(context, extension) {
419
+ var c = map(context);
420
+ var v = map(c.verification);
421
+ return {
422
+ bundle_digest: typeof v.bundleDigest === "string" ? v.bundleDigest : null,
423
+ witnesses: "absent",
424
+ countersignatures: seq(c.countersignatures).map(function (x) { return isMap(x) && typeof x.status === "string" ? x.status : "unknown"; }),
425
+ report_checked: reportChecked(v, extension),
426
+ };
427
+ }
428
+ // A carried copy, verified by the page's runtime on its own.
429
+ function pageMemberContext(bundle) {
430
+ var graph = root.EvidenceGraph;
431
+ if (!graph || typeof graph.buildVerifiedBundleContext !== "function") {
432
+ throw new Unavailable("the page's runtime offers no verifier for a carried copy");
433
+ }
434
+ return graph.buildVerifiedBundleContext(bundle);
435
+ }
436
+ // The context, read as the Python twin's VerifiedBundleContext is read.
437
+ function view(context, env) {
438
+ var c = map(context);
439
+ var bundle = map(c.bundle);
440
+ var records = seq(c.records).map(function (r) { return map(r).capsule_id; }).filter(function (id) { return typeof id === "string"; });
441
+ var resolved = c.resolvedDisclosures;
442
+ var verification = env.verification(context);
443
+ var disclosed = function (id, member) {
444
+ var entry = resolved && typeof resolved.get === "function" ? resolved.get(id) : undefined;
445
+ var r = entry ? entry[member] : undefined;
446
+ return r && r.state === "disclosed" ? (r.payload === undefined ? null : r.payload) : null;
447
+ };
448
+ var mismatch = records.some(function (id) {
449
+ var entry = resolved && typeof resolved.get === "function" ? resolved.get(id) : undefined;
450
+ return !!entry && ["agent_input", "agent_output"].some(function (m) { return entry[m] && entry[m].state === "disclosure_mismatch"; });
451
+ });
452
+ return {
453
+ context: context,
454
+ bundle: bundle,
455
+ root: typeof c.root === "string" ? c.root : null,
456
+ records: records,
457
+ disclosed: disclosed,
458
+ memberships: map(map(c.completeness).memberships),
459
+ verification: verification,
460
+ // context.py GATE_OUTCOMES: an incomplete outcome (a producer-selected bundle, which the
461
+ // page supplies only for the top-level bundle) passes the gate as it does there.
462
+ verified: (verification.outcome === "verified" || verification.outcome === "incomplete") && !mismatch,
463
+ assurance: env.assurance(context),
464
+ };
465
+ }
466
+ // ---- which side of a deal a copy is from (role.py) ------------------------
467
+ function sellerKindEngaged(v) {
468
+ return own(map(v.bundle.extensions), SELLER_KIND);
469
+ }
470
+ function sealedPartyRole(v) {
471
+ var roles = [];
472
+ v.records.forEach(function (cid) {
473
+ var payload = map(v.disclosed(cid, "agent_input"));
474
+ var block = map(get(payload, EXTENSION));
475
+ if (get(block, "record_type") !== "baseline" || get(block, "seq") !== 1)
476
+ return;
477
+ var intent = map(get(map(get(payload, "body")), "intent"));
478
+ roles.push(own(intent, "party_role") ? intent.party_role : "buyer");
479
+ });
480
+ if (roles.length !== 1 || (roles[0] !== "buyer" && roles[0] !== "seller"))
481
+ return null;
482
+ return roles[0];
483
+ }
484
+ function sellerOnly(payload) {
485
+ var body = map(get(payload, "body"));
486
+ var kind = or(get(payload, "type"), get(map(get(payload, EXTENSION)), "record_type"));
487
+ if (["proposed-action/v0", "action-record/v0", "check", "action"].indexOf(kind) >= 0)
488
+ return get(body, "action") === "offer";
489
+ if (kind === "action-approval/v0")
490
+ return get(body, "kind") === ACCEPTANCE_KIND;
491
+ if (kind === "task-authority/v0")
492
+ return own(body, "sale_authority_commitment");
493
+ return false;
494
+ }
495
+ function sealedSide(v) {
496
+ var role = sealedPartyRole(v);
497
+ if (role !== null)
498
+ return role;
499
+ for (var i = 0; i < v.records.length; i++) {
500
+ if (sellerOnly(map(v.disclosed(v.records[i], "agent_input"))))
501
+ return "seller";
502
+ }
503
+ return null;
504
+ }
505
+ // ---- the receipt model (model.py) -----------------------------------------
506
+ // model.group_thousands: ``2000`` -> ``2,000``, by hand and never by locale, so every reader and both twins agree.
507
+ function groupThousands(whole) {
508
+ if (whole < 0)
509
+ return "-" + groupThousands(-whole);
510
+ var digits = String(whole);
511
+ var head = digits.length % 3 || 3;
512
+ var out = [digits.slice(0, head)];
513
+ for (var i = head; i < digits.length; i += 3)
514
+ out.push(digits.slice(i, i + 3));
515
+ return out.join(",");
516
+ }
517
+ function formatAmount(minor, currency) {
518
+ // BTC counts millisatoshi (1e-11 BTC): shown as counted, never sats or a BTC decimal.
519
+ if (currency === "BTC")
520
+ return (minor < 0 ? "-" : "") + groupThousands(Math.abs(minor)) + " msat";
521
+ var exponent = own(EXPONENT, currency) ? EXPONENT[currency] : 2;
522
+ var sign = minor < 0 ? "-" : "";
523
+ var abs = Math.abs(minor);
524
+ var scale = Math.pow(10, exponent);
525
+ var whole = Math.floor(abs / scale);
526
+ var part = abs % scale;
527
+ if (!exponent)
528
+ return sign + groupThousands(whole) + " " + currency;
529
+ return sign + groupThousands(whole) + "." + String(part).padStart(exponent, "0") + " " + currency;
530
+ }
531
+ function fact(name, value, kind) { return { name: name, value: value, kind: kind || "token" }; }
532
+ function amountFact(name, minor, currency) {
533
+ var m = int(minor), c = str(currency);
534
+ return m !== null && c ? fact(name, formatAmount(m, c), "amount") : null;
535
+ }
536
+ function token(name, value) {
537
+ if (typeof value === "boolean")
538
+ return fact(name, value ? "true" : "false");
539
+ if (typeof value === "number" && Number.isInteger(value))
540
+ return fact(name, String(value), "count");
541
+ if (typeof value === "string" && value)
542
+ return fact(name, value);
543
+ if (Array.isArray(value) && value.length && value.every(function (x) { return typeof x === "string"; }))
544
+ return fact(name, value.join(", "));
545
+ return null;
546
+ }
547
+ function facts(recordType, body) {
548
+ var terms = map(get(body, "terms"));
549
+ var currency = or(get(body, "currency"), get(terms, "currency"));
550
+ var found;
551
+ if (recordType === "baseline") {
552
+ var intent = map(get(body, "intent"));
553
+ var asked = map(get(intent, "asked"));
554
+ found = [token("deal_type", get(body, "deal_type"))]
555
+ .concat(sortedKeys(asked).map(function (key) { return token("asked." + key, asked[key]); }))
556
+ .concat([
557
+ token("allowed", get(intent, "allowed")),
558
+ token("item", get(terms, "item")),
559
+ token("quantity", get(terms, "quantity")),
560
+ amountFact("price", get(terms, "price_minor"), get(terms, "currency")),
561
+ token("expect_close_by", get(body, "expect_close_by")),
562
+ ]);
563
+ }
564
+ else if (recordType === "check") {
565
+ found = [
566
+ token("action", get(body, "action")),
567
+ token("action_class", get(body, "action_class")),
568
+ amountFact("amount", get(body, "amount_minor"), currency),
569
+ amountFact("authorized_max", get(body, "authorized_max_minor"), currency),
570
+ token("item", get(terms, "item")),
571
+ token("quantity", get(terms, "quantity")),
572
+ token("material_fields_changed", get(body, "material_fields_changed")),
573
+ token("offer_fields_changed", get(body, "offer_fields_changed")),
574
+ ];
575
+ }
576
+ else if (recordType === "verdict") {
577
+ var differences = get(body, "differences");
578
+ found = [
579
+ token("result", get(body, "result")),
580
+ token("disposition", get(body, "disposition")),
581
+ Array.isArray(differences) ? fact("differences", String(differences.length), "count") : null,
582
+ token("judge", get(map(get(body, "judge")), "kind")),
583
+ token("rules", get(map(get(body, "rules")), "status")),
584
+ token("notes", get(body, "notes")),
585
+ ];
586
+ }
587
+ else if (recordType === "approval") {
588
+ found = [token("approver", get(body, "approver")), token("choice", get(body, "choice"))];
589
+ }
590
+ else if (recordType === "action") {
591
+ found = [
592
+ token("action", get(body, "action")),
593
+ amountFact("amount", get(body, "amount_minor"), currency),
594
+ token("direction", get(body, "direction")),
595
+ token("rail", get(body, "rail")),
596
+ ];
597
+ }
598
+ else if (recordType === "claim") {
599
+ found = [token("class", get(body, "class")), token("source_kind", get(body, "source_kind"))];
600
+ }
601
+ else {
602
+ found = [];
603
+ }
604
+ return found.filter(function (f) { return f !== null; });
605
+ }
606
+ function item(text, steps, at, flagged) {
607
+ return { text: text, steps: steps || [], at: at === undefined ? null : at, flagged: !!flagged };
608
+ }
609
+ function items(raw, stepsKey) {
610
+ var out = [];
611
+ seq(raw).forEach(function (entry) {
612
+ entry = map(entry);
613
+ var text = str(get(entry, "text"));
614
+ if (text !== null)
615
+ out.push(item(text, strings(get(entry, stepsKey || "steps")), str(get(entry, "at"))));
616
+ });
617
+ return out;
618
+ }
619
+ function pyStrip(s) { return s.replace(/^\s+|\s+$/g, ""); }
620
+ function deadline(d) {
621
+ var when = or(str(get(d, "cancel_by")), or(str(get(d, "due_by")), ""));
622
+ var marking = or(str(get(d, "marking")), or(str(get(d, "status")), ""));
623
+ var text = pyStrip(when + " · " + marking + ": " + or(str(get(d, "text")), "") + ". " + or(str(get(d, "holds")), ""));
624
+ return item(text, [], null, get(d, "status") === "open" || get(d, "status") === "carried_at_close");
625
+ }
626
+ function merchant(m) {
627
+ var rows = MERCHANT_ROWS.filter(function (key) { return truthy(str(get(m, key))); }).map(function (key) { return [key, or(str(get(m, key)), "")]; });
628
+ var its = strings(get(m, "items"));
629
+ if (its.length)
630
+ rows.push(["items", its.join(" · ")]);
631
+ return {
632
+ order_id: str(get(m, "order_id")),
633
+ verified: get(m, "verified") === true,
634
+ merchant_says: or(str(get(m, "merchant_says")), ""),
635
+ we_say: or(str(get(m, "we_say")), ""),
636
+ key_supplied: get(m, "key_source") === "supplied",
637
+ approved_basis: str(get(m, "approved_basis")),
638
+ rows: rows,
639
+ steps: strings(get(m, "steps")),
640
+ };
641
+ }
642
+ function told(t) {
643
+ var parts = [str(get(t, "text")), str(get(t, "at")), str(get(t, "authority_text"))].filter(truthy);
644
+ return item(parts.join(" · "), strings(get(t, "steps")), null, get(t, "authority") === "none");
645
+ }
646
+ // The errand's journey as the sealed report states it (model.py Move).
647
+ function journeyOf(raw) {
648
+ var out = [];
649
+ seq(raw).forEach(function (e) {
650
+ if (!isMap(e))
651
+ return;
652
+ var entry = map(e);
653
+ // A move with no key is still a move: capsulectl's page lists it as who moved, with no label.
654
+ var key = or(str(get(entry, "key")), "");
655
+ var facts = map(get(entry, "facts"));
656
+ var pairs = [];
657
+ Object.keys(facts).forEach(function (name) {
658
+ var value = str(facts[name]);
659
+ if (value !== null)
660
+ pairs.push([name, value]);
661
+ });
662
+ out.push({ by: or(str(get(entry, "by")), ""), key: key, step: str(get(entry, "step")), facts: pairs, classes: Array.isArray(get(facts, "classes")) ? strings(get(facts, "classes")) : null });
663
+ });
664
+ return out;
665
+ }
666
+ function report(capsuleId, raw) {
667
+ var life = map(get(raw, "lifecycle"));
668
+ var deadlines = seq(get(raw, "deadlines")).map(map);
669
+ var anomalies = seq(get(raw, "anomalies")).map(map);
670
+ var side = function (name) {
671
+ return anomalies.filter(function (a) { return get(a, "side") === name; })
672
+ .map(function (a) { return item(or(str(get(a, "text")), ""), strings(get(a, "steps")), null, true); });
673
+ };
674
+ return {
675
+ capsule_id: capsuleId,
676
+ audience: or(str(get(raw, "audience")), ""),
677
+ state: str(get(life, "state")),
678
+ did: items(get(raw, "did")),
679
+ money: str(get(map(get(raw, "money")), "text")),
680
+ lifecycle: str(get(life, "text")),
681
+ later: items(get(life, "later"), "capsule_id"),
682
+ may_change: str(get(life, "may_change")),
683
+ as_of: str(get(life, "as_of")),
684
+ scope: str(get(raw, "scope")),
685
+ did_line: str(get(raw, "did_line")),
686
+ instructions: str(get(raw, "instructions")),
687
+ told: seq(get(raw, "told")).map(function (t) { return told(map(t)); }),
688
+ deadlines: deadlines.map(deadline),
689
+ deadline_note: deadlines.length ? str(get(deadlines[0], "note")) : null,
690
+ cancellations: seq(get(raw, "cancellations")).map(map).map(function (c) {
691
+ return { proven: strings(get(c, "proven")), not_proven: strings(get(c, "not_proven")), confirmed: get(c, "merchant") === "confirmed", steps: strings(get(c, "steps")) };
692
+ }),
693
+ merchant: seq(get(raw, "merchant")).map(function (m) { return merchant(map(m)); }),
694
+ email_scope: str(get(raw, "email_scope")),
695
+ agent_anomalies: side("agent"),
696
+ counterparty_anomalies: side("counterparty"),
697
+ withheld: strings(get(raw, "withheld")),
698
+ journey: journeyOf(get(raw, "journey")),
699
+ };
700
+ }
701
+ // The context, read once: headers by id and disclosed deal payloads.
702
+ function Reader(v) {
703
+ this.v = v;
704
+ var headers = new Map();
705
+ seq(v.bundle.records).map(map).forEach(function (r) {
706
+ if (typeof r.capsule_id === "string")
707
+ headers.set(r.capsule_id, r);
708
+ });
709
+ this.headers = headers;
710
+ }
711
+ Reader.prototype.payload = function (cid) {
712
+ var value = this.v.disclosed(cid, "agent_input");
713
+ return isMap(value) ? value : null;
714
+ };
715
+ Reader.prototype.disclosure = function (cid) {
716
+ if (!this.headers.has(cid))
717
+ return "not_present";
718
+ return this.payload(cid) !== null ? "disclosed" : "withheld";
719
+ };
720
+ Reader.prototype.isReport = function (cid) {
721
+ var payload = this.payload(cid);
722
+ if (payload !== null)
723
+ return get(payload, "type") === REPORT_TYPE;
724
+ return get(this.headers.get(cid) || {}, "action_id") === REPORT_ACTION_ID;
725
+ };
726
+ Reader.prototype.log = function (cid) {
727
+ var coords = map(get(map(get(this.v.memberships, cid)), "log_coordinates"));
728
+ var logId = str(get(coords, "log_id")), s = int(get(coords, "seq")), leaf = int(get(coords, "leaf_index"));
729
+ return logId !== null && s !== null && leaf !== null ? { log_id: logId, seq: s, leaf_index: leaf } : null;
730
+ };
731
+ // The named report is the standalone record, not a record on the log.
732
+ Reader.prototype.standalone = function () {
733
+ var extensions = map(get(this.v.bundle, "extensions"));
734
+ var named = str(get(map(get(extensions, EXTENSION)), "sealed_report"));
735
+ return named !== null && !this.headers.has(named) && own(extensions, STANDALONE_EXTENSION);
736
+ };
737
+ // The report in x-deal-report/v0 when it is the named one; null when `named`
738
+ // is a record on the log. This script cannot check that record's signature:
739
+ // it is read only when capsulectl verify reported the check as passed
740
+ // (assurance.report_checked), and shown with that reported status only.
741
+ Reader.prototype.standaloneReport = function (named) {
742
+ var content = this.standaloneContent(named);
743
+ return content === null ? null : get(content, "report");
744
+ };
745
+ // The whole payload of the standalone report (its `report` is the text body).
746
+ Reader.prototype.standaloneContent = function (named) {
747
+ var self = this;
748
+ if (this.headers.has(named))
749
+ return null;
750
+ var block = map(get(map(get(this.v.bundle, "extensions")), STANDALONE_EXTENSION));
751
+ var record = map(get(block, "record"));
752
+ if (get(record, "capsule_id") !== named || Object.keys(block).sort().join() !== "agent_input,record" || get(record, "action_id") !== REPORT_ACTION_ID) {
753
+ throw new Unavailable("the named report " + named + " is neither a record in the bundle nor the one in " + STANDALONE_EXTENSION);
754
+ }
755
+ if (this.v.assurance.report_checked !== "pass")
756
+ throw new Unavailable("the verifier did not report a passing check of the standalone report");
757
+ if (this.v.records.some(function (cid) { return self.isReport(cid); }))
758
+ throw new Unavailable("a standalone report and a report record are both in the bundle");
759
+ var content = map(get(block, "agent_input"));
760
+ var rep = get(content, "report");
761
+ if (get(content, "type") !== REPORT_TYPE || !isMap(rep))
762
+ throw new Unavailable("the standalone report carries no report object");
763
+ return content;
764
+ };
765
+ Reader.prototype.sealedReport = function () {
766
+ var self = this;
767
+ var extension = map(get(map(get(this.v.bundle, "extensions")), EXTENSION));
768
+ var named = str(get(extension, "sealed_report"));
769
+ if (named === null)
770
+ throw new Unavailable("the x-deal-v0 extension names no sealed report");
771
+ var standalone = this.standaloneReport(named);
772
+ if (standalone !== null)
773
+ return [named, standalone];
774
+ var disclosed = this.v.records.filter(function (cid) { return self.isReport(cid) && self.payload(cid) !== null; });
775
+ if (!(disclosed.length === 1 && disclosed[0] === named)) {
776
+ throw new Unavailable("disclosed deal reports are not exactly the named one, " + named);
777
+ }
778
+ var rep = get(this.payload(named) || {}, "report");
779
+ if (!isMap(rep))
780
+ throw new Unavailable("the sealed report carries no report object");
781
+ return [named, rep];
782
+ };
783
+ function stepOf(reader, cid, entry) {
784
+ var payload = reader.payload(cid);
785
+ var recordType = null;
786
+ var body = {};
787
+ if (payload !== null) {
788
+ var typed = str(get(payload, "type"));
789
+ recordType = or(str(get(map(get(payload, EXTENSION)), "record_type")), or(str(get(payload, "record_type")), typed !== null && own(RECORD_TYPE_BY_TYPED, typed) ? typed : null));
790
+ body = map(get(payload, "body"));
791
+ }
792
+ var key = or(recordType, "");
793
+ var kind = own(RECORD_TYPE_BY_TYPED, key) ? RECORD_TYPE_BY_TYPED[key] : recordType;
794
+ var section;
795
+ if (kind !== null)
796
+ section = own(SECTION_BY_RECORD_TYPE, kind) ? SECTION_BY_RECORD_TYPE[kind] : "other";
797
+ else {
798
+ var stepKind = or(str(get(entry, "kind")), "");
799
+ section = own(SECTION_BY_STEP_KIND, stepKind) ? SECTION_BY_STEP_KIND[stepKind] : "other";
800
+ }
801
+ return {
802
+ capsule_id: cid,
803
+ disclosure: reader.disclosure(cid),
804
+ section: section,
805
+ record_type: recordType,
806
+ log: reader.log(cid),
807
+ key_id: str(get(reader.headers.get(cid) || {}, "key_id")),
808
+ facts: facts(kind, body),
809
+ line: str(get(entry, "line")),
810
+ at: str(get(entry, "at")),
811
+ n: int(get(entry, "n")),
812
+ };
813
+ }
814
+ function producerOf(payload) {
815
+ var producer = map(or(get(map(get(payload, EXTENSION)), "producer"), get(payload, "producer")));
816
+ var version = str(get(producer, "version"));
817
+ if (version === null)
818
+ return null;
819
+ return or(str(get(producer, "name")), "an unnamed producer") + " " + version + " (" + or(str(get(producer, "commit")), "unknown") + ")";
820
+ }
821
+ function producerNameOf(payload) {
822
+ var producer = map(or(get(map(get(payload, EXTENSION)), "producer"), get(payload, "producer")));
823
+ return str(get(producer, "version")) === null ? null : str(get(producer, "name"));
824
+ }
825
+ function committed(reader, stepId, commitmentOf, nonce, text, label) {
826
+ label = label === undefined ? null : label;
827
+ if (stepId === null || reader.disclosure(stepId) === "not_present")
828
+ return { state: "not_present", step: stepId, text: null, label: label };
829
+ var payload = reader.payload(stepId);
830
+ if (payload === null)
831
+ return { state: "withheld", step: stepId, text: null, label: label };
832
+ var state = checkOpening(commitmentOf(payload), nonce, text);
833
+ return { state: state, step: stepId, text: state === "opened" ? str(text) : null, label: label };
834
+ }
835
+ function askedOf(reader, raw) {
836
+ var opening = map(get(raw, "asked_opening"));
837
+ return committed(reader, str(get(raw, "asked_step")), function (p) {
838
+ return get(map(get(map(get(p, "body")), "intent")), "verbatim_commitment");
839
+ }, get(opening, "nonce"), get(opening, "text"));
840
+ }
841
+ function statementsOf(reader, raw) {
842
+ return seq(get(raw, "representations")).map(map).map(function (r) {
843
+ var index = int(get(r, "index"));
844
+ var claimOf = function (payload) {
845
+ var body = map(get(payload, "body"));
846
+ if (index === null)
847
+ return body;
848
+ var claims = seq(get(body, "claims"));
849
+ return index >= 0 && index < claims.length ? map(claims[index]) : {};
850
+ };
851
+ var commitmentOf = function (payload) {
852
+ var c = claimOf(payload);
853
+ return get(c, "source_kind") === "agent" ? get(c, "text_commitment") : null;
854
+ };
855
+ var stepId = str(get(r, "step"));
856
+ var payload = stepId ? reader.payload(stepId) : null;
857
+ var label = payload !== null ? str(get(claimOf(payload), "class")) : null;
858
+ return committed(reader, stepId, commitmentOf, get(r, "nonce"), get(r, "text"), label);
859
+ });
860
+ }
861
+ function partOf(step, name) {
862
+ if (step === null || step === undefined)
863
+ return "not_present";
864
+ if (step.disclosure !== "disclosed")
865
+ return step.disclosure;
866
+ for (var i = 0; i < step.facts.length; i++)
867
+ if (step.facts[i].name === name)
868
+ return step.facts[i];
869
+ return "not_present";
870
+ }
871
+ function headlineOf(steps, rootId, rep) {
872
+ var opened = steps.find(function (s) { return s.section === "authorized"; }) || null;
873
+ var it = partOf(opened, "item");
874
+ if (it === "not_present")
875
+ it = partOf(opened, "asked.item");
876
+ var rootStep = steps.find(function (s) { return s.capsule_id === rootId; }) || null;
877
+ var acted = rootStep !== null && rootStep.section === "acted" ? rootStep : (steps.slice().reverse().find(function (s) { return s.section === "acted"; }) || null);
878
+ return { deal_type: partOf(opened, "deal_type"), item: it, amount: partOf(acted, "amount"), state: rep.state };
879
+ }
880
+ function stepIn(model, cid) {
881
+ return model.steps.find(function (s) { return s.capsule_id === cid; }) || null;
882
+ }
883
+ function copyAudience(v) {
884
+ var raw = new Reader(v).sealedReport()[1];
885
+ var audience = str(get(raw, "audience"));
886
+ if (audience === null)
887
+ throw new Unavailable("the sealed report names no audience");
888
+ return audience;
889
+ }
890
+ function namedDeals(v) {
891
+ var named = [];
892
+ v.records.forEach(function (cid) {
893
+ var payload = v.disclosed(cid, "agent_input");
894
+ if (!isMap(payload))
895
+ return;
896
+ var deal = or(str(get(map(get(payload, EXTENSION)), "deal_id")), or(str(get(payload, "deal_id")), str(get(payload, "chain_id"))));
897
+ if (deal !== null && named.indexOf(deal) < 0)
898
+ named.push(deal);
899
+ });
900
+ return named.sort(codepointCompare);
901
+ }
902
+ // model.build_receipt. `audience` null: the copy's own (see the file comment).
903
+ function buildReceipt(v, audience) {
904
+ if (!v.verified)
905
+ throw new Unavailable("the bundle did not verify");
906
+ var reader = new Reader(v);
907
+ var sealed = reader.sealedReport();
908
+ var reportId = sealed[0], raw = sealed[1];
909
+ var rep = report(reportId, raw);
910
+ if (audience !== null && rep.audience !== audience)
911
+ throw new Unavailable("this copy was cut for " + rep.audience + ", not " + audience);
912
+ var entries = new Map();
913
+ seq(get(raw, "steps")).map(map).forEach(function (e) {
914
+ var cid = str(get(e, "capsule_id"));
915
+ if (cid !== null)
916
+ entries.set(cid, e);
917
+ });
918
+ var order = v.records.filter(function (cid) { return !reader.isReport(cid); });
919
+ var cited = Array.from(entries.keys());
920
+ rep.did.concat(rep.told, rep.later).forEach(function (i) { cited = cited.concat(i.steps); });
921
+ cited.forEach(function (cid) {
922
+ if (order.indexOf(cid) < 0 && !reader.isReport(cid))
923
+ order.push(cid);
924
+ });
925
+ var steps = order.map(function (cid) { return stepOf(reader, cid, entries.has(cid) ? entries.get(cid) : {}); });
926
+ v.records.forEach(function (cid) {
927
+ if (!reader.isReport(cid))
928
+ return;
929
+ steps.push({
930
+ capsule_id: cid, disclosure: reader.disclosure(cid), section: "report", record_type: cid === reportId ? REPORT_TYPE : null,
931
+ log: reader.log(cid), key_id: str(get(reader.headers.get(cid), "key_id")), facts: [], line: null, at: null, n: null,
932
+ });
933
+ });
934
+ var payloads = v.records.map(function (cid) { return reader.payload(cid); }).filter(function (p) { return p !== null; });
935
+ var demo = payloads.some(function (p) {
936
+ return get(map(get(p, EXTENSION)), "record_type") === "baseline" && get(map(get(p, "body")), "demo") === true;
937
+ });
938
+ return {
939
+ deal_id: or(str(get(raw, "deal_id")), ""),
940
+ demo: demo,
941
+ headline: headlineOf(steps, v.root, rep),
942
+ asked: askedOf(reader, raw),
943
+ statements: statementsOf(reader, raw),
944
+ steps: steps,
945
+ report: rep,
946
+ producers: distinct(payloads.map(producerOf)),
947
+ producer_names: distinct(payloads.map(producerNameOf)),
948
+ bundle_digest: v.assurance.bundle_digest,
949
+ witnessed: v.assurance.witnesses,
950
+ countersignatures: v.assurance.countersignatures,
951
+ verification: v.verification,
952
+ report_checked: reader.standalone() ? or(str(v.assurance.report_checked), null) : null,
953
+ };
954
+ }
955
+ // ---- the v1 deal receipt (evidencebook docs/design/461-deal-profile.md, section 9) ----
956
+ //
957
+ // A v1 deal has no close and no status a record holds: the holder's sealed
958
+ // report lists each row with the status evidencebook's rowstatus computed,
959
+ // and this page only shows it. It never computes or corrects one, and it
960
+ // reads a word outside section 9's closed sets as an unknown version of the
961
+ // report (the module declines), never as a word of its own.
962
+ var V1_AUDIENCES = ["keep", "counterparty", "adjudicator"];
963
+ var V1_START_STATES = ["started", "awaiting_agreement", "not_started"];
964
+ var V1_START_BY = ["offerer_in_time", "acceptor_named", "first_act"];
965
+ var V1_ROWS_STATES = ["listed", "not_started", "withheld"];
966
+ var V1_STATUSES = ["not_reached", "not_due", "no_statement", "waiting", "uncontested", "agreed_so_far", "agreed", "in_disagreement", "in_dispute", "ruled"];
967
+ var V1_VALUES = ["met", "not_met"];
968
+ var V1_REMEDIES = ["none", "due", "made", "not_honoured", "not_counted"];
969
+ var V1_SIDES = ["buyer", "seller"];
970
+ var V1_CHECKS = ["passed", "failed", "not_run", "not_recomputed"];
971
+ function closedWord(list, value, what) {
972
+ if (typeof value !== "string" || list.indexOf(value) < 0)
973
+ throw new Unavailable("the v1 report's " + what + " is not one of " + list.join(", "));
974
+ return value;
975
+ }
976
+ function optionalWord(list, value, what) { return value === null || value === undefined ? null : closedWord(list, value, what); }
977
+ // A row date is an RFC 3339 UTC time to the second, or the word not_set.
978
+ var RFC3339_UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
979
+ // The regex checks the shape; the round trip rejects a date Date.parse would silently move (30 February, hour 24).
980
+ function validUtcTime(t) {
981
+ if (!RFC3339_UTC.test(t))
982
+ return false;
983
+ var ms = Date.parse(t);
984
+ return !isNaN(ms) && new Date(ms).toISOString().slice(0, 19) + "Z" === t;
985
+ }
986
+ function rowDate(value, what) {
987
+ var t = str(value);
988
+ if (t === null || (t !== "not_set" && !validUtcTime(t))) {
989
+ throw new Unavailable("the v1 report's " + what + " is neither an RFC 3339 UTC time nor not_set");
990
+ }
991
+ return t;
992
+ }
993
+ function flag(o, k, what) {
994
+ var value = get(o, k);
995
+ if (typeof value !== "boolean")
996
+ throw new Unavailable("the v1 report's " + what + " is not a boolean");
997
+ return value;
998
+ }
999
+ // The members section 9's report has; evidencebook's VerifyReport refuses any other.
1000
+ var V1_REPORT_MEMBERS = ["type", "profile", "deal_id", "audience", "nonce", "as_of", "deal_checkpoint", "pack_digest", "start", "settled", "rows_state", "rows", "rests_on", "report", "disputes", "rulings_unnamed", "status_fact", "referee"];
1001
+ // Every field name section 9's report has, at any level. VerifyReport refuses a member spelled otherwise (another case, or
1002
+ // U+017F long s and U+212A Kelvin sign, which case-fold to s and k): the reader reads exact names only, and declines the
1003
+ // report rather than ignore a second spelling beside, or in place of, the one it reads.
1004
+ var V1_FIELD_NAMES = ["against", "as_of", "audience", "by", "check", "claimant", "counted", "counterparty", "counterparty_kind", "counterparty_layer", "counterparty_proof", "current", "deal_checkpoint", "deal_id", "disputes", "due", "final", "fork_at", "forum", "id", "key_id", "last", "late", "local", "log_id", "mmr_size", "nonce", "outcome", "owed", "owed_by", "own", "pack_digest", "profile", "record", "referee", "relied_on", "remedy", "remedy_due", "remedy_made", "report", "rests_on", "root", "row", "rows", "rows_state", "ruling", "rulings_unnamed", "settled", "side", "size", "start", "state", "statements", "status", "status_fact", "time", "type", "url", "value", "window_end", "witnessed", "witnesses"];
1005
+ function foldName(k) { return String(k).toUpperCase().toLowerCase(); }
1006
+ function refuseRespelledNames(node) {
1007
+ if (Array.isArray(node)) {
1008
+ node.forEach(refuseRespelledNames);
1009
+ return;
1010
+ }
1011
+ if (!isMap(node))
1012
+ return;
1013
+ Object.keys(node).forEach(function (k) {
1014
+ if (V1_FIELD_NAMES.indexOf(k) < 0) {
1015
+ var folded = foldName(k);
1016
+ if (V1_FIELD_NAMES.some(function (n) { return foldName(n) === folded; }))
1017
+ throw new Unavailable("the v1 report has a member spelled otherwise than a field name: " + k);
1018
+ }
1019
+ // The report's text and a term's owed are free-form: their names are not the profile's.
1020
+ if (k !== "report" && k !== "owed")
1021
+ refuseRespelledNames(node[k]);
1022
+ });
1023
+ }
1024
+ function failV1(what) { throw new Unavailable("the v1 report's " + what); }
1025
+ function dealRow(raw) {
1026
+ if (!isMap(raw))
1027
+ throw new Unavailable("a row of the v1 report is not an object");
1028
+ var r = raw;
1029
+ var id = str(get(r, "id"));
1030
+ if (id === null || id === "")
1031
+ throw new Unavailable("a row of the v1 report has no id");
1032
+ var ruling = get(r, "ruling");
1033
+ // section 9: the first final ruling rowstatus applied, or null.
1034
+ if (ruling !== null && (!isMap(ruling) || flag(ruling, "final", "ruling final") !== true))
1035
+ throw new Unavailable("the v1 report's ruling is not a final ruling or null");
1036
+ // A ruling names its side, buyer, seller or null, and always carries the member.
1037
+ if (ruling !== null && !own(ruling, "against"))
1038
+ throw new Unavailable("the v1 report's ruling has no against member");
1039
+ var relied = get(r, "relied_on");
1040
+ if (!Array.isArray(relied))
1041
+ throw new Unavailable("the v1 report's row relied_on is not an array");
1042
+ // VerifyReport refuses a null or mistyped list or object where section 9 has one.
1043
+ if (!isMap(get(r, "owed")))
1044
+ throw new Unavailable("the v1 report's row owed is not an object");
1045
+ var late = get(r, "late");
1046
+ if (own(r, "late")) {
1047
+ if (!isMap(late) || !Array.isArray(get(late, "statements")) || !Array.isArray(get(late, "disputes")))
1048
+ throw new Unavailable("the v1 report's row late is not {statements, disputes} lists");
1049
+ }
1050
+ return {
1051
+ id: id,
1052
+ owed_by: or(str(get(r, "owed_by")), ""),
1053
+ due: rowDate(get(r, "due"), "due"),
1054
+ window_end: rowDate(get(r, "window_end"), "window_end"),
1055
+ status: closedWord(V1_STATUSES, get(r, "status"), "row status"),
1056
+ value: optionalWord(V1_VALUES, get(r, "value"), "row value"),
1057
+ remedy: optionalWord(V1_REMEDIES, get(r, "remedy"), "row remedy"),
1058
+ remedy_made: flag(r, "remedy_made", "row remedy_made"),
1059
+ local: flag(r, "local", "row local"),
1060
+ check: closedWord(V1_CHECKS, get(r, "check"), "row check"),
1061
+ // `late` (optional in section 9, undefined until rowstatus reports it) is not read: the page shows no late line.
1062
+ ruling: isMap(ruling)
1063
+ ? { value: or(str(get(ruling, "value")), ""), against: optionalWord(V1_SIDES, get(ruling, "against"), "ruling against") }
1064
+ : null,
1065
+ relied_on: relied.map(function (e) {
1066
+ if (!isMap(e))
1067
+ throw new Unavailable("a relied_on entry of the v1 report is not an object");
1068
+ var time = str(get(e, "time"));
1069
+ var named = flag(e, "witnessed", "relied_on named-witness flag");
1070
+ // A time is given exactly when a named witness receipt gives it (section 9).
1071
+ if (named !== (time !== null))
1072
+ throw new Unavailable("a relied_on entry's named-witness flag does not match its time");
1073
+ return { record: or(str(get(e, "record")), ""), side: or(str(get(e, "side")), ""), time: time, named_witness: named };
1074
+ }),
1075
+ };
1076
+ }
1077
+ // Reader.sealedReport's twin for v1: the named report is always standalone (section 9).
1078
+ Reader.prototype.dealReportV1 = function () {
1079
+ var extensions = map(get(this.v.bundle, "extensions"));
1080
+ if (own(extensions, EXTENSION))
1081
+ throw new Unavailable("a deal has one version: the bundle carries x-deal-v0 beside x-deal-v1");
1082
+ var named = str(get(map(get(extensions, EXTENSION_V1)), "sealed_report"));
1083
+ if (named === null)
1084
+ throw new Unavailable("the x-deal-v1 extension names no sealed report");
1085
+ if (!own(extensions, STANDALONE_EXTENSION))
1086
+ throw new Unavailable("the v1 report is standalone and the bundle carries none in " + STANDALONE_EXTENSION);
1087
+ var content = this.standaloneContent(named);
1088
+ if (content === null)
1089
+ throw new Unavailable("the v1 report is a record on a log; a v1 report travels standalone");
1090
+ return [named, content];
1091
+ };
1092
+ // The settle legs a payment row relied on (evidencebook#588, docs/design/461-deal-profile.md
1093
+ // section 9, "The payment legs and the bundle extension"). The x-deal-v1 extension is exactly
1094
+ // {sealed_report, book}, and book is {agreement, relied_on}: relied_on holds, keyed by record id, the
1095
+ // book pair of every record the holder's rows rely on, so a leg is read by its relied_on id. VerifyReportBundle
1096
+ // refuses a bundle without the book, so this page does too. It checks the shape and that each key is its
1097
+ // pair's Capsule id; it does not check who signed a record or the logs (the check capsulectl runs does
1098
+ // that), so the side shown is the report's own. It picks no leg and derives no verdict from one: `check`
1099
+ // stays the only verdict.
1100
+ function dealBook(extension) {
1101
+ Object.keys(extension).forEach(function (k) {
1102
+ if (k !== "sealed_report" && k !== "book")
1103
+ throw new Unavailable("the x-deal-v1 extension has a member section 9 does not: " + k);
1104
+ });
1105
+ var book = get(extension, "book");
1106
+ if (!isMap(book))
1107
+ throw new Unavailable("the x-deal-v1 extension carries no book object");
1108
+ Object.keys(book).forEach(function (k) {
1109
+ if (k !== "agreement" && k !== "relied_on")
1110
+ throw new Unavailable("the x-deal-v1 extension's book has a member section 9 does not: " + k);
1111
+ });
1112
+ if (!isMap(get(book, "agreement")) || !isMap(get(book, "relied_on")))
1113
+ throw new Unavailable("the x-deal-v1 extension's book has no agreement and relied_on objects");
1114
+ var relied = get(book, "relied_on");
1115
+ Object.keys(relied).forEach(function (k) {
1116
+ var pair = relied[k];
1117
+ if (!isMap(pair) || !isMap(get(pair, "record")))
1118
+ throw new Unavailable("a book pair of the x-deal-v1 extension is not a Capsule pair");
1119
+ if (get(get(pair, "record"), "capsule_id") !== k)
1120
+ throw new Unavailable("a book pair's Capsule id is not its key in the x-deal-v1 extension: " + k);
1121
+ });
1122
+ return relied;
1123
+ }
1124
+ // A money member of a settlement as recorded: its value counted in 10^-assetScale of assetCode. A member
1125
+ // this cannot write that way (the draft allows any scale and any digit string) is shown as recorded, never
1126
+ // a reason to decline the receipt.
1127
+ // The payer's leg records `amount`, the payee's `received` and `receive_fee` (draft-mih-agent-settlement-records).
1128
+ var LEG_MONEY = ["amount", "received", "receive_fee"];
1129
+ function legAmount(a) {
1130
+ if (!isMap(a))
1131
+ return "-";
1132
+ var value = str(get(a, "value")), code = str(get(a, "assetCode")), scale = int(get(a, "assetScale"));
1133
+ if (value === null || !/^-?\d+$/.test(value) || code === null || code === "" || scale === null || scale < 0 || scale > 255) {
1134
+ return [value, code, scale === null ? null : "scale " + scale].filter(function (x) { return x !== null; }).join(" ") || "-";
1135
+ }
1136
+ if (!scale)
1137
+ return value + " " + code;
1138
+ var sign = value.charAt(0) === "-" ? "-" : "";
1139
+ var digits = value.replace("-", "").padStart(scale + 1, "0");
1140
+ return sign + digits.slice(0, digits.length - scale) + "." + digits.slice(digits.length - scale) + " " + code;
1141
+ }
1142
+ // One leg, as its record states it: the settlement member's names and values, the record id, and the side
1143
+ // the report names (or, in a copy that withholds the rows, the settlement's own sealer_role).
1144
+ function readLeg(record, id, side) {
1145
+ var settlement = get(record, "settlement");
1146
+ if (!isMap(settlement))
1147
+ throw new Unavailable("a leg's settlement is not an object");
1148
+ var leg = str(get(settlement, "leg")), status = str(get(settlement, "status"));
1149
+ if (leg === null || status === null)
1150
+ throw new Unavailable("a leg's settlement has no leg and status");
1151
+ var ref = get(settlement, "payment_ref");
1152
+ return {
1153
+ record: id,
1154
+ side: side,
1155
+ sealer_role: str(get(settlement, "sealer_role")),
1156
+ leg: leg,
1157
+ status: status,
1158
+ money: LEG_MONEY.filter(function (k) { return own(settlement, k); }).map(function (k) { return [k, legAmount(get(settlement, k))]; }),
1159
+ observed_at: str(get(settlement, "observed_at")),
1160
+ payment_ref: isMap(ref) ? { type: or(str(get(ref, "type")), ""), value: or(str(get(ref, "value")), "") } : null,
1161
+ };
1162
+ }
1163
+ // A copy that withholds the rows (an adjudicator's) ties no record to a term: every settle leg the book holds,
1164
+ // in the book's order, with no side but the settlement's own sealer_role.
1165
+ function bookLegs(relied) {
1166
+ return Object.keys(relied).filter(function (k) { return own(get(relied[k], "record"), "settlement"); })
1167
+ .map(function (k) { return readLeg(get(relied[k], "record"), k, null); });
1168
+ }
1169
+ function legsOf(rows, rowsState, relied) {
1170
+ // Rows listed: the book holds exactly the records they name (section 9).
1171
+ if (rowsState === "listed") {
1172
+ var named = {};
1173
+ rows.forEach(function (row) { row.relied_on.forEach(function (e) { named[e.record] = true; }); });
1174
+ Object.keys(relied).forEach(function (k) { if (!own(named, k))
1175
+ throw new Unavailable("the x-deal-v1 extension's book holds a record no row relies on: " + k); });
1176
+ }
1177
+ return rows.map(function (row) {
1178
+ var legs = [];
1179
+ row.relied_on.forEach(function (e) {
1180
+ if (!own(relied, e.record))
1181
+ throw new Unavailable("a record a row relies on is not in the x-deal-v1 extension's book: " + e.record);
1182
+ var record = get(get(relied, e.record), "record");
1183
+ if (!own(record, "settlement"))
1184
+ return;
1185
+ legs.push(readLeg(record, e.record, e.side));
1186
+ });
1187
+ return legs;
1188
+ });
1189
+ }
1190
+ function buildDeal(v, audience) {
1191
+ if (!v.verified)
1192
+ throw new Unavailable("the bundle did not verify");
1193
+ var reader = new Reader(v);
1194
+ var sealed = reader.dealReportV1();
1195
+ var content = sealed[1];
1196
+ if (get(content, "profile") !== EXTENSION_V1)
1197
+ throw new Unavailable("the sealed report is not an x-deal-v1 report");
1198
+ refuseRespelledNames(content);
1199
+ Object.keys(content).forEach(function (k) { if (V1_REPORT_MEMBERS.indexOf(k) < 0)
1200
+ throw new Unavailable("the v1 report has a member section 9 does not: " + k); });
1201
+ var cut = closedWord(V1_AUDIENCES, get(content, "audience"), "audience");
1202
+ if (audience !== null && cut !== audience)
1203
+ throw new Unavailable("this copy was cut for " + cut + ", not " + audience);
1204
+ var startRaw = map(get(content, "start"));
1205
+ var start = {
1206
+ state: closedWord(V1_START_STATES, get(startRaw, "state"), "start state"),
1207
+ local: flag(startRaw, "local", "start local"),
1208
+ by: optionalWord(V1_START_BY, get(startRaw, "by"), "start by"),
1209
+ };
1210
+ if (!isMap(get(content, "report")))
1211
+ throw new Unavailable("the v1 report's report text is not an object");
1212
+ var unnamed = get(content, "rulings_unnamed");
1213
+ // Both are left out at zero (section 9), so a present one is a positive count, or a non-empty list.
1214
+ if (own(content, "rulings_unnamed") && (int(unnamed) === null || unnamed < 1))
1215
+ throw new Unavailable("the v1 report's rulings_unnamed is not a positive count");
1216
+ if (own(content, "disputes") && (!Array.isArray(get(content, "disputes")) || !get(content, "disputes").length))
1217
+ throw new Unavailable("the v1 report's disputes is not a non-empty list");
1218
+ var rowsState = closedWord(V1_ROWS_STATES, get(content, "rows_state"), "rows_state");
1219
+ var rawRows = get(content, "rows");
1220
+ if (!Array.isArray(rawRows))
1221
+ throw new Unavailable("the v1 report's rows is not an array");
1222
+ var rows = rawRows.map(dealRow);
1223
+ var relied = dealBook(map(get(map(get(v.bundle, "extensions")), EXTENSION_V1)));
1224
+ var legs = legsOf(rows, rowsState, relied);
1225
+ rows.forEach(function (row, i) { row.legs = legs[i]; });
1226
+ var withheldLegs = rowsState === "withheld" ? bookLegs(relied) : [];
1227
+ // section 9: an adjudicator's copy, and only it, withholds the rows.
1228
+ if ((rowsState === "withheld") !== (cut === "adjudicator"))
1229
+ throw new Unavailable("the v1 report's rows_state is withheld exactly on an adjudicator's copy");
1230
+ if (rowsState !== "listed" && rows.length)
1231
+ throw new Unavailable("the v1 report lists rows while its rows_state is " + rowsState);
1232
+ var rests = map(get(content, "rests_on"));
1233
+ var theirs = get(rests, "counterparty");
1234
+ var rep = report(sealed[0], map(get(content, "report")));
1235
+ rep.audience = cut;
1236
+ return {
1237
+ deal_id: or(str(get(content, "deal_id")), ""),
1238
+ audience: cut,
1239
+ as_of: or(str(get(content, "as_of")), ""),
1240
+ pack_digest: str(get(content, "pack_digest")),
1241
+ start: start,
1242
+ settled: flag(content, "settled", "settled"),
1243
+ rows_state: rowsState,
1244
+ rows: rows,
1245
+ withheld_legs: withheldLegs,
1246
+ rests_on: {
1247
+ own_size: int(get(map(get(rests, "own")), "size")),
1248
+ counterparty: isMap(theirs) ? { counted: int(get(theirs, "counted")), fork_at: int(get(theirs, "fork_at")) } : null,
1249
+ // The adjudicator's copy omits these two (section 9's audience table): absent is not zero.
1250
+ counterparty_layer: own(rests, "counterparty_layer") ? flag(rests, "counterparty_layer", "counterparty_layer") : null,
1251
+ witnesses: own(rests, "witnesses") ? (Array.isArray(rests.witnesses) ? rests.witnesses.length : failV1("witnesses is not an array")) : null,
1252
+ },
1253
+ report: rep,
1254
+ bundle_digest: v.assurance.bundle_digest,
1255
+ witnessed: v.assurance.witnesses,
1256
+ countersignatures: v.assurance.countersignatures,
1257
+ verification: v.verification,
1258
+ report_checked: or(str(v.assurance.report_checked), null),
1259
+ };
1260
+ }
1261
+ // ---- the seller model (seller.py) -----------------------------------------
1262
+ function sellerAmount(body, minorKey) {
1263
+ var minor = get(body, minorKey || "amount_minor"), currency = str(get(body, "currency"));
1264
+ if (typeof minor === "number" && Number.isInteger(minor) && currency)
1265
+ return fact("amount", formatAmount(minor, currency), "amount");
1266
+ return null;
1267
+ }
1268
+ function recordTypeOf(payload) {
1269
+ return or(str(get(payload, "type")), str(get(map(get(payload, EXTENSION)), "record_type")));
1270
+ }
1271
+ function refDigests(payload, rel) {
1272
+ var refs = or(get(payload, "refs"), get(map(get(payload, EXTENSION)), "refs"));
1273
+ var out = [];
1274
+ seq(refs).forEach(function (ref) {
1275
+ ref = map(ref);
1276
+ var digest = str(get(ref, "digest"));
1277
+ if (get(ref, "rel") === rel && digest !== null)
1278
+ out.push(digest);
1279
+ });
1280
+ return out;
1281
+ }
1282
+ function commitmentsOf(step, body, prefix) {
1283
+ prefix = prefix || "";
1284
+ var out = [];
1285
+ sortedKeys(body).forEach(function (key) {
1286
+ var value = body[key];
1287
+ if (key.slice(-"_commitment".length) === "_commitment") {
1288
+ var c = str(value);
1289
+ if (c !== null)
1290
+ out.push([step, prefix + key, c]);
1291
+ return;
1292
+ }
1293
+ out = out.concat(commitmentsOf(step, map(value), prefix + key + "."));
1294
+ });
1295
+ return out;
1296
+ }
1297
+ function buildSeller(v, audience) {
1298
+ if (!sellerKindEngaged(v))
1299
+ throw new Unavailable("the copy does not engage " + SELLER_KIND);
1300
+ var role = sealedSide(v);
1301
+ if (role !== "seller")
1302
+ throw new Unavailable("the copy engages " + SELLER_KIND + " and its sealed records show side " + role + ", not seller");
1303
+ var receipt = buildReceipt(v, audience);
1304
+ var raw = new Reader(v).sealedReport()[1];
1305
+ var payloads = new Map();
1306
+ receipt.steps.forEach(function (step) {
1307
+ var payload = v.disclosed(step.capsule_id, "agent_input");
1308
+ if (isMap(payload) && step.section !== "report")
1309
+ payloads.set(step.capsule_id, payload);
1310
+ });
1311
+ var kindOf = new Map();
1312
+ iter(get(raw, "steps")).map(map).forEach(function (entry) {
1313
+ var cid = str(get(entry, "capsule_id")), kind = str(get(entry, "kind"));
1314
+ if (cid !== null && kind !== null)
1315
+ kindOf.set(cid, kind);
1316
+ });
1317
+ var bodies = function (recordType) {
1318
+ var out = [];
1319
+ payloads.forEach(function (p, cid) { if (recordTypeOf(p) === recordType)
1320
+ out.push([cid, map(get(p, "body"))]); });
1321
+ return out;
1322
+ };
1323
+ var withheld = function (kind) {
1324
+ return receipt.steps.filter(function (s) { return s.disclosure === "withheld" && kindOf.get(s.capsule_id) === kind; }).map(function (s) { return s.capsule_id; });
1325
+ };
1326
+ var byDigest = new Map();
1327
+ var digestOfPayload = new Map();
1328
+ payloads.forEach(function (p, cid) {
1329
+ var d = recordDigest(p);
1330
+ digestOfPayload.set(cid, d);
1331
+ if (d !== null)
1332
+ byDigest.set(d, cid);
1333
+ });
1334
+ var acceptances = [];
1335
+ bodies("action-approval/v0").forEach(function (pair) {
1336
+ var cid = pair[0], body = pair[1];
1337
+ if (get(body, "kind") !== ACCEPTANCE_KIND)
1338
+ return;
1339
+ var named = str(get(map(get(body, "proposed_action_ref")), "digest"));
1340
+ acceptances.push({
1341
+ step: cid, channel: str(get(body, "channel")), observed_at: str(get(body, "observed_at")), offer_digest: named,
1342
+ offer: named && byDigest.has(named) ? byDigest.get(named) : null,
1343
+ });
1344
+ });
1345
+ var proposed = bodies("proposed-action/v0").filter(function (pair) { return ["offer", "commit"].indexOf(get(pair[1], "action")) >= 0; });
1346
+ var supersededBy = new Map();
1347
+ proposed.forEach(function (pair) {
1348
+ refDigests(payloads.get(pair[0]), "supersedes").forEach(function (d) {
1349
+ var old = byDigest.get(d);
1350
+ if (truthy(old))
1351
+ supersededBy.set(old, pair[0]);
1352
+ });
1353
+ });
1354
+ var acceptedBy = new Map();
1355
+ acceptances.forEach(function (a) { if (a.offer !== null)
1356
+ acceptedBy.set(a.offer, a.step); });
1357
+ var offers = proposed.map(function (pair) {
1358
+ var cid = pair[0], body = pair[1];
1359
+ var supersedes = null;
1360
+ var refs = refDigests(payloads.get(cid), "supersedes");
1361
+ for (var i = 0; i < refs.length; i++)
1362
+ if (byDigest.has(refs[i])) {
1363
+ supersedes = byDigest.get(refs[i]);
1364
+ break;
1365
+ }
1366
+ return {
1367
+ step: cid, action: pyStr(get(body, "action")), amount: sellerAmount(body), digest: digestOfPayload.get(cid),
1368
+ supersedes: supersedes, superseded_by: supersededBy.has(cid) ? supersededBy.get(cid) : null,
1369
+ accepted_by: acceptedBy.has(cid) ? acceptedBy.get(cid) : null,
1370
+ };
1371
+ });
1372
+ var evidence = bodies("evidence").map(function (pair) {
1373
+ return { step: pair[0], disclosure: "disclosed", source: str(get(pair[1], "source")), verified: get(pair[1], "verified") === true };
1374
+ }).concat(withheld("evidence").map(function (cid) { return { step: cid, disclosure: "withheld", source: null, verified: null }; }));
1375
+ var handover = { state: "not_present", step: null, facts: [] };
1376
+ var delivered = bodies("action-outcome/v0").map(function (pair) { return [pair[0], map(get(pair[1], "delivered"))]; })
1377
+ .filter(function (pair) { return truthy(pair[1]); });
1378
+ if (delivered.length) {
1379
+ var last = delivered[delivered.length - 1];
1380
+ var terms = last[1];
1381
+ var hf = ["item", "quantity"].filter(function (k) { return own(terms, k); })
1382
+ .map(function (k) { return fact(k, pyStr(terms[k]), k === "quantity" ? "count" : "token"); });
1383
+ var price = sellerAmount(terms, "price_minor");
1384
+ if (price)
1385
+ hf.push(fact("price", price.value, "amount"));
1386
+ handover = { state: "recorded", step: last[0], facts: hf };
1387
+ }
1388
+ else if (withheld("outcome").length) {
1389
+ var wo = withheld("outcome");
1390
+ handover = { state: "withheld", step: wo[wo.length - 1], facts: [] };
1391
+ }
1392
+ var closes = bodies("close");
1393
+ var outcome = closes.length ? str(get(closes[closes.length - 1][1], "outcome")) : null;
1394
+ var baselines = bodies("baseline");
1395
+ var opening = baselines.length ? baselines[0][1] : {};
1396
+ var authorities = bodies("task-authority/v0");
1397
+ var authorityBody = authorities.length ? authorities[0][1] : {};
1398
+ var intent = map(get(opening, "intent"));
1399
+ var oterms = map(get(opening, "terms"));
1400
+ var it = truthy(str(get(oterms, "item"))) ? fact("item", oterms.item) : "not_present";
1401
+ if (typeof it === "string" && truthy(str(get(map(get(intent, "asked")), "item"))))
1402
+ it = fact("item", pyStr(map(get(intent, "asked")).item));
1403
+ var commits = offers.filter(function (o) { return o.action === "commit"; });
1404
+ var acted = bodies("action-record/v0").filter(function (pair) { return get(pair[1], "action") === "commit"; }).map(function (pair) { return pair[1]; });
1405
+ var amount = "not_present";
1406
+ if (acted.length && sellerAmount(acted[acted.length - 1]))
1407
+ amount = sellerAmount(acted[acted.length - 1]) || "not_present";
1408
+ else if (commits.length && commits[commits.length - 1].amount)
1409
+ amount = commits[commits.length - 1].amount;
1410
+ else if (receipt.steps.some(function (s) { return kindOf.get(s.capsule_id) === "act" && s.disclosure === "withheld"; }))
1411
+ amount = "withheld";
1412
+ var boundsSealed = truthy(or(str(get(authorityBody, "bounds_commitment")), str(get(intent, "bounds_commitment"))));
1413
+ var floor;
1414
+ if (truthy(get(raw, "bounds_openings")))
1415
+ floor = "committed";
1416
+ else if (boundsSealed || withheld("task_authority").length || withheld("open").length)
1417
+ floor = "withheld";
1418
+ else
1419
+ floor = "not_present";
1420
+ var isAddress = function (f) { return get(map(f), "class") === "address"; };
1421
+ var addressSteps = [];
1422
+ iter(get(raw, "told")).map(map).forEach(function (t) {
1423
+ if (!iter(get(t, "fields")).some(isAddress))
1424
+ return;
1425
+ iter(get(t, "steps")).map(str).forEach(function (cid) {
1426
+ if (cid !== null && kindOf.get(cid) === "disclosure")
1427
+ addressSteps.push(cid);
1428
+ });
1429
+ });
1430
+ bodies("disclosure").forEach(function (pair) {
1431
+ if (iter(get(pair[1], "fields")).some(isAddress) && addressSteps.indexOf(pair[0]) < 0)
1432
+ addressSteps.push(pair[0]);
1433
+ });
1434
+ var address;
1435
+ if (addressSteps.some(function (cid) { return payloads.has(cid); }))
1436
+ address = "committed";
1437
+ else if (addressSteps.length)
1438
+ address = "withheld";
1439
+ else
1440
+ address = "not_present";
1441
+ var authority = [
1442
+ truthy(get(authorityBody, "allowed_actions")) ? fact("allowed_actions", iter(authorityBody.allowed_actions).map(pyStr).join(", ")) : null,
1443
+ truthy(str(get(authorityBody, "outcome_id"))) ? fact("outcome_id", authorityBody.outcome_id) : null,
1444
+ ].filter(function (f) { return f !== null; });
1445
+ var commitments = [];
1446
+ payloads.forEach(function (p, cid) { commitments = commitments.concat(commitmentsOf(cid, map(get(p, "body")))); });
1447
+ var keys = distinct(receipt.steps.map(function (s) { return s.key_id; }).filter(truthy));
1448
+ return {
1449
+ receipt: receipt,
1450
+ item: truthy(opening) || !withheld("open").length ? it : "withheld",
1451
+ amount: amount,
1452
+ outcome: outcome,
1453
+ floor: floor,
1454
+ address: address,
1455
+ authority: authority,
1456
+ offers: offers,
1457
+ acceptances: acceptances,
1458
+ evidence: evidence,
1459
+ handover: handover,
1460
+ commitments: commitments,
1461
+ keys: keys,
1462
+ };
1463
+ }
1464
+ // ---- the composition (composed.py, bilateral.py) ---------------------------
1465
+ function pyStrings(v) { return seq(v).map(pyStr); }
1466
+ function pair(v) { var s = pyStrings(v).concat(["", ""]); return [s[0], s[1]]; }
1467
+ function pyClaim(c) { var o = map(c); return { status: pyStr(get(o, "status")), findings: pyStrings(get(o, "findings")) }; }
1468
+ // The page verifier's composed/v1 result (context.extensions[].composed, in
1469
+ // agent-action-capsule's ComposedResult shape), as composed.py's Composition.
1470
+ function compositionOf(v) {
1471
+ var entry = seq(map(v.context).extensions).find(function (e) { return get(map(e), "kind") === COMPOSED_KIND; });
1472
+ if (entry === undefined)
1473
+ return null;
1474
+ var raw = map(get(map(entry), "composed"));
1475
+ if (!truthy(raw))
1476
+ throw new Unavailable("the page's verifier names a composed/v1 block and carries no result for it");
1477
+ if (get(raw, "malformed") === true || !own(raw, "composedDigest")) {
1478
+ return {
1479
+ status: pyStr(get(raw, "status")), findings: pyStrings(get(raw, "findings")), malformed: true, digest_declared: "", digest_recomputed: "",
1480
+ digest_matches: false, members: [], observers: [], closure: { status: "fail", findings: [] }, closure_missing: [], joins: [], corroboration: [],
1481
+ };
1482
+ }
1483
+ var digest = map(get(raw, "composedDigest"));
1484
+ var closure = map(get(raw, "compositionClosure"));
1485
+ var declared = map(get(map(get(v.bundle, "extensions")), COMPOSED_KIND));
1486
+ return {
1487
+ status: pyStr(get(raw, "status")),
1488
+ findings: pyStrings(get(raw, "findings")),
1489
+ malformed: false,
1490
+ digest_declared: pyStr(get(digest, "declared")),
1491
+ digest_recomputed: pyStr(or(get(digest, "recomputed"), "")),
1492
+ digest_matches: get(digest, "matches") === true,
1493
+ members: seq(get(raw, "members")).map(map).map(function (m) {
1494
+ var b = get(m, "bundle");
1495
+ var signature = get(m, "refusalSignature");
1496
+ return {
1497
+ id: pyStr(get(m, "id")), observer: pyStr(get(m, "observer")), outcome: pyStr(get(m, "outcome")), body: pyStr(get(m, "body")),
1498
+ digest: pyStr(get(m, "digest")), findings: pyStrings(get(m, "findings")),
1499
+ claims: isMap(b) ? [pyClaim(b.graphClosure), pyClaim(b.intervalCoverage), pyClaim(b.perRecordMembership)] : null,
1500
+ refusal_signature: typeof signature === "string" ? signature : null,
1501
+ report: null,
1502
+ };
1503
+ }),
1504
+ observers: seq(get(declared, "observers")).map(map).map(function (o) {
1505
+ return { id: pyStr(get(o, "id")), role: pyStr(get(o, "role")), custody_domain: pyStr(get(o, "custody_domain")) };
1506
+ }),
1507
+ closure: pyClaim(closure),
1508
+ closure_missing: pyStrings(get(closure, "missing")),
1509
+ joins: seq(get(raw, "joins")).map(map).map(function (j) {
1510
+ var derived = get(j, "derived");
1511
+ return {
1512
+ members: pair(get(j, "members")), basis: pyStr(get(j, "basis")), declared: pyStr(get(j, "declared")),
1513
+ derived: typeof derived === "string" ? derived : null, result: pyStr(get(j, "result")),
1514
+ differences: seq(get(j, "differences")).map(map).map(function (d) {
1515
+ return {
1516
+ pointer: pyStr(get(d, "pointer")),
1517
+ values: seq(get(d, "values")).map(map).map(function (x) { return { member: pyStr(get(x, "member")), resolved: get(x, "resolved") === true, value: own(x, "value") ? x.value : null }; }),
1518
+ };
1519
+ }),
1520
+ };
1521
+ }),
1522
+ corroboration: seq(get(raw, "corroboration")).map(map).map(function (c) {
1523
+ var rep = get(c, "report");
1524
+ return { members: pair(get(c, "members")), result: pyStr(get(c, "result")), reasons: pyStrings(get(c, "reasons")), report: typeof rep === "string" ? rep : null };
1525
+ }),
1526
+ };
1527
+ }
1528
+ function compositionProblem(c) {
1529
+ if (c.status !== "pass" || !c.digest_matches || c.closure.status !== "pass")
1530
+ return "the composition did not pass";
1531
+ var members = c.members;
1532
+ var copies = members.filter(function (m) { return m.outcome === "artifact"; });
1533
+ if (members.length !== 2 || !copies.length || members.some(function (m) { return m.body !== "carried"; }))
1534
+ return "a bilateral receipt is two carried members, at least one a copy";
1535
+ if (copies.length === 1 && members.some(function (m) { return m.outcome !== "artifact" && m.outcome !== "absence" && m.outcome !== "refusal"; }))
1536
+ return "a one-sided receipt's other member is an absence or a refusal";
1537
+ if (copies.length === 1 && c.joins.some(function (j) { return j.derived !== "one_sided"; }))
1538
+ return "a one-sided composition's joins do not all derive one_sided";
1539
+ if (members.some(function (m) { return m.digest !== "reproduced"; }))
1540
+ return "a carried member's digest was not reproduced";
1541
+ if (distinct(members.map(function (m) { return m.id; })).length !== 2 || distinct(members.map(function (m) { return m.observer; })).length !== 2) {
1542
+ return "the two copies are not from two observers";
1543
+ }
1544
+ if (c.corroboration.length !== c.joins.length)
1545
+ return "the report does not give one corroboration result per join";
1546
+ return null;
1547
+ }
1548
+ function pageMayShow(audience, cuts) {
1549
+ if (audience === null) {
1550
+ // The page's audience is not handed to a module: the copies must be
1551
+ // ones some page may show together.
1552
+ return Object.keys(CUTS).some(function (a) { return pageMayShow(a, cuts); });
1553
+ }
1554
+ var allowed = own(CUTS, audience) ? CUTS[audience] : [];
1555
+ return cuts.every(function (cut) { return allowed.indexOf(cut) >= 0; }) && cuts.filter(function (cut) { return cut === "keep"; }).length <= 1;
1556
+ }
1557
+ function oneDeal(named) {
1558
+ var every = [];
1559
+ named.forEach(function (deals) { deals.forEach(function (d) { if (every.indexOf(d) < 0)
1560
+ every.push(d); }); });
1561
+ every.sort(codepointCompare);
1562
+ if (named.some(function (deals) { return deals.length === 0; }))
1563
+ return ["unnamed", every];
1564
+ if (every.length === 1)
1565
+ return ["agree", every];
1566
+ return ["mismatch", every];
1567
+ }
1568
+ function carriedBodies(v) {
1569
+ var block = map(get(map(get(v.bundle, "extensions")), COMPOSED_KIND));
1570
+ return seq(get(block, "members")).map(map).filter(function (raw) {
1571
+ return get(raw, "outcome") === "artifact" && isMap(get(raw, "bundle"));
1572
+ });
1573
+ }
1574
+ // sides.missing_member: the one absence member, its body read
1575
+ // from the bundle's own block (carried, its digest reproduced:
1576
+ // compositionProblem).
1577
+ function missingMember(v, composition) {
1578
+ var others = composition.members.filter(function (m) { return m.outcome === "absence" || m.outcome === "refusal"; });
1579
+ if (others.length !== 1)
1580
+ return null;
1581
+ var member = others[0];
1582
+ var observer = composition.observers.find(function (o) { return o.id === member.observer; }) || null;
1583
+ var block = map(get(map(get(v.bundle, "extensions")), COMPOSED_KIND));
1584
+ var raw = seq(get(block, "members")).map(map).find(function (r) { return get(r, "id") === member.id; }) || {};
1585
+ if (member.outcome === "refusal") {
1586
+ var body = map(get(raw, "refusal"));
1587
+ var issued = str(get(body, "issued_at")), reason = str(get(body, "reason"));
1588
+ if (issued === null || reason !== "policy_declined" || member.refusal_signature !== "verified") {
1589
+ throw new Unavailable("the refusal member " + pyRepr(member.id) + " is not a verified policy_declined refusal");
1590
+ }
1591
+ return { member: member.id, role: observer ? observer.role : null, window: [issued, issued], kind: "refusal", reason: reason };
1592
+ }
1593
+ var win = map(get(map(get(raw, "absence")), "window"));
1594
+ var start = str(get(win, "from")), end = str(get(win, "to"));
1595
+ if (start === null || end === null)
1596
+ throw new Unavailable("the absence member " + pyRepr(member.id) + " carries no window");
1597
+ return { member: member.id, role: observer ? observer.role : null, window: [start, end], kind: "absence", reason: null };
1598
+ }
1599
+ // sides.plain_date: an RFC 3339 timestamp's date, as "Oct 9, 2026".
1600
+ var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1601
+ function plainDate(value) {
1602
+ var m = /^(\d{4})-(\d{2})-(\d{2})(?:T|$)/.exec(value);
1603
+ if (m === null || +m[2] < 1 || +m[2] > 12)
1604
+ return value;
1605
+ return MONTHS[+m[2] - 1] + " " + +m[3] + ", " + m[1];
1606
+ }
1607
+ // sides.plain_time: a UTC RFC 3339 instant, as "Oct 9, 2026, 18:00 UTC"; anything else as it is.
1608
+ // The reader's own zone is set after drawing (localTimes), where the page has a script.
1609
+ function plainTime(value) {
1610
+ var m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]00:00)$/.exec(value);
1611
+ if (m === null || +m[2] < 1 || +m[2] > 12 || +m[3] < 1 || +m[3] > 31 || +m[4] > 23 || +m[5] > 59)
1612
+ return value;
1613
+ return MONTHS[+m[2] - 1] + " " + +m[3] + ", " + m[1] + ", " + m[4] + ":" + m[5] + " UTC";
1614
+ }
1615
+ // Each data-time span the drawing made, said in the reader's own time zone.
1616
+ function localTimes(root) {
1617
+ var Format = typeof Intl !== "undefined" && Intl.DateTimeFormat;
1618
+ if (!Format)
1619
+ return;
1620
+ var format;
1621
+ try {
1622
+ format = new Format(undefined, { year: "numeric", month: "short", day: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short" });
1623
+ }
1624
+ catch (e) {
1625
+ return;
1626
+ }
1627
+ Array.prototype.forEach.call(root.querySelectorAll("[data-time]"), function (node) {
1628
+ var date = new Date(node.getAttribute("data-time"));
1629
+ if (!isNaN(date.getTime()))
1630
+ node.textContent = format.format(date);
1631
+ });
1632
+ }
1633
+ // sides.two_copy_case.
1634
+ function twoCopyCase(dealState, joins) {
1635
+ var agreed = joins.length > 0 && joins.every(function (jv) {
1636
+ return jv.join.derived === "agree" && jv.join.result === "derived_matches" && !!jv.corroboration && jv.corroboration.result === "corroborating";
1637
+ });
1638
+ return dealState === "agree" && agreed ? "both" : "not_agreed";
1639
+ }
1640
+ // bilateral.build_bilateral. Asynchronous: each carried copy is verified by
1641
+ // the page's runtime, which may need a digest.
1642
+ function buildBilateral(v, env) {
1643
+ if (!v.verified)
1644
+ return Promise.reject(new Unavailable("the bundle did not verify"));
1645
+ var composition;
1646
+ try {
1647
+ composition = env.composition(v);
1648
+ }
1649
+ catch (e) {
1650
+ return Promise.reject(e);
1651
+ }
1652
+ if (composition === null)
1653
+ return Promise.reject(new Unavailable("no composed/v1 result was reported for this bundle"));
1654
+ var problem = compositionProblem(composition);
1655
+ if (problem !== null)
1656
+ return Promise.reject(new Unavailable(problem));
1657
+ var raws = carriedBodies(v);
1658
+ var members = [];
1659
+ for (var i = 0; i < raws.length; i++) {
1660
+ var member = composition.members.find(function (m) { return m.id === pyStr(get(raws[i], "id")); });
1661
+ if (!member)
1662
+ return Promise.reject(new Unavailable("the verifier assesses no carried bundle for a member"));
1663
+ members.push(member);
1664
+ }
1665
+ return Promise.all(raws.map(function (raw, i) {
1666
+ // A carried copy the page's runtime cannot verify is no copy to show.
1667
+ return Promise.resolve().then(function () { return env.memberContext(raw.bundle, members[i].id); }).then(null, function (err) {
1668
+ throw err instanceof Unavailable ? err : new Unavailable("a carried copy could not be verified: " + (err && err.message));
1669
+ });
1670
+ })).then(function (contexts) {
1671
+ var copies = composition.members.filter(function (m) { return m.outcome === "artifact"; }).length;
1672
+ if (contexts.length !== copies)
1673
+ throw new Unavailable("the bundle does not carry the copies its report assessed");
1674
+ var parties = contexts.map(function (ctx, i) {
1675
+ var pv = view(ctx, env);
1676
+ var m = members[i];
1677
+ var observer = composition.observers.find(function (o) { return o.id === m.observer; }) || null;
1678
+ var cut = copyAudience(pv);
1679
+ if (!sellerKindEngaged(pv) && sealedSide(pv) === "seller")
1680
+ throw new Unavailable(m.id + " is sealed as a seller's copy and does not engage the seller kind");
1681
+ var seller = sellerKindEngaged(pv) ? buildSeller(pv, cut) : null;
1682
+ return {
1683
+ member: m.id, observer: m.observer, role: observer ? observer.role : null, custody_domain: observer ? observer.custody_domain : null,
1684
+ audience: cut, deals: namedDeals(pv), assurance: pv.assurance, receipt: buildReceipt(pv, cut), seller: seller,
1685
+ };
1686
+ });
1687
+ if (!pageMayShow(env.audience, parties.map(function (p) { return p.audience; }))) {
1688
+ throw new Unavailable("a page does not show copies cut for " + parties.map(function (p) { return p.audience; }).join(", "));
1689
+ }
1690
+ var deal = oneDeal(parties.map(function (p) { return p.deals; }));
1691
+ var joins = composition.joins.map(function (j, i) { return { join: j, corroboration: composition.corroboration[i] }; });
1692
+ var missing = missingMember(v, composition);
1693
+ return {
1694
+ deal: deal[0] === "agree" ? deal[1][0] : null,
1695
+ deal_state: deal[0],
1696
+ named: deal[1],
1697
+ parties: parties,
1698
+ joins: joins,
1699
+ composition: composition,
1700
+ bundle_digest: v.assurance.bundle_digest,
1701
+ verification: v.verification,
1702
+ case: missing !== null ? (missing.kind === "refusal" ? "limit" : "one_sided") : twoCopyCase(deal[0], joins),
1703
+ missing: missing,
1704
+ };
1705
+ });
1706
+ }
1707
+ // ---- drawing: the kit (capsule_viewer.kit.components), as DOM -------------
1708
+ // A child is a string (a text node), a node, an array of children, or null.
1709
+ function Drawing(doc) { this.doc = doc; }
1710
+ Drawing.prototype.el = function (tag, attrs, children) {
1711
+ var node = this.doc.createElement(tag);
1712
+ var a = attrs || {};
1713
+ Object.keys(a).forEach(function (k) { if (a[k] !== null && a[k] !== undefined)
1714
+ node.setAttribute(k, a[k]); });
1715
+ this.append(node, children);
1716
+ return node;
1717
+ };
1718
+ Drawing.prototype.append = function (node, children) {
1719
+ var self = this;
1720
+ if (children === null || children === undefined)
1721
+ return;
1722
+ if (Array.isArray(children)) {
1723
+ children.forEach(function (c) { self.append(node, c); });
1724
+ return;
1725
+ }
1726
+ node.appendChild(typeof children === "string" ? this.doc.createTextNode(children) : children);
1727
+ };
1728
+ Drawing.prototype.frag = function (children) {
1729
+ var f = this.doc.createDocumentFragment();
1730
+ this.append(f, children);
1731
+ return f;
1732
+ };
1733
+ function pyRepr(s) {
1734
+ var quote = s.indexOf("'") >= 0 && s.indexOf('"') < 0 ? '"' : "'";
1735
+ var body = s.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
1736
+ if (quote === "'")
1737
+ body = body.replace(/'/g, "\\'");
1738
+ return quote + body + quote;
1739
+ }
1740
+ function Kit(d) { this.d = d; }
1741
+ Kit.prototype.refusal = function (component, value, reason) {
1742
+ return this.d.el("span", { class: "cv-refusal cv-badge", "data-refused": component }, [component + " refused " + pyRepr(value) + ": " + reason]);
1743
+ };
1744
+ Kit.prototype.section = function (title, children, level) {
1745
+ level = level || 2;
1746
+ if ([2, 3, 4].indexOf(level) < 0)
1747
+ throw new Error("section level must be 2, 3 or 4, got " + level);
1748
+ var d = this.d;
1749
+ return d.el("section", { class: "cv-section", "data-cv": "section" }, [
1750
+ d.el("h" + level, { class: "cv-section__title" }, [title]),
1751
+ d.el("div", { class: "cv-section__body" }, children),
1752
+ ]);
1753
+ };
1754
+ Kit.prototype.metricGrid = function (metrics) {
1755
+ var d = this.d;
1756
+ var tiles = metrics.map(function (m) {
1757
+ var parts = [d.el("dt", { class: "cv-metric__label" }, [m.label]), d.el("dd", { class: "cv-metric__value" }, [m.value])];
1758
+ if (m.note)
1759
+ parts.push(d.el("dd", { class: "cv-metric__note" }, [m.note]));
1760
+ return d.el("div", { class: "cv-metric" }, parts);
1761
+ });
1762
+ return d.el("div", { class: "cv-metrics-wrap", "data-cv": "metric-grid" }, [d.el("dl", { class: "cv-metrics" }, tiles)]);
1763
+ };
1764
+ Kit.prototype.dataTable = function (columns, rows) {
1765
+ var d = this.d;
1766
+ rows.forEach(function (row, i) {
1767
+ if (row.length !== columns.length)
1768
+ throw new Error("data_table row " + i + " has " + row.length + " cells for " + columns.length + " columns");
1769
+ });
1770
+ var head = d.el("thead", {}, [d.el("tr", {}, columns.map(function (c) { return d.el("th", { scope: "col" }, [c]); }))]);
1771
+ var body = d.el("tbody", {}, rows.map(function (row) {
1772
+ return d.el("tr", {}, row.map(function (cell, i) { return d.el("td", { "data-label": columns[i] }, [cell]); }));
1773
+ }));
1774
+ return d.el("div", { class: "cv-table-wrap", "data-cv": "data-table" }, [d.el("table", { class: "cv-table" }, [head, body])]);
1775
+ };
1776
+ Kit.prototype.disclosureBadge = function (state) {
1777
+ if (!own(DISCLOSURE_STATES, state))
1778
+ return this.refusal("DisclosureBadge", state, "state must be one of " + Object.keys(DISCLOSURE_STATES).join(", "));
1779
+ var entry = DISCLOSURE_STATES[state];
1780
+ return this.d.el("span", { class: "cv-badge cv-tone--" + entry[1], "data-cv": "disclosure-badge", "data-state": state }, [entry[0]]);
1781
+ };
1782
+ Kit.prototype.drilldown = function (summary, children, expanded) {
1783
+ var d = this.d;
1784
+ var attrs = { class: "cv-drilldown", "data-cv": "drilldown" };
1785
+ if (expanded)
1786
+ attrs.open = "";
1787
+ return d.el("details", attrs, [d.el("summary", {}, [summary]), d.el("div", { class: "cv-drilldown__body" }, children)]);
1788
+ };
1789
+ Kit.prototype.evidenceDetails = function (list) {
1790
+ var d = this.d, kit = this;
1791
+ return d.el("ul", { class: "cv-evidence", "data-cv": "evidence-details" }, list.map(function (it) {
1792
+ var parts = [d.el("div", { class: "cv-evidence__head" }, [d.el("span", { class: "cv-evidence__label" }, [it.label]), kit.disclosureBadge(it.disclosure)])];
1793
+ if (it.media_type)
1794
+ parts.push(d.el("span", { class: "cv-muted" }, [it.media_type]));
1795
+ if (it.digest)
1796
+ parts.push(d.el("span", { class: "cv-mono" }, [it.digest]));
1797
+ if (it.note)
1798
+ parts.push(d.el("span", {}, [it.note]));
1799
+ return d.el("li", { class: "cv-evidence__item" }, parts);
1800
+ }));
1801
+ };
1802
+ Kit.prototype.outcome = function (outcome, cls) {
1803
+ if (!own(VERIFICATION_OUTCOMES, outcome))
1804
+ return this.refusal("VerificationDetails", outcome, "outcome must be one of " + Object.keys(VERIFICATION_OUTCOMES).join(", "));
1805
+ var entry = VERIFICATION_OUTCOMES[outcome];
1806
+ return this.d.el("span", { class: cls + " cv-tone--" + entry[1], "data-outcome": outcome }, [entry[0]]);
1807
+ };
1808
+ Kit.prototype.verificationDetails = function (result) {
1809
+ var d = this.d, kit = this;
1810
+ var headline = d.el("div", { class: "cv-verification__outcome-row" }, [
1811
+ kit.outcome(result.outcome, "cv-verification__outcome cv-pill"), d.el("span", { class: "cv-muted" }, [" reported by " + result.verifier]),
1812
+ ]);
1813
+ var checks = result.checks.map(function (c) {
1814
+ var parts = [kit.outcome(c.outcome, "cv-pill"), d.el("span", {}, [c.name])];
1815
+ if (c.detail)
1816
+ parts.push(d.el("span", { class: "cv-mono cv-muted" }, [c.detail]));
1817
+ return d.el("li", { class: "cv-check" }, parts);
1818
+ });
1819
+ return d.el("div", { class: "cv-verification", "data-cv": "verification-details" }, [headline, d.el("ul", { class: "cv-checks" }, checks)]);
1820
+ };
1821
+ // ---- words ----------------------------------------------------------------
1822
+ var PLACEHOLDER = /\{([a-z_]+)\}/g;
1823
+ // In a report a key's "<key>.report" form wins when the pack has one: the
1824
+ // reader may not be the owner, so no line says "you" or "your" (Sherlock2,
1825
+ // #386; drawCarrier is set by render for one draw).
1826
+ function word(key) {
1827
+ if (drawCarrier === "report" && own(WORDS, key + ".report"))
1828
+ return WORDS[key + ".report"];
1829
+ return own(WORDS, key) ? WORDS[key] : null;
1830
+ }
1831
+ function w(key, values) {
1832
+ var template = word(key);
1833
+ if (template === null)
1834
+ return "[" + key + "]";
1835
+ return template.replace(PLACEHOLDER, function (_, name) {
1836
+ if (!values || !own(values, name))
1837
+ throw new Error("no value for {" + name + "} in " + key);
1838
+ return values[name];
1839
+ });
1840
+ }
1841
+ // ---- drawing: one copy (module.py, seller.py) ------------------------------
1842
+ // What carries the receipt being drawn ("report", or null when it stands
1843
+ // alone), set by render for the length of one synchronous draw.
1844
+ var drawCarrier = null;
1845
+ function Drawer(doc, depth, seller) {
1846
+ this.d = new Drawing(doc);
1847
+ this.kit = new Kit(this.d);
1848
+ this.depth = depth;
1849
+ this.seller = !!seller;
1850
+ this.carrier = drawCarrier;
1851
+ }
1852
+ var P = Drawer.prototype;
1853
+ P.p = function (text, attrs) { return this.d.el("p", attrs, [text]); };
1854
+ P.note = function (text, attrs) { return this.d.el("p", Object.assign({ class: "cv-muted" }, attrs || {}), [text]); };
1855
+ // module.py's time_el, _timed, _short, _short_id, _fact_value and checked_note.
1856
+ P.timeEl = function (at) {
1857
+ var shown = plainTime(at);
1858
+ return shown !== at ? this.d.el("span", { "data-time": at }, [shown]) : at;
1859
+ };
1860
+ P.timed = function (key, at, values) {
1861
+ var clean = {};
1862
+ Object.keys(values || {}).forEach(function (k) { clean[k] = values[k].split(TIME_MARK).join(""); });
1863
+ var parts = w(key, Object.assign({ at: TIME_MARK }, clean)).split(TIME_MARK);
1864
+ if (parts.length < 2)
1865
+ return parts[0];
1866
+ return [parts[0], this.timeEl(at), parts.slice(1).join(TIME_MARK)];
1867
+ };
1868
+ P.short = function (id) {
1869
+ if (id.length <= SHORT_HEAD + SHORT_TAIL + 1)
1870
+ return id;
1871
+ return w("record.short", { head: id.slice(0, SHORT_HEAD), tail: id.slice(-SHORT_TAIL) });
1872
+ };
1873
+ P.shortId = function (id) { return this.d.el("span", { class: "cv-mono", "data-capsule-id": id }, [this.short(id)]); };
1874
+ P.factValue = function (f) {
1875
+ var d = this.d;
1876
+ var worded = f.kind === "token" ? word("value." + f.name + "." + f.value.toLowerCase()) : null;
1877
+ if (worded === null)
1878
+ return d.el("dd", { class: "cv-mono", "data-fact": f.name }, [f.value]);
1879
+ if (worded.toLowerCase() === f.value.toLowerCase())
1880
+ return d.el("dd", { "data-fact": f.name, "data-token": f.value }, [worded]);
1881
+ return d.el("dd", { "data-fact": f.name, "data-token": f.value }, [worded, " ", d.el("span", { class: "cv-mono cv-muted", "data-code": "true" }, [f.value])]);
1882
+ };
1883
+ P.checkedNote = function (result) {
1884
+ var pill = this.kit.outcome(result.outcome, "cv-verification__outcome cv-pill");
1885
+ var ran = result.checks.filter(function (c) { return c.name !== WITNESS_CHECK; });
1886
+ var said = function (c) { return VERIFICATION_OUTCOMES[c.outcome][0].toLowerCase(); };
1887
+ var tested;
1888
+ if (ran.length && ran.every(function (c) { return c.outcome === ran[0].outcome; })) {
1889
+ tested = ran.length > 1 ? w("verify.checks_all", { checks: ran.map(function (c) { return c.name; }).join(", "), outcome: said(ran[0]) }) : w("verify.check_one", { name: ran[0].name, outcome: said(ran[0]) });
1890
+ }
1891
+ else {
1892
+ tested = ran.map(function (c) { return w("verify.check_one", { name: c.name, outcome: said(c) }); }).join(", ");
1893
+ }
1894
+ // The page's own verifier ran in this browser, so the line says so; an
1895
+ // outside verifier's report (capsulectl's), or a page whose check could
1896
+ // not run in full here, keeps "did not re-check" (Sherlock2,
1897
+ // capsule-viewer#391: never on a can't-check result).
1898
+ var here = result.verifier === VERIFIER && result.here === true && tested;
1899
+ var text = here ? w("verify.tested_here", { verifier: result.verifier, checks: tested })
1900
+ : tested ? w("verify.tested", { verifier: result.verifier, checks: tested }) : w("verify.reported", { verifier: result.verifier });
1901
+ return this.d.el("p", { "data-checked": "true" }, [pill, " ", text]);
1902
+ };
1903
+ P.enumText = function (prefix, value) {
1904
+ var text = word(prefix + "." + value);
1905
+ if (text !== null)
1906
+ return text;
1907
+ return this.d.el("span", { class: "cv-mono", "data-unworded": prefix + "." + value }, [value]);
1908
+ };
1909
+ // The owner's own copy says PRIVATE when it stands alone. Carried in a report
1910
+ // (its panel bears data-receipt-carrier="report", set by the page's runtime),
1911
+ // it was shared on purpose by the report owner's setting, and says so
1912
+ // instead: no do-not-forward line (Sherlock2, ops bc71ecae, #383).
1913
+ P.privateBanner = function () {
1914
+ if (this.carrier === "report") {
1915
+ var shared = this.d.el("span", { class: "cv-badge" }, [w("banner.shared.label")]);
1916
+ return this.d.el("p", { "data-banner": "shared" }, [shared, " ", w("banner.shared.text")]);
1917
+ }
1918
+ var label = this.d.el("span", { class: "cv-badge" }, [w("banner.private.label")]);
1919
+ return this.d.el("p", { class: "cv-tone--caution", "data-banner": "private" }, [label, " ", w("banner.private.text")]);
1920
+ };
1921
+ // module.py's sides, half and missing_half (sides.py has the cases).
1922
+ P.sides = function (kase, halves, keep, line) {
1923
+ var d = this.d;
1924
+ var parts = halves.slice();
1925
+ if (line !== false) {
1926
+ var key = (kase === "one_sided" || kase === "limit") && (!keep || this.carrier === "report") ? "sides.case." + kase + ".shared" : "sides.case." + kase;
1927
+ parts.unshift(d.el("p", { class: "cv-sides__case cv-tone--" + CASE_TONE[kase], "data-case": kase }, [w(key)]));
1928
+ }
1929
+ return d.el("div", { class: "cv-sides", "data-receipt-case": kase }, parts);
1930
+ };
1931
+ // module.py's actions: after L1's drilldown, on the holder's own page only.
1932
+ // They are prompts for the owner's own agent, so a copy carried in a report,
1933
+ // read by anyone the owner shared it with, has none (Sherlock2, #386).
1934
+ P.actions = function (kase) {
1935
+ if (this.carrier === "report")
1936
+ return null;
1937
+ var d = this.d;
1938
+ var items = [d.el("li", { class: "cv-actions__heading" }, [w("actions.heading")])].concat(ACTIONS[kase].map(function (k) {
1939
+ return d.el("li", { "data-action": k.replace(/^actions\./, "") }, [w(k)]);
1940
+ }));
1941
+ return d.el("ul", { class: "cv-actions", "data-actions": "true" }, items);
1942
+ };
1943
+ P.half = function (kind, label, body, attrs) {
1944
+ return this.d.el("div", Object.assign({ class: "cv-half cv-half--" + kind, "data-half": kind }, attrs || {}), [this.d.el("p", { class: "cv-half__label" }, [label])].concat(body));
1945
+ };
1946
+ P.missingHalf = function (missing, keep) {
1947
+ var text;
1948
+ if (missing === null)
1949
+ text = w("sides.missing.none");
1950
+ else if (missing.kind === "refusal")
1951
+ text = w("sides.missing.refusal." + missing.reason, { date: plainDate(missing.window[0]) });
1952
+ else
1953
+ text = w("sides.missing.absence", { start: plainDate(missing.window[0]), end: plainDate(missing.window[1]) });
1954
+ var label = keep || missing === null || missing.role === null ? w("sides.missing.heading") : missing.role;
1955
+ var attrs = missing !== null ? { "data-outcome": missing.kind, "data-party": missing.member } : { "data-outcome": "none" };
1956
+ return this.half("missing", label, [this.d.el("p", {}, [text])], attrs);
1957
+ };
1958
+ P.part = function (part, prefix) {
1959
+ if (typeof part === "object" && part !== null)
1960
+ return prefix ? this.enumText(prefix, part.value) : part.value;
1961
+ return this.kit.disclosureBadge(part);
1962
+ };
1963
+ P.headline = function (model) {
1964
+ var h = model.headline;
1965
+ var state = h.state ? this.enumText("state", h.state) : w("l0.state.missing");
1966
+ var dealType = this.d.el("p", { "data-deal-type": "true" }, [w("l0.deal_type"), ": ", this.part(h.deal_type, "deal_type")]);
1967
+ // No Amount card when no signed field carries an amount: a deal that
1968
+ // records its payment only in prose (a Mesh node's outcome and close) must
1969
+ // not show "not present" beside a paid deal, and prose is never parsed
1970
+ // into a figure (Sherlock2, capsule-viewer#391).
1971
+ var cards = [{ label: w("l0.item"), value: this.part(h.item) }];
1972
+ if (h.amount !== "not_present")
1973
+ cards.push({ label: w("l0.amount"), value: this.part(h.amount) });
1974
+ cards.push({ label: w("l0.state"), value: state });
1975
+ return [dealType, this.kit.metricGrid(cards)];
1976
+ };
1977
+ P.copyNotes = function (model) {
1978
+ var parts = [];
1979
+ var aud = model.report.audience;
1980
+ if (SHARED_AUDIENCES.indexOf(aud) >= 0)
1981
+ parts.push(this.p(w("shared." + aud, { kinds: model.report.withheld.join(", ") }), { "data-shared": aud }));
1982
+ if (model.report.scope)
1983
+ parts.push(this.p(model.report.scope, { "data-sealed-text": "scope" }));
1984
+ parts.push(this.p(this.witness(model), { "data-rung": "witness" }));
1985
+ parts.push(this.p(this.countersign(model), { "data-rung": "countersign" }));
1986
+ if (testMoney(model))
1987
+ parts.push(this.p(w("money.test"), { class: "cv-tone--caution", "data-test-money": "true" }));
1988
+ return parts;
1989
+ };
1990
+ P.witness = function (model) {
1991
+ if (model.witnessed === "pass")
1992
+ return w("rung.witness_verified");
1993
+ if (model.witnessed === "fail")
1994
+ return w("rung.witness_failed");
1995
+ if (model.witnessed === "withheld")
1996
+ return w("rung.unwitnessed");
1997
+ return w("rung.unreported");
1998
+ };
1999
+ P.countersign = function (model) {
2000
+ if (!model.countersignatures.length)
2001
+ return w("countersign.none");
2002
+ return w("countersign.some", { statuses: model.countersignatures.join(", ") });
2003
+ };
2004
+ P.logText = function (log) {
2005
+ return log ? w("step.log", { seq: String(log.seq), leaf: String(log.leaf_index), log: log.log_id }) : w("step.no_log");
2006
+ };
2007
+ P.factLabel = function (name) {
2008
+ if (this.seller) {
2009
+ var worded = word("seller.fact." + name);
2010
+ if (truthy(worded))
2011
+ return worded;
2012
+ }
2013
+ return w("fact." + name);
2014
+ };
2015
+ P.step = function (step, testMoneyOnly) {
2016
+ var d = this.d, self = this;
2017
+ var label = step.n !== null && step.at ? this.timed("step.position", step.at, { n: String(step.n) }) : w("step.unnumbered");
2018
+ var parts = [this.kit.evidenceDetails([{ label: label, disclosure: step.disclosure, digest: step.capsule_id, media_type: "", note: this.logText(step.log) }])];
2019
+ if (step.line)
2020
+ parts.push(this.p(w("step.line", { text: step.line }), { "data-sealed-text": "step-line" }));
2021
+ if (step.disclosure === "disclosed") {
2022
+ var list = step.facts.filter(function (f) { return !(testMoneyOnly && isRail(f)); }).map(function (f) {
2023
+ return [d.el("dt", {}, [self.factLabel(f.name)]), self.factValue(f)];
2024
+ });
2025
+ if (step.record_type)
2026
+ list.unshift([d.el("dt", {}, [w("step.type")]), d.el("dd", { class: "cv-mono", "data-fact": "record_type" }, [step.record_type])]);
2027
+ parts.push(d.el("dl", { "data-facts": "true" }, list));
2028
+ }
2029
+ var attrs = { "data-record": step.capsule_id, "data-disclosure": step.disclosure };
2030
+ if (step.log)
2031
+ attrs["data-log"] = step.log.log_id + ":" + step.log.seq + ":" + step.log.leaf_index;
2032
+ return d.el("div", attrs, parts);
2033
+ };
2034
+ P.steps = function (model, ids) {
2035
+ var d = this.d, kit = this.kit, self = this;
2036
+ return d.el("ol", {}, ids.map(function (cid) {
2037
+ var step = stepIn(model, cid);
2038
+ if (step === null)
2039
+ return d.el("li", {}, [kit.disclosureBadge("not_present"), " ", d.el("span", { class: "cv-mono" }, [cid])]);
2040
+ var line = step.line || "";
2041
+ var at = step.at ? [self.timeEl(step.at), " · "] : "";
2042
+ return d.el("li", { "data-step": cid }, [kit.disclosureBadge(step.disclosure), " ", d.el("span", {}, [at, line])]);
2043
+ }));
2044
+ };
2045
+ P.item = function (model, it, prefix) {
2046
+ var text = it.at ? [prefix || "", this.timeEl(it.at), " · ", it.text] : [prefix || "", it.text];
2047
+ if (it.flagged)
2048
+ text = ["⚠️ ", text];
2049
+ if (!it.steps.length)
2050
+ return this.p(text, { "data-sealed-text": "item" });
2051
+ return this.d.el("div", { "data-item": "true" }, [
2052
+ this.p(text, { "data-sealed-text": "item" }),
2053
+ this.kit.section(w("steps.summary"), [this.steps(model, it.steps)], 4),
2054
+ ]);
2055
+ };
2056
+ P.sectionSteps = function (model, section) {
2057
+ var self = this;
2058
+ var testMoneyOnly = testMoney(model);
2059
+ return model.steps.filter(function (s) { return s.section === section; }).map(function (s) { return self.step(s, testMoneyOnly); });
2060
+ };
2061
+ P.committed = function (c, prefix) {
2062
+ if (c.state === "opened" && c.text !== null) {
2063
+ var label = "";
2064
+ if (c.label) {
2065
+ var worded = word("class." + c.label);
2066
+ label = truthy(worded) ? worded + ": " : "";
2067
+ }
2068
+ return [
2069
+ this.d.el("p", { "data-committed": prefix, "data-state": "opened" }, [label + "“" + c.text + "”"]),
2070
+ this.note(w(prefix + ".opened")),
2071
+ ];
2072
+ }
2073
+ if (c.state === "committed") {
2074
+ return [this.kit.disclosureBadge("committed"), this.note(w(prefix + ".committed"), { "data-committed": prefix, "data-state": "committed" })];
2075
+ }
2076
+ if (c.state === "withheld" || c.state === "not_present") {
2077
+ return [this.kit.disclosureBadge(c.state), this.note(w(prefix + "." + c.state), { "data-committed": prefix, "data-state": c.state })];
2078
+ }
2079
+ return this.p(w(prefix + ".mismatch"), { "data-committed": prefix, "data-state": "mismatch" });
2080
+ };
2081
+ P.claims = function (keys) {
2082
+ var d = this.d;
2083
+ return [
2084
+ d.el("ul", {}, keys.map(function (k) { return d.el("li", { "data-claim": k }, [w(k)]); })),
2085
+ this.note(w("claims.scope")),
2086
+ ];
2087
+ };
2088
+ P.deadlineList = function (deadlines) {
2089
+ var d = this.d;
2090
+ return d.el("ul", {}, deadlines.map(function (x) { return d.el("li", { "data-flagged": x.flagged ? "true" : "false" }, [x.text]); }));
2091
+ };
2092
+ // Who wrote the sealed text, as the records say: the one producer every
2093
+ // disclosed step names, else "the producer"; a report carried outside the
2094
+ // log has no record of its own to say (module.py _producer).
2095
+ P.producer = function (model) {
2096
+ var ns = model.producer_names;
2097
+ return model.report_checked === null && ns.length === 1 && ns[0] !== null ? ns[0] : w("provenance.the_producer");
2098
+ };
2099
+ // How the report was sealed. A report carried outside the log is described
2100
+ // by what capsulectl verify reported of it and nothing more (module.py).
2101
+ P.sealedNote = function (model) {
2102
+ if (model.report_checked === null)
2103
+ return this.note(w("summary.sealed", { producer: this.producer(model) }), { "data-sealed": "x-deal-v0" });
2104
+ return this.note(w("summary.standalone", { status: model.report_checked }), { "data-sealed": "x-deal-report" });
2105
+ };
2106
+ // The words for one move, as capsulectl's deal page words it (module.py
2107
+ // _journey_label): a key the pack has no word for, or a placeholder with no
2108
+ // value, words nothing.
2109
+ P.journeyLabel = function (move) {
2110
+ var template = word(move.key);
2111
+ if (template === null)
2112
+ return "";
2113
+ var facts = {};
2114
+ move.facts.forEach(function (pair) { facts[pair[0]] = pair[1]; });
2115
+ var values = {};
2116
+ Object.keys(facts).forEach(function (name) { if (name !== "detail")
2117
+ values[name] = facts[name]; });
2118
+ if (own(facts, "reason")) {
2119
+ var reason = facts.reason === "other" ? (own(facts, "detail") ? facts.detail : null) : word("journey.reason." + facts.reason) || "";
2120
+ delete values.reason;
2121
+ if (reason !== null)
2122
+ values.reason = reason;
2123
+ }
2124
+ if (move.classes !== null) {
2125
+ var named = move.classes.map(function (c) { return word("class." + c) || c.replace(/_/g, " "); });
2126
+ values.classes = named.length < 2 ? named.join("") : named.slice(0, -1).join(", ") + " and " + named[named.length - 1];
2127
+ }
2128
+ var missing = false;
2129
+ template.replace(PLACEHOLDER, function (_, name) { if (!own(values, name))
2130
+ missing = true; return ""; });
2131
+ if (missing)
2132
+ return "";
2133
+ // A reason the pack has no word for is said as nothing: no empty "()" is left behind
2134
+ // (capsulectl's page prints it; capsule-cli#465).
2135
+ return template.replace(PLACEHOLDER, function (_, name) { return values[name]; })
2136
+ .replace(/\s*\(\s*\)/g, "").replace(/\s+\)/g, ")");
2137
+ };
2138
+ // "How it went": the errand's moves in order, each opening to its sealed step.
2139
+ P.journey = function (model) {
2140
+ var r = model.report, self = this;
2141
+ if (SHARED_AUDIENCES.indexOf(r.audience) >= 0 || !r.journey.length)
2142
+ return [];
2143
+ var rows = [];
2144
+ var said = null;
2145
+ r.journey.forEach(function (move) {
2146
+ var step = move.step ? model.steps.find(function (s) { return s.capsule_id === move.step; }) || null : null;
2147
+ var when = step !== null && step.disclosure === "disclosed" ? step.at : null;
2148
+ var shown = when && when !== said ? when : null;
2149
+ said = when || said;
2150
+ var mover = word("journey_by." + move.by) || w("journey_by.unknown");
2151
+ var label = self.journeyLabel(move);
2152
+ rows.push(self.item(model, item(label ? mover + " · " + label : mover, move.step ? [move.step] : [], shown, false)));
2153
+ });
2154
+ return [this.kit.section(w("section.journey"), rows.concat([this.note(w("journey_note"))]))];
2155
+ };
2156
+ P.l1 = function (model) {
2157
+ var d = this.d, kit = this.kit, self = this;
2158
+ var r = model.report;
2159
+ var out = [this.sealedNote(model)];
2160
+ out.push(kit.section(w("section.authorized"), [this.committed(model.asked, "asked"), this.sectionSteps(model, "authorized")]));
2161
+ out = out.concat(this.journey(model));
2162
+ out.push(kit.section(w("section.proposed"), this.sectionSteps(model, "proposed")));
2163
+ out.push(kit.section(w("section.approved"), this.sectionSteps(model, "approved")));
2164
+ out.push(kit.section(w("section.merchant"), this.merchant(model)));
2165
+ var acted = [this.note(w("summary.lines", { producer: this.producer(model) }))];
2166
+ var did = r.did.map(function (i) { return self.item(model, i); });
2167
+ acted = acted.concat(did.length ? did : [this.note(w("acted.nothing"))]);
2168
+ if (r.money)
2169
+ acted.push(this.p(r.money, { "data-sealed-text": "money" }));
2170
+ acted = acted.concat(this.sectionSteps(model, "acted"));
2171
+ if (r.did_line)
2172
+ acted.push(this.note(r.did_line, { "data-sealed-text": "did-line" }));
2173
+ out.push(kit.section(w("section.acted"), acted));
2174
+ if (r.lifecycle) {
2175
+ var life = [this.p(r.lifecycle, { "data-sealed-text": "lifecycle" })];
2176
+ r.later.forEach(function (i) {
2177
+ life.push(self.item(model, item(self.timed("lifecycle.later", i.at || "", { text: i.text }), i.steps)));
2178
+ });
2179
+ if (r.may_change && r.as_of)
2180
+ life.push(this.note(this.timed("lifecycle.as_of", r.as_of, { text: r.may_change }), { "data-sealed-text": "may-change" }));
2181
+ out.push(kit.section(w("section.lifecycle"), life));
2182
+ }
2183
+ if (model.statements.length) {
2184
+ var heading = ["keep"].concat(SHARED_AUDIENCES).indexOf(r.audience) >= 0 ? "section.statements." + r.audience : "section.statements.keep";
2185
+ out.push(kit.section(w(heading), [model.statements.map(function (c) { return self.committed(c, "statement"); }), this.sectionSteps(model, "statements")]));
2186
+ }
2187
+ var toldItems = r.told.map(function (i) { return self.item(model, i); });
2188
+ out.push(kit.section(w("section.told"), [toldItems.length ? toldItems : [this.note(w("told.none"))], this.note(w("told.note"))]));
2189
+ if (r.deadlines.length) {
2190
+ var extra = r.deadline_note ? [this.note(r.deadline_note)] : [];
2191
+ out.push(kit.section(w("section.deadlines"), [this.deadlineList(r.deadlines), extra]));
2192
+ }
2193
+ r.cancellations.forEach(function (c) {
2194
+ var shows = kit.section(w("cancellation.shows"), [
2195
+ d.el("ul", {}, c.proven.map(function (p) { return d.el("li", {}, [p]); })),
2196
+ kit.section(w("cancellation.not_shows"), [d.el("ul", {}, c.not_proven.map(function (p) { return d.el("li", {}, [p]); }))], 4),
2197
+ self.steps(model, c.steps),
2198
+ ], 3);
2199
+ out.push(kit.section(w("section.cancellation"), [shows]));
2200
+ });
2201
+ if (!r.agent_anomalies.length && !r.counterparty_anomalies.length) {
2202
+ // One "none", not one per side: nothing is hidden by joining them.
2203
+ out.push(kit.section(w("section.anomalies"), [this.note(w("anomalies.none"))]));
2204
+ }
2205
+ else {
2206
+ var anomalies = [["agent", r.agent_anomalies], ["counterparty", r.counterparty_anomalies]].map(function (pair) {
2207
+ var body = pair[1].map(function (i) { return self.item(model, i); });
2208
+ return kit.section(w("anomalies." + pair[0]), body.length ? body : [self.note(w("anomalies.none"))], 3);
2209
+ });
2210
+ out.push(kit.section(w("section.anomalies"), anomalies));
2211
+ }
2212
+ var other = this.sectionSteps(model, "other");
2213
+ if (other.length)
2214
+ out.push(kit.section(w("section.other"), other));
2215
+ var keys = ["claims.tamper", "claims.reported", "claims.merchant"];
2216
+ if (model.steps.some(function (s) { return s.disclosure === "withheld"; }))
2217
+ keys.push("claims.withheld");
2218
+ out.push(kit.section(w("section.claims"), this.claims(keys)));
2219
+ return out;
2220
+ };
2221
+ P.merchant = function (model) {
2222
+ var d = this.d, kit = this.kit, self = this;
2223
+ var r = model.report;
2224
+ if (!r.merchant.length)
2225
+ return [this.note(w("merchant.none"))];
2226
+ var out = [this.note(w("merchant.intro", { producer: this.producer(model) }))];
2227
+ if (r.email_scope)
2228
+ out.push(this.p(r.email_scope, { "data-sealed-text": "email-scope" }));
2229
+ r.merchant.forEach(function (m) {
2230
+ var rows = m.rows.map(function (row) {
2231
+ var label = row[0] === "approved" && m.approved_basis ? w("merchant.approved_basis", { basis: m.approved_basis }) : w("merchant." + row[0]);
2232
+ return [label, row[1]];
2233
+ });
2234
+ var body = [
2235
+ self.p(w("merchant.signature", { text: m.merchant_says }), { "data-merchant-verified": m.verified ? "true" : "false" }),
2236
+ self.note(w("merchant.seal", { text: m.we_say })),
2237
+ ];
2238
+ if (m.key_supplied)
2239
+ body.push(self.p(w("merchant.key_supplied")));
2240
+ if (rows.length)
2241
+ body.push(d.el("dl", {}, rows.map(function (row) { return [d.el("dt", {}, [row[0]]), d.el("dd", {}, [row[1]])]; })));
2242
+ body.push(self.steps(model, m.steps));
2243
+ var title = m.order_id ? w("merchant.order", { order: m.order_id }) : w("merchant.email");
2244
+ out.push(kit.section(title, body, 3));
2245
+ });
2246
+ return out;
2247
+ };
2248
+ P.l2 = function (model) {
2249
+ var d = this.d, kit = this.kit, self = this;
2250
+ var out = [kit.verificationDetails(model.verification)];
2251
+ if (model.bundle_digest) {
2252
+ out.push(d.el("p", {}, [w("l2.bundle_digest"), " ", d.el("span", { class: "cv-mono", "data-bundle-digest": "true" }, [model.bundle_digest])]));
2253
+ }
2254
+ var rows = model.steps.map(function (s) {
2255
+ var position = s.n !== null ? String(s.n) : (s.section === "report" ? w("records.report") : "");
2256
+ return [position, s.record_type || w("records.unknown"), kit.disclosureBadge(s.disclosure), self.logText(s.log), self.shortId(s.capsule_id)];
2257
+ });
2258
+ out.push(kit.section(w("section.records"), [
2259
+ kit.dataTable([w("records.step"), w("records.kind"), w("records.disclosure"), w("records.log"), w("records.id")], rows),
2260
+ ], 3));
2261
+ var producers = model.producers.map(function (p) { return p !== null ? p : w("provenance.unrecorded"); }).join(w("provenance.then"));
2262
+ var prov = [this.note(w("provenance.by", { producers: producers }), { "data-provenance": "true" })];
2263
+ if (model.report.instructions)
2264
+ prov.push(this.note(model.report.instructions, { "data-sealed-text": "instructions" }));
2265
+ prov.push(this.note(w("wording.provenance", { id: PACK.id, sha: PACK.sha256 || "-" })));
2266
+ out.push(kit.section(w("section.provenance"), prov, 3));
2267
+ return out;
2268
+ };
2269
+ P.levels = function (model) {
2270
+ var l1Open = this.depth === "L1" || this.depth === "L2";
2271
+ return {
2272
+ headline: this.d.el("div", { "data-headline": "true" }, this.headline(model)),
2273
+ notes: this.copyNotes(model),
2274
+ l1: this.l1(model),
2275
+ l2: this.l2(model),
2276
+ l1_open: l1Open,
2277
+ l2_open: this.depth === "L2",
2278
+ };
2279
+ };
2280
+ // ---- seller drawing -------------------------------------------------------
2281
+ P.audienceKey = function (prefix, model) {
2282
+ var audience = model.receipt.report.audience;
2283
+ return prefix + "." + (["keep"].concat(SHARED_AUDIENCES).indexOf(audience) >= 0 ? audience : "keep");
2284
+ };
2285
+ P.n = function (model, step) {
2286
+ var found = step ? stepIn(model.receipt, step) : null;
2287
+ return found !== null && found.n !== null ? String(found.n) : "-";
2288
+ };
2289
+ P.withheldRow = function (state, key, attr) {
2290
+ return this.d.el("p", { "data-seller": attr, "data-state": state }, [this.kit.disclosureBadge(state), " ", this.d.el("span", {}, [w(key + "." + state)])]);
2291
+ };
2292
+ P.handoverText = function (h) {
2293
+ if (h.state === "recorded")
2294
+ return w("seller.handover.seller_observed");
2295
+ if (h.state === "withheld")
2296
+ return this.kit.disclosureBadge("withheld");
2297
+ return w("seller.handover.none");
2298
+ };
2299
+ P.sellerHeadline = function (model) {
2300
+ var d = this.d;
2301
+ var state;
2302
+ if (model.outcome)
2303
+ state = this.enumText("seller.outcome", model.outcome);
2304
+ else if (model.receipt.report.state)
2305
+ state = this.enumText("state", model.receipt.report.state);
2306
+ else
2307
+ state = w("l0.state.missing");
2308
+ var grid = this.kit.metricGrid([
2309
+ { label: w("seller.l0.item"), value: this.part(model.item) },
2310
+ { label: w("seller.l0.amount"), value: this.part(model.amount) },
2311
+ { label: w("l0.state"), value: state },
2312
+ ]);
2313
+ var payment = d.el("p", { "data-seller-line": "payment" }, [w("seller.l0.payment"), ": ", w("seller.payment.not_recorded")]);
2314
+ var handover = d.el("p", { "data-seller-line": "handover" }, [
2315
+ w("seller.l0.handover"), ": ", d.el("span", { "data-handover": model.handover.state }, [this.handoverText(model.handover)]),
2316
+ ]);
2317
+ return [grid, payment, handover];
2318
+ };
2319
+ P.sellerNotes = function (model) {
2320
+ var audience = model.receipt.report.audience;
2321
+ var notes = this.copyNotes(model.receipt);
2322
+ if (SHARED_AUDIENCES.indexOf(audience) >= 0)
2323
+ notes[0] = this.p(w("seller.shared." + audience), { "data-shared": audience });
2324
+ return notes;
2325
+ };
2326
+ P.leftOut = function (model) {
2327
+ var audience = model.receipt.report.audience;
2328
+ if (SHARED_AUDIENCES.indexOf(audience) < 0)
2329
+ return [];
2330
+ var kinds = model.receipt.report.withheld.join(", ");
2331
+ return [this.kit.section(w("seller.section.left_out"), [this.p(w("shared." + audience, { kinds: kinds }), { "data-left-out": audience })])];
2332
+ };
2333
+ P.sellerL1 = function (model) {
2334
+ var d = this.d, kit = this.kit, self = this;
2335
+ var r = model.receipt;
2336
+ var out = [this.sealedNote(r)].concat(this.leftOut(model));
2337
+ var authorised = [this.committed(r.asked, "seller.asked")];
2338
+ if (model.authority.length) {
2339
+ authorised.push(d.el("dl", {}, model.authority.map(function (f) {
2340
+ return [d.el("dt", {}, [w("seller.fact." + f.name)]), d.el("dd", { class: "cv-mono", "data-fact": f.name }, [f.value])];
2341
+ })));
2342
+ }
2343
+ authorised.push(this.withheldRow(model.floor, "seller.floor", "floor"));
2344
+ authorised = authorised.concat(this.sectionSteps(r, "authorized"));
2345
+ out.push(kit.section(w(this.audienceKey("seller.section.authorised", model)), authorised));
2346
+ out = out.concat(this.journey(r));
2347
+ var toldList = r.statements.map(function (c) { return self.committed(c, "statement"); });
2348
+ out.push(kit.section(w(this.audienceKey("seller.section.represented", model)), [
2349
+ toldList.length ? toldList : [this.note(w("seller.represented.none"))], this.sectionSteps(r, "statements"),
2350
+ ]));
2351
+ out.push(kit.section(w("seller.section.offers"), [this.offers(model), this.sectionSteps(r, "proposed")]));
2352
+ out.push(kit.section(w(this.audienceKey("seller.section.accepted", model)), [this.acceptances(model), this.sectionSteps(r, "approved")]));
2353
+ var payment = [this.note(w("seller.payment.none"), { "data-seller": "payment" })];
2354
+ model.evidence.forEach(function (e) {
2355
+ if (e.disclosure === "disclosed") {
2356
+ var verified = w(e.verified ? "seller.evidence.verified" : "seller.evidence.unverified");
2357
+ payment.push(d.el("p", { "data-evidence": e.step }, [w("seller.evidence.source") + " " + (e.source || "-") + " · " + verified]));
2358
+ }
2359
+ else {
2360
+ payment.push(d.el("p", { "data-evidence": e.step }, [kit.disclosureBadge(e.disclosure), " ", d.el("span", {}, [w("seller.evidence.withheld")])]));
2361
+ }
2362
+ });
2363
+ out.push(kit.section(w("seller.section.payment"), payment));
2364
+ out.push(kit.section(w("seller.section.handover"), [this.handover(model), this.sectionSteps(r, "acted")]));
2365
+ var given = [this.withheldRow(model.address, "seller.address", "address")];
2366
+ r.report.told.forEach(function (i) { given.push(self.item(r, i)); });
2367
+ given.push(this.note(w("told.note")));
2368
+ out.push(kit.section(w(this.audienceKey("seller.section.given", model)), given));
2369
+ if (r.report.deadlines.length)
2370
+ out.push(kit.section(w("seller.section.obligations"), [this.deadlineList(r.report.deadlines)]));
2371
+ else
2372
+ out.push(kit.section(w("seller.section.obligations"), [this.note(w("seller.obligations.none"))]));
2373
+ var stands = [];
2374
+ if (model.outcome) {
2375
+ stands.push(d.el("p", { "data-outcome": model.outcome }, [this.enumText("seller.outcome", model.outcome)]));
2376
+ if (model.outcome === "not_selected")
2377
+ stands.push(this.note(w("seller.not_selected")));
2378
+ }
2379
+ if (r.report.lifecycle)
2380
+ stands.push(this.p(r.report.lifecycle, { "data-sealed-text": "lifecycle" }));
2381
+ stands.push(this.note(w("seller.threads")));
2382
+ out.push(kit.section(w("section.lifecycle"), stands));
2383
+ var other = this.sectionSteps(r, "other");
2384
+ if (other.length)
2385
+ out.push(kit.section(w("section.other"), other));
2386
+ var keys = ["claims.tamper", "claims.reported", "seller.claims.handover"];
2387
+ if (r.steps.some(function (s) { return s.disclosure === "withheld"; }))
2388
+ keys.push("claims.withheld");
2389
+ out.push(kit.section(w("section.claims"), this.claims(keys)));
2390
+ return out;
2391
+ };
2392
+ P.offers = function (model) {
2393
+ var d = this.d, self = this;
2394
+ if (!model.offers.length)
2395
+ return [this.note(w("seller.offers.none"))];
2396
+ var rows = model.offers.map(function (o) {
2397
+ var status = o.accepted_by ? w("seller.offer.accepted") : (o.superseded_by ? w("seller.offer.superseded") : w("seller.offer.open"));
2398
+ return [
2399
+ self.n(model, o.step),
2400
+ self.enumText("seller.action", o.action),
2401
+ o.amount ? o.amount.value : "-",
2402
+ d.el("span", { "data-offer-status": o.accepted_by ? "accepted" : (o.superseded_by ? "superseded" : "open"), "data-offer": o.step }, [status]),
2403
+ ];
2404
+ });
2405
+ return [
2406
+ this.kit.dataTable([w("records.step"), w("seller.offers.action"), w("seller.offers.amount"), w("seller.offers.status")], rows),
2407
+ this.note(w("seller.offers.note")),
2408
+ ];
2409
+ };
2410
+ P.acceptances = function (model) {
2411
+ var d = this.d, self = this;
2412
+ if (!model.acceptances.length)
2413
+ return [this.note(w("seller.accepted.none"))];
2414
+ return model.acceptances.map(function (a) {
2415
+ var offer = model.offers.find(function (o) { return o.step === a.offer; }) || null;
2416
+ var named, detail;
2417
+ if (offer !== null) {
2418
+ named = w("seller.accepted.offer");
2419
+ detail = self.n(model, offer.step) + " · " + (offer.amount ? offer.amount.value : "-");
2420
+ }
2421
+ else {
2422
+ named = w("seller.accepted.offer_not_here");
2423
+ detail = "";
2424
+ }
2425
+ var parts = [
2426
+ d.el("p", {}, [named, " ", d.el("span", { "data-accepted-offer": a.offer || "" }, [detail])]),
2427
+ d.el("p", {}, [w("seller.accepted.digest"), " ", d.el("span", { class: "cv-mono", "data-offer-digest": "true" }, [a.offer_digest || "-"])]),
2428
+ ];
2429
+ if (a.channel || a.observed_at)
2430
+ parts.push(self.note((a.channel || "-") + " · " + (a.observed_at || "-")));
2431
+ parts.push(self.note(w("seller.accepted.words")));
2432
+ return d.el("div", { "data-acceptance": a.step }, parts);
2433
+ });
2434
+ };
2435
+ P.handover = function (model) {
2436
+ var d = this.d;
2437
+ var h = model.handover;
2438
+ var rows = PROVENANCES.map(function (provenance) {
2439
+ var state = provenance === "seller_observed" ? h.state : "not_present";
2440
+ return d.el("li", { "data-provenance": provenance, "data-state": state }, [
2441
+ d.el("strong", {}, [w("seller.provenance." + provenance)]), " ", d.el("span", {}, [w("seller.provenance." + provenance + "." + state)]),
2442
+ ]);
2443
+ });
2444
+ var out = [d.el("ul", {}, rows)];
2445
+ if (h.facts.length) {
2446
+ out.push(d.el("dl", {}, h.facts.map(function (f) {
2447
+ return [d.el("dt", {}, [w("seller.delivered." + f.name)]), d.el("dd", { class: "cv-mono", "data-fact": f.name }, [f.value])];
2448
+ })));
2449
+ }
2450
+ out.push(this.note(w("seller.handover.note")));
2451
+ return out;
2452
+ };
2453
+ P.sellerL2 = function (model) {
2454
+ var d = this.d, kit = this.kit, self = this;
2455
+ var out = this.l2(model.receipt);
2456
+ var chain = model.offers.map(function (o) {
2457
+ return [self.n(model, o.step), o.digest || "-", o.supersedes ? self.n(model, o.supersedes) : "-", o.superseded_by ? self.n(model, o.superseded_by) : "-"];
2458
+ });
2459
+ if (chain.length) {
2460
+ out.push(kit.section(w("seller.section.chain"), [
2461
+ kit.dataTable([w("records.step"), w("seller.chain.digest"), w("seller.chain.supersedes"), w("seller.chain.superseded_by")], chain),
2462
+ ], 3));
2463
+ }
2464
+ var opened = [];
2465
+ if (model.receipt.asked.state === "opened")
2466
+ opened.push(model.receipt.asked.step + "\u0000intent.verbatim_commitment");
2467
+ model.receipt.statements.forEach(function (c) { if (c.state === "opened")
2468
+ opened.push(c.step + "\u0000text_commitment"); });
2469
+ var rows = model.commitments.map(function (c) {
2470
+ var isOpened = opened.indexOf(c[0] + "\u0000" + c[1]) >= 0;
2471
+ return [self.n(model, c[0]), c[1], d.el("span", { class: "cv-mono" }, [c[2]]), w(isOpened ? "seller.commitment.opened" : "seller.commitment.sealed")];
2472
+ });
2473
+ out.push(kit.section(w("seller.section.commitments"), [
2474
+ kit.dataTable([w("records.step"), w("seller.commitment.field"), w("seller.commitment.value"), w("seller.commitment.state")], rows),
2475
+ ], 3));
2476
+ var legs = [
2477
+ [w("seller.leg.agreement"), w(model.offers.some(function (o) { return o.action === "commit"; }) ? "seller.leg.recorded" : "seller.leg.none")],
2478
+ [w("seller.leg.payment"), w("seller.leg.none")],
2479
+ [w("seller.leg.handover"), w("seller.provenance.seller_observed." + model.handover.state)],
2480
+ ];
2481
+ out.push(kit.section(w("seller.section.legs"), [kit.dataTable([w("seller.leg.name"), w("seller.leg.state")], legs)], 3));
2482
+ out.push(kit.section(w("seller.section.keys"), [
2483
+ d.el("ul", {}, model.keys.map(function (k) { return d.el("li", { class: "cv-mono", "data-key": "true" }, [k]); })),
2484
+ ], 3));
2485
+ return out;
2486
+ };
2487
+ P.sellerLevels = function (model) {
2488
+ var l1Open = this.depth === "L1" || this.depth === "L2";
2489
+ return {
2490
+ headline: this.d.el("div", { "data-headline": "true" }, this.sellerHeadline(model)),
2491
+ notes: this.sellerNotes(model),
2492
+ l1: this.sellerL1(model),
2493
+ l2: this.sellerL2(model),
2494
+ l1_open: l1Open,
2495
+ l2_open: this.depth === "L2",
2496
+ };
2497
+ };
2498
+ // The three levels of one page: L0 always shown, L1 and L2 one toggle each.
2499
+ P.page = function (l0, l1Summary, l1, l1Open, l2, l2Open, after) {
2500
+ var d = this.d;
2501
+ return [
2502
+ d.el("div", { "data-level": "L0" }, l0),
2503
+ d.el("div", { "data-level": "L1" }, [this.kit.drilldown(l1Summary, l1, l1Open)].concat(after ? [after] : [])),
2504
+ d.el("div", { "data-level": "L2" }, [this.kit.drilldown(w("depth.l2"), l2, l2Open)]),
2505
+ ];
2506
+ };
2507
+ function drawUnilateral(doc, depth, model) {
2508
+ var dr = new Drawer(doc, depth, false);
2509
+ var levels = dr.levels(model);
2510
+ var l0 = [];
2511
+ if (model.demo)
2512
+ l0.push(dr.d.el("p", { "data-demo": "true" }, [w("badge.demo")]));
2513
+ l0.push(dr.d.el("h2", {}, [w("page.title")]));
2514
+ l0.push(dr.checkedNote(model.verification));
2515
+ var keep = model.report.audience === "keep";
2516
+ if (keep)
2517
+ l0.push(dr.privateBanner());
2518
+ l0 = l0.concat([levels.headline], levels.notes);
2519
+ // The holder's own copy and nothing from the other side: no record.
2520
+ if (keep)
2521
+ l0.push(dr.sides("none", [dr.missingHalf(null, true)], true, false));
2522
+ return dr.page(l0, w("depth.l1"), levels.l1, levels.l1_open, levels.l2, levels.l2_open, keep ? dr.actions("none") : null);
2523
+ }
2524
+ function drawSeller(doc, depth, model) {
2525
+ var dr = new Drawer(doc, depth, true);
2526
+ var levels = dr.sellerLevels(model);
2527
+ var l0 = [];
2528
+ if (model.receipt.demo)
2529
+ l0.push(dr.d.el("p", { "data-demo": "true" }, [w("badge.demo")]));
2530
+ l0.push(dr.d.el("h2", {}, [w("seller.title")]));
2531
+ l0.push(dr.checkedNote(model.receipt.verification));
2532
+ var keep = model.receipt.report.audience === "keep";
2533
+ if (keep)
2534
+ l0.push(dr.privateBanner());
2535
+ l0 = l0.concat([levels.headline], levels.notes);
2536
+ if (keep)
2537
+ l0.push(dr.sides("none", [dr.missingHalf(null, true)], true, false));
2538
+ return dr.page(l0, w("seller.depth.l1"), levels.l1, levels.l1_open, levels.l2, levels.l2_open, keep ? dr.actions("none") : null);
2539
+ }
2540
+ // ---- drawing: the v1 deal receipt -----------------------------------------
2541
+ P.token = function (prefix, value) {
2542
+ var text = word(prefix + "." + value);
2543
+ return text !== null ? text : value;
2544
+ };
2545
+ P.dealState = function (model) {
2546
+ var d = this.d;
2547
+ var parts = [this.token("deal.state", model.start.state)];
2548
+ // The deal-level line is the start state, then "settled" or nothing: no close, no done (section 9).
2549
+ if (model.start.state === "started" && model.settled)
2550
+ parts.push(" · ", d.el("span", { "data-settled": "true" }, [w("deal.settled")]));
2551
+ return d.el("span", { "data-deal-state": model.start.state }, parts);
2552
+ };
2553
+ P.dealHeadline = function (model) {
2554
+ var d = this.d;
2555
+ var out = [this.kit.metricGrid([{ label: w("l0.state"), value: this.dealState(model) }])];
2556
+ if (model.start.by !== null)
2557
+ out.push(this.note(w("deal.start.by", { by: this.token("deal.start.by", model.start.by) }), { "data-start-by": model.start.by }));
2558
+ if (model.start.local)
2559
+ out.push(this.note(w("deal.local"), { "data-local": "start" }));
2560
+ if (model.rows_state !== "listed")
2561
+ out.push(this.note(w("deal.rows." + model.rows_state), { "data-rows-state": model.rows_state }));
2562
+ out.push(this.note(w("deal.as_of", { at: model.as_of || w("deal.no_time") }), { "data-as-of": model.as_of }));
2563
+ return d.el("div", { "data-headline": "true" }, out);
2564
+ };
2565
+ P.dateText = function (value) { return value === "not_set" ? w("deal.date.not_set") : value; };
2566
+ P.rowDetail = function (row) {
2567
+ var bits = [];
2568
+ // A ruled term shows the ruling's value, not a statement value: a statement's value is not the ruling's.
2569
+ if (row.value !== null && row.status !== "ruled")
2570
+ bits.push(w("deal.row.value", { value: this.token("deal.value", row.value) }));
2571
+ if (row.remedy !== null)
2572
+ bits.push(w("deal.row.remedy", { remedy: this.token("deal.remedy", row.remedy) }));
2573
+ if (row.remedy === "not_counted" && row.remedy_made)
2574
+ bits.push(w("deal.row.remedy_made"));
2575
+ if (row.ruling !== null) {
2576
+ var value = this.token("deal.value", row.ruling.value);
2577
+ // `against` is buyer, seller or null (anything else declined the report); null: the ruling alone.
2578
+ bits.push(row.ruling.against !== null ? w("deal.row.ruling", { value: value, side: this.token("deal.side", row.ruling.against) }) : w("deal.row.ruling.bare", { value: value }));
2579
+ }
2580
+ bits.push(w("deal.row.check", { check: this.token("deal.check", row.check) }));
2581
+ if (row.local)
2582
+ bits.push(w("deal.local"));
2583
+ return bits.join("; ");
2584
+ };
2585
+ P.dealRows = function (model) {
2586
+ var d = this.d, self = this;
2587
+ if (model.rows_state !== "listed")
2588
+ return [this.note(w("deal.rows." + model.rows_state), { "data-rows-state": model.rows_state })];
2589
+ if (!model.rows.length)
2590
+ return [this.note(w("deal.rows.none"), { "data-rows-state": "listed" })];
2591
+ var rows = model.rows.map(function (row) {
2592
+ return [
2593
+ d.el("span", { class: "cv-mono", "data-row-id": row.id }, [row.id]),
2594
+ row.owed_by,
2595
+ d.el("span", { "data-row-status": row.status }, [self.token("deal.status", row.status)]),
2596
+ self.dateText(row.due),
2597
+ self.dateText(row.window_end),
2598
+ self.rowDetail(row),
2599
+ ];
2600
+ });
2601
+ return [this.kit.dataTable([w("deal.col.row"), w("deal.col.owed_by"), w("deal.col.status"), w("deal.col.due"), w("deal.col.window_end"), w("deal.col.detail")], rows),
2602
+ this.note(w("deal.rows.note"))];
2603
+ };
2604
+ // The payment legs the rows relied on, each as its record states it (evidencebook#588). No leg is picked
2605
+ // and no verdict is drawn from one: the check above stays the only verdict.
2606
+ P.dealLegs = function (model) {
2607
+ var d = this.d, self = this;
2608
+ var withheld = model.rows_state === "withheld";
2609
+ if (!withheld && (model.rows_state !== "listed" || !model.rows.length))
2610
+ return [];
2611
+ var rows = [];
2612
+ function cells(leg, lead) {
2613
+ return lead.concat([
2614
+ leg.leg,
2615
+ leg.status,
2616
+ leg.money.length ? leg.money.map(function (m) { return m[0] + " " + m[1]; }).join("; ") : "-",
2617
+ leg.observed_at !== null ? leg.observed_at : w("deal.no_time"),
2618
+ leg.payment_ref !== null ? leg.payment_ref.type + " " + leg.payment_ref.value : "-",
2619
+ d.el("span", { class: "cv-mono", "data-leg-record": leg.record }, [leg.record]),
2620
+ ]);
2621
+ }
2622
+ var head = [w(withheld ? "deal.col.sealer" : "deal.col.leg_side"), w("deal.col.leg"), w("deal.col.leg_status"), w("deal.col.amount"), w("deal.col.observed"), w("deal.col.payment_ref"), w("deal.col.record")];
2623
+ if (withheld) {
2624
+ // The rows are withheld, so no record is tied to a term: the side is the settlement's own sealer_role.
2625
+ model.withheld_legs.forEach(function (leg) { rows.push(cells(leg, [leg.sealer_role !== null ? leg.sealer_role : "-"])); });
2626
+ }
2627
+ else {
2628
+ head.unshift(w("deal.col.row"));
2629
+ model.rows.forEach(function (row) {
2630
+ row.legs.forEach(function (leg) {
2631
+ rows.push(cells(leg, [d.el("span", { class: "cv-mono", "data-row-id": row.id }, [row.id]), self.token("deal.side", leg.side)]));
2632
+ });
2633
+ });
2634
+ }
2635
+ var inner = rows.length
2636
+ ? [this.kit.dataTable(head, rows), this.note(w(withheld ? "deal.legs.note.withheld" : "deal.legs.note"), { "data-legs": withheld ? "withheld" : "listed" })]
2637
+ : [this.note(w(withheld ? "deal.legs.none.withheld" : "deal.legs.none"), { "data-legs": "none" })];
2638
+ return [this.kit.section(w("deal.section.legs"), inner)];
2639
+ };
2640
+ P.dealL1 = function (model) {
2641
+ return [
2642
+ this.note(w("summary.standalone", { status: model.report_checked === null ? "-" : model.report_checked }), { "data-sealed": "x-deal-report" }),
2643
+ this.note(w("deal.report.scope")),
2644
+ this.kit.section(w("deal.section.rows"), this.dealRows(model)),
2645
+ ].concat(this.dealLegs(model));
2646
+ };
2647
+ P.dealL2 = function (model) {
2648
+ var d = this.d, kit = this.kit;
2649
+ var out = [kit.verificationDetails(model.verification)];
2650
+ if (model.bundle_digest) {
2651
+ out.push(d.el("p", {}, [w("l2.bundle_digest"), " ", d.el("span", { class: "cv-mono", "data-bundle-digest": "true" }, [model.bundle_digest])]));
2652
+ }
2653
+ var basis = [];
2654
+ model.rows.forEach(function (row) {
2655
+ row.relied_on.forEach(function (e) {
2656
+ basis.push([row.id, d.el("span", { class: "cv-mono" }, [e.record]), e.side, e.time !== null ? e.time : w("deal.no_time"), w(e.named_witness ? "deal.named_witness.yes" : "deal.named_witness.no")]);
2657
+ });
2658
+ });
2659
+ var inner = basis.length
2660
+ ? [kit.dataTable([w("deal.col.row"), w("deal.col.record"), w("deal.col.side"), w("deal.col.time"), w("deal.col.named_witness")], basis)]
2661
+ : [this.note(w("deal.basis.none"))];
2662
+ out.push(kit.section(w("deal.section.basis"), inner, 3));
2663
+ var rest = [];
2664
+ if (model.pack_digest)
2665
+ rest.push(this.note(w("deal.pack_digest"), { "data-pack": "true" }), d.el("p", { class: "cv-mono" }, [model.pack_digest]));
2666
+ var r = model.rests_on;
2667
+ if (r.own_size !== null)
2668
+ rest.push(this.note(w("deal.rests.own", { size: String(r.own_size) })));
2669
+ if (r.counterparty !== null) {
2670
+ rest.push(this.note(w("deal.rests.counterparty", { counted: r.counterparty.counted === null ? "-" : String(r.counterparty.counted) })));
2671
+ if (r.counterparty.fork_at)
2672
+ rest.push(this.note(w("deal.rests.fork", { at: String(r.counterparty.fork_at) })));
2673
+ }
2674
+ if (r.counterparty_layer !== null)
2675
+ rest.push(this.note(w(r.counterparty_layer ? "deal.rests.layer" : "deal.rests.no_layer")));
2676
+ if (r.witnesses !== null)
2677
+ rest.push(this.note(w("deal.rests.witnesses", { count: String(r.witnesses) })));
2678
+ rest.push(this.note(w("wording.provenance", { id: PACK.id, sha: PACK.sha256 || "-" })));
2679
+ out.push(kit.section(w("deal.section.rests"), rest, 3));
2680
+ return out;
2681
+ };
2682
+ function drawDeal(doc, depth, model) {
2683
+ var dr = new Drawer(doc, depth, false);
2684
+ var l0 = [dr.d.el("h2", {}, [w("deal.title")])];
2685
+ var keep = model.audience === "keep";
2686
+ if (keep)
2687
+ l0.push(dr.privateBanner());
2688
+ l0.push(dr.dealHeadline(model));
2689
+ l0 = l0.concat(dr.copyNotes(model));
2690
+ var l1Open = depth === "L1" || depth === "L2";
2691
+ return dr.page(l0, w("deal.depth.l1"), dr.dealL1(model), l1Open, dr.dealL2(model), depth === "L2", null);
2692
+ }
2693
+ // ---- drawing: the composition section and the bilateral page ---------------
2694
+ function pairText(members) { return members[0] + " – " + members[1]; }
2695
+ function findingsText(findings) { return findings.length ? findings.join(", ") : "none"; }
2696
+ function claimText(c) { return c.findings.length ? c.status + " (" + c.findings.join(", ") + ")" : c.status; }
2697
+ // Python's json.dumps(v, ensure_ascii=False, separators=(",", ":")).
2698
+ function pyJson(v) {
2699
+ if (v === null || v === undefined)
2700
+ return "null";
2701
+ if (Array.isArray(v))
2702
+ return "[" + v.map(pyJson).join(",") + "]";
2703
+ if (typeof v === "object")
2704
+ return "{" + Object.keys(v).map(function (k) { return JSON.stringify(k) + ":" + pyJson(v[k]); }).join(",") + "}";
2705
+ return JSON.stringify(v);
2706
+ }
2707
+ function corroborationText(c) {
2708
+ if (c.result === "redundant")
2709
+ return (c.report || "redundant, not corroborating") + " (" + c.reasons.join(", ") + ")";
2710
+ if (c.result === "corroborating")
2711
+ return "corroborating, on declared custody";
2712
+ return "not applicable: the join did not derive agree";
2713
+ }
2714
+ function compositionSection(dr, c) {
2715
+ var d = dr.d, kit = dr.kit;
2716
+ var out = [d.el("p", { "data-composition-status": c.status }, ["composed/v1 check: " + c.status])];
2717
+ if (c.findings.length)
2718
+ out.push(d.el("p", {}, ["findings: " + c.findings.join(", ")]));
2719
+ if (c.malformed)
2720
+ return kit.section("Composition", out, 3);
2721
+ out.push(d.el("p", {}, [COMPOSED_SCOPE]));
2722
+ out.push(kit.section("Composed digest", [kit.dataTable(["declared", "recomputed", "matches"], [[c.digest_declared, c.digest_recomputed || "uncomputable", c.digest_matches ? "yes" : "no"]])], 4));
2723
+ var rows = c.members.map(function (m) {
2724
+ return [m.id, m.observer, m.outcome, m.body, m.digest]
2725
+ .concat(m.claims !== null ? m.claims.map(claimText) : [NOT_APPLICABLE, NOT_APPLICABLE, NOT_APPLICABLE])
2726
+ .concat([m.refusal_signature || NOT_APPLICABLE, findingsText(m.findings)]);
2727
+ });
2728
+ out.push(kit.section("Members", [kit.dataTable(["member", "observer", "outcome", "body", "digest", "graph closure", "interval coverage",
2729
+ "per-record membership", "refusal signature", "findings"], rows)], 4));
2730
+ out.push(kit.section("Observers", [
2731
+ kit.dataTable(["observer", "role", "custody domain"], c.observers.map(function (o) { return [o.id, o.role, o.custody_domain]; })),
2732
+ d.el("p", {}, [COMPOSED_CUSTODY]),
2733
+ ], 4));
2734
+ var missing = c.closure_missing.length ? c.closure_missing.join(", ") : "none";
2735
+ out.push(kit.section("Composition closure", [
2736
+ d.el("p", { "data-closure-status": c.closure.status }, [c.closure.status + "; missing: " + missing + "; findings: " + findingsText(c.closure.findings)]),
2737
+ ], 4));
2738
+ if (!c.joins.length) {
2739
+ out.push(kit.section("Joins", [d.el("p", {}, ["No joins."])], 4));
2740
+ return kit.section("Composition", out, 3);
2741
+ }
2742
+ var joins = [kit.dataTable(["members", "basis", "declared", "derived", "result"], c.joins.map(function (j) {
2743
+ return [pairText(j.members), j.basis, j.declared, j.derived || "not derivable", j.result];
2744
+ }))];
2745
+ c.joins.forEach(function (j) {
2746
+ if (!j.differences.length)
2747
+ return;
2748
+ var lists = j.differences.map(function (diff) {
2749
+ return d.el("dl", { "data-pointer": diff.pointer }, [d.el("dt", {}, [diff.pointer])].concat(diff.values.map(function (x) {
2750
+ return d.el("dd", {}, [x.resolved ? x.member + ": " + pyJson(x.value) : x.member + ": does not resolve"]);
2751
+ })));
2752
+ });
2753
+ joins.push(d.el("div", { "data-differences": "true" }, [d.el("p", {}, ["Differing values: " + pairText(j.members)])].concat(lists)));
2754
+ });
2755
+ out.push(kit.section("Joins", joins, 4));
2756
+ out.push(kit.section("Agreement", [kit.dataTable(["members", "result"], c.corroboration.map(function (x) {
2757
+ return [pairText(x.members), corroborationText(x)];
2758
+ }))], 4));
2759
+ return kit.section("Composition", out, 3);
2760
+ }
2761
+ // bilateral._token: an enum's words, or the token itself when there are none.
2762
+ function enumToken(prefix, value) { var t = word(prefix + "." + value); return truthy(t) ? t : value; }
2763
+ function drawBilateral(doc, depth, model) {
2764
+ var dr = new Drawer(doc, depth, false);
2765
+ var d = dr.d, kit = dr.kit;
2766
+ var drawn = model.parties.map(function (p) {
2767
+ if (p.seller !== null)
2768
+ return new Drawer(doc, depth, true).sellerLevels(p.seller);
2769
+ return new Drawer(doc, depth, false).levels(p.receipt);
2770
+ });
2771
+ var heading = function (party) {
2772
+ return w("party.heading", { role: party.role || w("party.role_undeclared"), member: party.member });
2773
+ };
2774
+ var keep = model.parties.some(function (p) { return p.audience === "keep"; });
2775
+ var one = model.parties.length === 1;
2776
+ var l0 = [d.el("h2", {}, [w(one ? "bilateral.title.one_sided" : "bilateral.title")]), dr.checkedNote(model.verification)];
2777
+ if (keep)
2778
+ l0.push(dr.privateBanner());
2779
+ var dealText;
2780
+ if (model.deal_state === "agree" && model.deal !== null)
2781
+ dealText = w(one ? "deal.one" : "deal.agree", { deal: model.deal });
2782
+ else if (model.deal_state === "mismatch")
2783
+ dealText = w("deal.mismatch", { deals: model.named.join(", ") });
2784
+ else
2785
+ dealText = w("deal.unnamed");
2786
+ l0.push(d.el("p", { "data-deal-state": model.deal_state }, [dealText]));
2787
+ // A one-sided page's joins all derive one_sided, which its case line
2788
+ // says; they stay in L2's composition section.
2789
+ if (one) {
2790
+ // no joins section in L0
2791
+ }
2792
+ else if (!model.joins.length) {
2793
+ l0.push(kit.section(w("joins.heading"), [d.el("p", {}, [w("joins.none")])], 3));
2794
+ }
2795
+ else {
2796
+ l0.push(kit.section(w("joins.heading"), [d.el("ul", {}, model.joins.map(function (jv) {
2797
+ var j = jv.join, c = jv.corroboration;
2798
+ var derived = j.derived || "not_derivable";
2799
+ var parts = [d.el("span", {}, [w("join.line", { basis: enumToken("join.basis", j.basis), declared: enumToken("join.state", j.declared), derived: enumToken("join.state", derived) })])];
2800
+ if (j.result === "join_state_mismatch")
2801
+ parts.push(d.el("span", {}, [" " + w("join.result.join_state_mismatch")]));
2802
+ if (c && c.result === "corroborating")
2803
+ parts.push(d.el("span", {}, [" " + w("corroboration.corroborating")]));
2804
+ else if (c && c.result === "redundant")
2805
+ parts.push(d.el("span", {}, [" " + w("corroboration.redundant", { reasons: c.reasons.join(", ") })]));
2806
+ return d.el("li", {
2807
+ "data-join-basis": j.basis, "data-join-declared": j.declared, "data-join-derived": derived, "data-join-result": j.result,
2808
+ "data-corroboration": c ? c.result : "none",
2809
+ }, parts);
2810
+ }))], 3));
2811
+ }
2812
+ var halves = model.parties.map(function (party, i) {
2813
+ var levels = drawn[i];
2814
+ var section = kit.section(heading(party), [levels.headline].concat(levels.notes), 3);
2815
+ var attrs = { "data-party": party.member, "data-cut": party.audience };
2816
+ // On the holder's page their own copy is ours; every other copy is theirs, as received.
2817
+ // In a report the reader may not be the owner, so the owner's side is
2818
+ // named, not "your" (Sherlock2, #386).
2819
+ if (party.audience === "keep")
2820
+ return dr.half("ours", w(dr.carrier === "report" ? "sides.ours.shared" : "sides.ours"), [section], attrs);
2821
+ var label = keep ? w("sides.theirs") : w("sides.half", { role: party.role || w("party.role_undeclared") });
2822
+ return dr.half("theirs", label, [section], attrs);
2823
+ });
2824
+ if (model.missing !== null)
2825
+ halves.push(dr.missingHalf(model.missing, keep));
2826
+ l0.push(dr.sides(model.case, halves, keep));
2827
+ if (!one)
2828
+ l0.push(d.el("p", { class: "cv-muted" }, [w("parts.own")]));
2829
+ var l1 = model.parties.map(function (p, i) { return d.el("div", { "data-party": p.member }, [kit.section(heading(p), drawn[i].l1, 3)]); });
2830
+ var l2 = [kit.verificationDetails(model.verification)];
2831
+ if (model.bundle_digest) {
2832
+ l2.push(d.el("p", {}, [w("l2.bundle_digest"), " ", d.el("span", { class: "cv-mono", "data-bundle-digest": "true" }, [model.bundle_digest])]));
2833
+ }
2834
+ l2.push(d.el("div", { "data-composition": "true" }, [kit.section(w("l2.composition"), [compositionSection(dr, model.composition)], 3)]));
2835
+ model.parties.forEach(function (p, i) { l2.push(d.el("div", { "data-party": p.member }, [kit.section(heading(p), drawn[i].l2, 3)])); });
2836
+ return dr.page(l0, w("depth.l1"), l1, depth === "L1" || depth === "L2", l2, depth === "L2", keep ? dr.actions(model.case) : null);
2837
+ }
2838
+ // ---- the modules (presentation contract: canRender, buildModel, render) ----
2839
+ // The module's manifest id: the x-deal-v0 modules are /v0, the x-deal-v1 module /v1.
2840
+ function moduleId(kind) { return "capsuleviewer.receipt." + kind + (kind === "deal" ? "/v1" : "/v0"); }
2841
+ var DRAW = { unilateral: drawUnilateral, seller: drawSeller, bilateral: drawBilateral, deal: drawDeal };
2842
+ // The page could not check the receipt here: no receipt, only the line
2843
+ // and where to check it, in the pack's words (row.cannot_check,
2844
+ // row.cannot_check_pointer; Sherlock2, capsule-viewer#392).
2845
+ function cannotCheckLevels(doc) {
2846
+ var d = new Drawing(doc);
2847
+ var line = d.el("p", { class: "cv-tone--caution", "data-cannot-check": "true" }, [w("row.cannot_check") + ". " + w("row.cannot_check_pointer")]);
2848
+ return [d.el("div", { "data-level": "L0" }, [line]), d.el("div", { "data-level": "L1" }, []), d.el("div", { "data-level": "L2" }, [])];
2849
+ }
2850
+ var TITLES = { unilateral: "page.title", seller: "seller.title", bilateral: "bilateral.title", deal: "deal.title" };
2851
+ // The kit stylesheet, once per document (its bytes are what the manifest's
2852
+ // style_sha256 pins).
2853
+ function ensureStyle(doc) {
2854
+ if (!KIT_CSS || doc.getElementById("cv-kit-css"))
2855
+ return;
2856
+ var style = doc.createElement("style");
2857
+ style.id = "cv-kit-css";
2858
+ style.textContent = KIT_CSS;
2859
+ (doc.head || doc.documentElement).appendChild(style);
2860
+ }
2861
+ // One module. `env` is what the page's runtime does not hand a module (see
2862
+ // the file comment); a page's module takes the defaults. The tests give the
2863
+ // Python twin's inputs instead, to compare the two.
2864
+ // audience the page's audience, or null (the copy's own)
2865
+ // verification context -> the kit's VerificationResult
2866
+ // assurance context -> {bundle_digest, witnesses, countersignatures}
2867
+ // composition view -> the composed/v1 result, or null
2868
+ // memberContext (bundle, member id) -> a carried copy's context (or a promise of one)
2869
+ function createModule(kind, env) {
2870
+ if (!own(DRAW, kind))
2871
+ throw new Error("no receipt module " + kind);
2872
+ var e = {
2873
+ audience: env && env.audience !== undefined ? env.audience : null,
2874
+ verification: (env && env.verification) || pageVerification,
2875
+ assurance: (env && env.assurance) || function (context) { return pageAssurance(context, kind === "deal" ? EXTENSION_V1 : EXTENSION); },
2876
+ composition: (env && env.composition) || compositionOf,
2877
+ memberContext: (env && env.memberContext) || pageMemberContext,
2878
+ // The page says each time in the reader's zone; the parity tests leave it off to compare with the script-free twin.
2879
+ localTime: !!(env && env.localTime),
2880
+ };
2881
+ // Sherlock2 on capsule-viewer#392: a page whose own check cannot run in
2882
+ // full here (no strict result: this browser has no Ed25519) draws no
2883
+ // receipt, only the can't-check line and where to check it. A verifier's
2884
+ // report given in env (capsulectl's) is not this page's own check.
2885
+ var cannotCheckHere = function (context) {
2886
+ return !(env && env.verification) && map(context).strict === undefined;
2887
+ };
2888
+ var build = function (context) {
2889
+ if (cannotCheckHere(context))
2890
+ return { cannot_check: true };
2891
+ var v = view(context, e);
2892
+ if (kind === "deal")
2893
+ return buildDeal(v, e.audience);
2894
+ if (kind === "bilateral")
2895
+ return buildBilateral(v, e);
2896
+ if (kind === "seller")
2897
+ return buildSeller(v, e.audience);
2898
+ // A seller's copy, by its packaging or by its own sealed records, is
2899
+ // never shown as a buyer's receipt.
2900
+ if (sellerKindEngaged(v) || sealedSide(v) === "seller")
2901
+ throw new Unavailable("a seller's copy is the seller receipt's");
2902
+ return buildReceipt(v, e.audience);
2903
+ };
2904
+ var declined = function (err) {
2905
+ if (err instanceof Unavailable)
2906
+ return false;
2907
+ throw err;
2908
+ };
2909
+ return {
2910
+ manifest: kind === KIND ? MANIFEST : { id: moduleId(kind) },
2911
+ title: w(TITLES[kind]),
2912
+ // Declining is canRender's answer: nothing of this module is shown.
2913
+ canRender: function (context) {
2914
+ try {
2915
+ var built = build(context);
2916
+ if (built && typeof built.then === "function")
2917
+ return built.then(function () { return true; }, declined);
2918
+ return true;
2919
+ }
2920
+ catch (err) {
2921
+ return declined(err);
2922
+ }
2923
+ },
2924
+ buildModel: build,
2925
+ // Draws into host.L0, host.L1 and host.L2 at host.depth.
2926
+ render: function (model, host) {
2927
+ var doc = host.L0.ownerDocument;
2928
+ var depth = DEPTHS.indexOf(host.depth) >= 0 ? host.depth : "L0";
2929
+ ensureStyle(doc);
2930
+ var carried = host.L0.closest ? host.L0.closest("[data-receipt-carrier]") : null;
2931
+ drawCarrier = carried && carried.getAttribute("data-receipt-carrier") === "report" ? "report" : null;
2932
+ var levels;
2933
+ try {
2934
+ levels = model && model.cannot_check === true ? cannotCheckLevels(doc) : DRAW[kind](doc, depth, model);
2935
+ }
2936
+ finally {
2937
+ drawCarrier = null;
2938
+ }
2939
+ // One text node per run of text, as the Python twin's HTML parses: the
2940
+ // browser shapes each text node on its own, so a run built from several
2941
+ // would lay out a fraction of a pixel differently.
2942
+ levels.forEach(function (level) { level.normalize(); });
2943
+ [host.L0, host.L1, host.L2].forEach(function (region, i) {
2944
+ var wrap = doc.createElement("div");
2945
+ wrap.className = "cv-kit";
2946
+ wrap.setAttribute("data-receipt-module", moduleId(kind));
2947
+ wrap.appendChild(levels[i]);
2948
+ region.appendChild(wrap);
2949
+ if (e.localTime)
2950
+ localTimes(wrap);
2951
+ });
2952
+ },
2953
+ };
2954
+ }
2955
+ var module = createModule(KIND, { localTime: true });
2956
+ root.CapsuleViewerReceipt = {
2957
+ KIND: KIND,
2958
+ MANIFEST: MANIFEST,
2959
+ WORDS: WORDS,
2960
+ PACK: PACK,
2961
+ KIT_CSS: KIT_CSS,
2962
+ module: module,
2963
+ createModule: createModule,
2964
+ Unavailable: Unavailable,
2965
+ checkOpening: checkOpening,
2966
+ recordDigest: recordDigest,
2967
+ sha256Hex: sha256Hex,
2968
+ utf8: utf8,
2969
+ jcs: jcs,
2970
+ formatAmount: formatAmount,
2971
+ plainTime: plainTime,
2972
+ localTimes: localTimes,
2973
+ bundleVerified: bundleVerified,
2974
+ };
2975
+ if (typeof root.EvidenceGraph !== "undefined" && root.EvidenceGraph && typeof root.EvidenceGraph.registerPresentation === "function") {
2976
+ root.EvidenceGraph.registerPresentation(module);
2977
+ }
2978
+ })(root);
2979
+ /** The receipt script's API (CapsuleViewerReceipt), from a private root. */
2980
+ export const RECEIPT_CORE = root.CapsuleViewerReceipt;
2981
+ /** The receipt modules' manifests, by kind, as go/receipt ships them. */
2982
+ export const RECEIPT_MANIFESTS = {
2983
+ "unilateral": {
2984
+ "spec_version": "aac.presentation-manifest/v0",
2985
+ "id": "capsuleviewer.receipt.unilateral/v0",
2986
+ "presentation_api": "aac.presentation-api/v0",
2987
+ "runtime_min": "0.1.0",
2988
+ "trust_class": "trusted-executable",
2989
+ "requires": {
2990
+ "bundle_kind": "evidence-bundle/v2",
2991
+ "extensions": {
2992
+ "required": [
2993
+ "x-deal-v0"
2994
+ ]
2995
+ }
2996
+ },
2997
+ "forbids": {
2998
+ "profiles": [
2999
+ "spec_version:report/v1",
3000
+ "spec_version:evaluation-summary/v1",
3001
+ "result_version:evidence-result-v0"
3002
+ ],
3003
+ "extensions": [
3004
+ "composed/v1",
3005
+ "x-history-selection/v0",
3006
+ "x-deal-seller/v0"
3007
+ ]
3008
+ },
3009
+ "audiences": [
3010
+ "keep",
3011
+ "counterparty",
3012
+ "adjudicator",
3013
+ "*"
3014
+ ],
3015
+ "formats": [
3016
+ "html"
3017
+ ],
3018
+ "fallback": false,
3019
+ "priority": 1,
3020
+ "executable": {
3021
+ "carrier": "module-slot",
3022
+ "script_sha256": "47ed7bdebc603427d6250da520a5cb7618da044a15765e94003e5ae2a7e4727c",
3023
+ "style_sha256": [
3024
+ "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3025
+ ]
3026
+ }
3027
+ },
3028
+ "seller": {
3029
+ "spec_version": "aac.presentation-manifest/v0",
3030
+ "id": "capsuleviewer.receipt.seller/v0",
3031
+ "presentation_api": "aac.presentation-api/v0",
3032
+ "runtime_min": "0.1.0",
3033
+ "trust_class": "trusted-executable",
3034
+ "requires": {
3035
+ "bundle_kind": "evidence-bundle/v2",
3036
+ "extensions": {
3037
+ "required": [
3038
+ "x-deal-v0",
3039
+ "x-deal-seller/v0"
3040
+ ]
3041
+ }
3042
+ },
3043
+ "forbids": {
3044
+ "profiles": [
3045
+ "spec_version:report/v1",
3046
+ "spec_version:evaluation-summary/v1",
3047
+ "result_version:evidence-result-v0"
3048
+ ],
3049
+ "extensions": [
3050
+ "composed/v1",
3051
+ "x-history-selection/v0"
3052
+ ]
3053
+ },
3054
+ "audiences": [
3055
+ "keep",
3056
+ "counterparty",
3057
+ "adjudicator",
3058
+ "*"
3059
+ ],
3060
+ "formats": [
3061
+ "html"
3062
+ ],
3063
+ "fallback": false,
3064
+ "priority": 1,
3065
+ "executable": {
3066
+ "carrier": "module-slot",
3067
+ "script_sha256": "449f15cb5aa70d69a77e0d914bfa7876f3f0c29f0a336ae5cea5507f5658871d",
3068
+ "style_sha256": [
3069
+ "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3070
+ ]
3071
+ }
3072
+ },
3073
+ "bilateral": {
3074
+ "spec_version": "aac.presentation-manifest/v0",
3075
+ "id": "capsuleviewer.receipt.bilateral/v0",
3076
+ "presentation_api": "aac.presentation-api/v0",
3077
+ "runtime_min": "0.1.0",
3078
+ "trust_class": "trusted-executable",
3079
+ "requires": {
3080
+ "bundle_kind": "evidence-bundle/v2",
3081
+ "extensions": {
3082
+ "required": [
3083
+ "composed/v1"
3084
+ ]
3085
+ }
3086
+ },
3087
+ "forbids": {
3088
+ "profiles": [
3089
+ "spec_version:report/v1",
3090
+ "spec_version:evaluation-summary/v1",
3091
+ "result_version:evidence-result-v0"
3092
+ ],
3093
+ "extensions": [
3094
+ "x-deal-v0",
3095
+ "x-history-selection/v0"
3096
+ ]
3097
+ },
3098
+ "audiences": [
3099
+ "keep",
3100
+ "counterparty",
3101
+ "adjudicator",
3102
+ "*"
3103
+ ],
3104
+ "formats": [
3105
+ "html"
3106
+ ],
3107
+ "fallback": false,
3108
+ "priority": 1,
3109
+ "executable": {
3110
+ "carrier": "module-slot",
3111
+ "script_sha256": "7796931b7f70c815122e6730e8d0485c23f2f4317d4f3535944c36898169fab3",
3112
+ "style_sha256": [
3113
+ "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3114
+ ]
3115
+ }
3116
+ },
3117
+ "deal": {
3118
+ "spec_version": "aac.presentation-manifest/v0",
3119
+ "id": "capsuleviewer.receipt.deal/v1",
3120
+ "presentation_api": "aac.presentation-api/v0",
3121
+ "runtime_min": "0.1.0",
3122
+ "trust_class": "trusted-executable",
3123
+ "requires": {
3124
+ "bundle_kind": "evidence-bundle/v2",
3125
+ "extensions": {
3126
+ "required": [
3127
+ "x-deal-v1"
3128
+ ]
3129
+ }
3130
+ },
3131
+ "forbids": {
3132
+ "profiles": [
3133
+ "spec_version:report/v1",
3134
+ "spec_version:evaluation-summary/v1",
3135
+ "result_version:evidence-result-v0"
3136
+ ],
3137
+ "extensions": [
3138
+ "composed/v1",
3139
+ "x-history-selection/v0",
3140
+ "x-deal-seller/v0",
3141
+ "x-deal-v0"
3142
+ ]
3143
+ },
3144
+ "audiences": [
3145
+ "keep",
3146
+ "counterparty",
3147
+ "adjudicator",
3148
+ "*"
3149
+ ],
3150
+ "formats": [
3151
+ "html"
3152
+ ],
3153
+ "fallback": false,
3154
+ "priority": 1,
3155
+ "executable": {
3156
+ "carrier": "module-slot",
3157
+ "script_sha256": "23ce57896898ce207d379cd37d1b46cc5b0fa9c2b3e252fa76513a815ce24905",
3158
+ "style_sha256": [
3159
+ "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3160
+ ]
3161
+ }
3162
+ }
3163
+ };
3164
+ //# sourceMappingURL=receipt-core.generated.js.map