<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<contentHaul xmlns:a="http://www.appian.com/ae/types/2009">
    <rule>
        <name>${expRule_removeInactiveValues_name}</name>
        <uuid>${expRule_removeInactiveValues_uuid}</uuid>
        <description>${expRule_removeInactiveValues_desc}</description>
        <parentUuid>${_a-0000dc10-002c-8000-9b0c-01ef9001ef90_2789}</parentUuid>
        <visibility>
            <advertise>false</advertise>
            <hierarchy>true</hierarchy>
            <indexable>true</indexable>
            <quota>false</quota>
            <searchable>true</searchable>
            <system>false</system>
            <unlogged>false</unlogged>
        </visibility>
        <definition>a!localVariables(
  /* All local variables used here are lists of indices for options */
  local!selections: wherecontains(ri!selections, ri!options.id),
  /* These are the inactive options to keep, because this record  *
     * record has them stored and so they should be displayed.      */
  local!inactiveSelections: intersection(
    local!selections,
    /* All the inactive options to remove by default                */
    where(not(ri!options.active), {})
  ),
  local!activeOptions: where(ri!options.active, null),
  /* Find the values of all unselected, active options that have    *
   * the same values as a selected, inactive option.                */
  local!activeOptionsToRemove: if(
    or(isnull(local!inactiveSelections), length(local!inactiveSelections) = 0),
    {},
    intersection(
      /* Find the values of the unselected, active options          */
      difference(local!activeOptions, local!selections),
      /* Find the values of the selected, inactive options          */
      wherecontains(
        index(ri!options.value,local!inactiveSelections),
        ri!options.value
      )
    )
  ),
  local!optionIndices: if(
    or(isnull(local!activeOptionsToRemove), length(local!activeOptionsToRemove) = 0),
    union(local!selections, local!activeOptions),
    union(
      local!selections,
      difference(
        local!activeOptions,
        local!activeOptionsToRemove
      )
    )
  ),
  /* If there are no selections, just show the active values.       *
   * Otherwise, show all selected and active values, minus any      *
   * active unselected values that duplicate selected values.       */
  if(
    or(isnull(ri!selections), length(ri!selections) = 0),
    index(ri!options, local!activeOptions, {}),
    difference(ri!options, remove(ri!options, local!optionIndices))
  )
)</definition>
        <namedTypedValue>
            <name>options</name>
            <type>
                <name>Variant</name>
                <namespace>http://www.appian.com/ae/types/2009</namespace>
            </type>
        </namedTypedValue>
        <namedTypedValue>
            <name>selections</name>
            <type>
                <name>Integer?list</name>
                <namespace>http://www.appian.com/ae/types/2009</namespace>
            </type>
        </namedTypedValue>
        <preferredEditor>legacy</preferredEditor>
        <offlineEnabled>false</offlineEnabled>
    </rule>
    <roleMap public="true">
        <role allowForAll="false" inherit="true" name="readers">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="true" name="authors">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="true" name="administrators">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="false" name="denyReaders">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="false" name="denyAuthors">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="false" name="denyAdministrators">
            <users/>
            <groups/>
        </role>
    </roleMap>
</contentHaul>
