is prototype: true
terms:
  metadata:
    category: brane
    name: Unnamed brane
    previews:
      - small:
          - file: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/64px-No-Image-Placeholder.svg.png"
            format: PNG
      - large:
          - file: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/512px-No-Image-Placeholder.svg.png"
            format: PNG
    tags: ["brane"]
  owner: null
  allowed prototypes: {}
  children: {}
  settings: {}

clauses:
  create child:
    $do:
      - $if:
          condition:
            $is not defined:
              $get:
                term:
                  - "allowed prototypes"
                  - $subject item: "type"
          is met then:
            $revert:
              error: "no such prototype"
      - $set:
          local term: ["created child"]
          to value:
            $create pactum:
              prototype:
                $get:
                  term:
                    - "allowed prototypes"
                    - $subject item: "type"
              terms:
                $subject item: "props"
      - $set:
          term:
            - "children"
            - $get:
                local term: ["created child"]
          to value: true
      - $get:
          local term: [ "created child" ]

  get object:
    $get:
      term: []

  add allowed prototype:
    $if:
      condition:
        $are equal:
          - $sender
          - $get:
              term: ["owner"]
      is met then:
        $set:
          term:
            - "allowed prototypes"
            - $subject item: "type"
          to value:
            $subject item: "prototype"
      else:
        $revert:
          error: "only brane owner can append allowed prototype"

  update settings: 
    $set:
      term: ["settings"]
      to value: $subject

publish:
    $set:
      term: ["owner"]
      to value: $sender
