@player-ui/reference-assets-plugin 0.15.4-next.0 → 0.16.0--canary.866.36538

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.
@@ -1605,6 +1605,412 @@ var ReferenceAssetsPlugin = function() {
1605
1605
  });
1606
1606
  return batchTxn;
1607
1607
  };
1608
+ var pointerToBinding = function pointerToBinding(pointer) {
1609
+ if (!pointer || pointer === "/") return "";
1610
+ var absolute = pointer.startsWith("/");
1611
+ var raw = absolute ? pointer.slice(1) : pointer;
1612
+ var segments = raw.split("/").map(decodeSegment);
1613
+ var out = "";
1614
+ for(var i = 0; i < segments.length; i++){
1615
+ var seg = segments[i];
1616
+ if (NUMERIC_SEGMENT.test(seg)) {
1617
+ out += "[".concat(seg, "]");
1618
+ } else {
1619
+ out += i === 0 ? seg : ".".concat(seg);
1620
+ }
1621
+ }
1622
+ return out;
1623
+ };
1624
+ var bindingToSegments = function bindingToSegments(binding) {
1625
+ if (!binding) return [];
1626
+ var segments = [];
1627
+ var parts = binding.split(".");
1628
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1629
+ try {
1630
+ for(var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1631
+ var part = _step.value;
1632
+ var match = part.match(/^([^[]+)((?:\[\d+\])*)$/);
1633
+ if (!match) {
1634
+ segments.push(part);
1635
+ continue;
1636
+ }
1637
+ var _match = _sliced_to_array(match, 3), name = _match[1], arrays = _match[2];
1638
+ if (name) segments.push(name);
1639
+ if (arrays) {
1640
+ var _segments;
1641
+ var _arrays_match;
1642
+ var arrayMatches = (_arrays_match = arrays.match(/\[\d+\]/g)) !== null && _arrays_match !== void 0 ? _arrays_match : [];
1643
+ (_segments = segments).push.apply(_segments, _to_consumable_array(arrayMatches));
1644
+ }
1645
+ }
1646
+ } catch (err) {
1647
+ _didIteratorError = true;
1648
+ _iteratorError = err;
1649
+ } finally{
1650
+ try {
1651
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1652
+ _iterator.return();
1653
+ }
1654
+ } finally{
1655
+ if (_didIteratorError) {
1656
+ throw _iteratorError;
1657
+ }
1658
+ }
1659
+ }
1660
+ return segments;
1661
+ };
1662
+ var interpolatePointers = function interpolatePointers(input) {
1663
+ return input.replace(/\$\{([^}]+)\}/g, function(_, pointer) {
1664
+ return "{{".concat(pointerToBinding(pointer), "}}");
1665
+ });
1666
+ };
1667
+ var translateFunctionCall = function translateFunctionCall(call, logger) {
1668
+ if (call.call === "formatString") {
1669
+ var _call_args;
1670
+ var value = (_call_args = call.args) === null || _call_args === void 0 ? void 0 : _call_args.value;
1671
+ if (typeof value === "string") return interpolatePointers(value);
1672
+ logger === null || logger === void 0 ? void 0 : logger.warn("[a2ui] formatString received non-string 'value' arg; emitting expression form");
1673
+ }
1674
+ var argList = renderArgList(call.args);
1675
+ if (call.call === "formatString") {
1676
+ return "@[formatString(".concat(argList, ")]@");
1677
+ }
1678
+ return "@[".concat(call.call, "(").concat(argList, ")]@");
1679
+ };
1680
+ var renderArgList = function renderArgList(args) {
1681
+ if (!args) return "";
1682
+ return Object.values(args).map(renderArg).join(", ");
1683
+ };
1684
+ var newBuilder = function newBuilder() {
1685
+ return {
1686
+ schema: {
1687
+ ROOT: {}
1688
+ },
1689
+ knownTypes: /* @__PURE__ */ new Set([
1690
+ "ROOT"
1691
+ ])
1692
+ };
1693
+ };
1694
+ var findBoundPath = function findBoundPath(component, logger) {
1695
+ var lookupProp = INPUT_BINDING_PROPS[component.component];
1696
+ if (lookupProp) {
1697
+ var prop = component[lookupProp];
1698
+ if (isPathRef(prop)) return prop.path;
1699
+ }
1700
+ var pathRefs = collectPathRefs(component);
1701
+ if (pathRefs.length === 1) return pathRefs[0];
1702
+ if (pathRefs.length > 1) {
1703
+ logger === null || logger === void 0 ? void 0 : logger.warn("[a2ui] Component '".concat(component.id, "' (").concat(component.component, ") has checks but multiple {path} refs; skipping schema synthesis for this component"));
1704
+ } else {
1705
+ logger === null || logger === void 0 ? void 0 : logger.warn("[a2ui] Component '".concat(component.id, "' (").concat(component.component, ") has checks but no bound path could be determined; skipping"));
1706
+ }
1707
+ return void 0;
1708
+ };
1709
+ var collectPathRefs = function collectPathRefs(component) {
1710
+ var found = [];
1711
+ var walk = function walk1(v) {
1712
+ if (!v || (typeof v === "undefined" ? "undefined" : _type_of(v)) !== "object") return;
1713
+ if (Array.isArray(v)) {
1714
+ v.forEach(walk);
1715
+ return;
1716
+ }
1717
+ if (isPathRef(v)) {
1718
+ found.push(v.path);
1719
+ return;
1720
+ }
1721
+ Object.values(v).forEach(walk);
1722
+ };
1723
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1724
+ try {
1725
+ for(var _iterator = Object.entries(component)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1726
+ var _step_value = _sliced_to_array(_step.value, 2), k = _step_value[0], v = _step_value[1];
1727
+ if (k === "id" || k === "component" || k === "checks" || k === "action") {
1728
+ continue;
1729
+ }
1730
+ walk(v);
1731
+ }
1732
+ } catch (err) {
1733
+ _didIteratorError = true;
1734
+ _iteratorError = err;
1735
+ } finally{
1736
+ try {
1737
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1738
+ _iterator.return();
1739
+ }
1740
+ } finally{
1741
+ if (_didIteratorError) {
1742
+ throw _iteratorError;
1743
+ }
1744
+ }
1745
+ }
1746
+ return found;
1747
+ };
1748
+ var translateCheck = function translateCheck(check, logger) {
1749
+ var _check_args;
1750
+ var type = CHECK_TO_VALIDATOR[check.call];
1751
+ if (!type) {
1752
+ logger === null || logger === void 0 ? void 0 : logger.warn("[a2ui] Unknown validation check '".concat(check.call, "'; dropping"));
1753
+ return void 0;
1754
+ }
1755
+ var ref = {
1756
+ type: type,
1757
+ severity: "error"
1758
+ };
1759
+ if (check.message) ref.message = check.message;
1760
+ if (check.call === "regex" && ((_check_args = check.args) === null || _check_args === void 0 ? void 0 : _check_args.pattern)) {
1761
+ ref.regex = unwrapLiteral(check.args.pattern);
1762
+ }
1763
+ if (check.call === "length") {
1764
+ var _check_args1, _check_args2;
1765
+ if (((_check_args1 = check.args) === null || _check_args1 === void 0 ? void 0 : _check_args1.min) !== void 0) ref.min = unwrapLiteral(check.args.min);
1766
+ if (((_check_args2 = check.args) === null || _check_args2 === void 0 ? void 0 : _check_args2.max) !== void 0) ref.max = unwrapLiteral(check.args.max);
1767
+ }
1768
+ return ref;
1769
+ };
1770
+ var unwrapLiteral = function unwrapLiteral(value) {
1771
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null) {
1772
+ return value;
1773
+ }
1774
+ return value;
1775
+ };
1776
+ var installAtPath = function installAtPath(builder, binding, leafType, validations, logger) {
1777
+ var segments = bindingToSegments(binding).filter(function(s) {
1778
+ return !s.startsWith("[");
1779
+ });
1780
+ if (segments.length === 0) {
1781
+ logger === null || logger === void 0 ? void 0 : logger.warn("[a2ui] Cannot install schema validation at empty path; skipping");
1782
+ return;
1783
+ }
1784
+ var currentNode = builder.schema.ROOT;
1785
+ var ownerPath = [];
1786
+ for(var i = 0; i < segments.length - 1; i++){
1787
+ var seg = segments[i];
1788
+ ownerPath.push(seg);
1789
+ var typeName = "".concat(TYPE_PREFIX).concat(ownerPath.join("_"));
1790
+ var existing = currentNode[seg];
1791
+ if (!existing) {
1792
+ currentNode[seg] = {
1793
+ type: typeName
1794
+ };
1795
+ } else if (existing.type !== typeName) {}
1796
+ var ref = currentNode[seg].type;
1797
+ if (!builder.schema[ref]) {
1798
+ builder.schema[ref] = {};
1799
+ builder.knownTypes.add(ref);
1800
+ }
1801
+ currentNode = builder.schema[ref];
1802
+ }
1803
+ var leafSeg = segments[segments.length - 1];
1804
+ var existingLeaf = currentNode[leafSeg];
1805
+ if (existingLeaf) {
1806
+ var _existingLeaf_validation;
1807
+ var merged = _object_spread_props(_object_spread({}, existingLeaf), {
1808
+ type: pickLeafType(existingLeaf.type, leafType),
1809
+ validation: _to_consumable_array((_existingLeaf_validation = existingLeaf.validation) !== null && _existingLeaf_validation !== void 0 ? _existingLeaf_validation : []).concat(_to_consumable_array(validations))
1810
+ });
1811
+ currentNode[leafSeg] = merged;
1812
+ } else {
1813
+ currentNode[leafSeg] = {
1814
+ type: leafType,
1815
+ validation: validations
1816
+ };
1817
+ }
1818
+ };
1819
+ var pickLeafType = function pickLeafType(existing, incoming) {
1820
+ if (incoming !== "string") return incoming;
1821
+ return existing;
1822
+ };
1823
+ var defaultLeafType = function defaultLeafType(component, checks) {
1824
+ if (component.component === "CheckBox") return "boolean";
1825
+ if (checks.some(function(c) {
1826
+ return c.call === "numeric";
1827
+ })) return "number";
1828
+ return "string";
1829
+ };
1830
+ var synthesizeSchema = function synthesizeSchema(components, logger) {
1831
+ var builder = newBuilder();
1832
+ var found = false;
1833
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1834
+ try {
1835
+ for(var _iterator = components[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1836
+ var component = _step.value;
1837
+ if (!component.checks || component.checks.length === 0) continue;
1838
+ var pointer = findBoundPath(component, logger);
1839
+ if (!pointer) continue;
1840
+ var binding = pointerToBinding(pointer);
1841
+ if (!binding) continue;
1842
+ var validations = component.checks.map(function(c) {
1843
+ return translateCheck(c, logger);
1844
+ }).filter(function(v) {
1845
+ return v !== void 0;
1846
+ });
1847
+ if (validations.length === 0) continue;
1848
+ installAtPath(builder, binding, defaultLeafType(component, component.checks), validations, logger);
1849
+ found = true;
1850
+ }
1851
+ } catch (err) {
1852
+ _didIteratorError = true;
1853
+ _iteratorError = err;
1854
+ } finally{
1855
+ try {
1856
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1857
+ _iterator.return();
1858
+ }
1859
+ } finally{
1860
+ if (_didIteratorError) {
1861
+ throw _iteratorError;
1862
+ }
1863
+ }
1864
+ }
1865
+ return found ? builder.schema : void 0;
1866
+ };
1867
+ var resolveAndInline = function resolveAndInline(id, ctx, templateScope) {
1868
+ var component = ctx.byId.get(id);
1869
+ if (!component) {
1870
+ throw new Error("[a2ui] Component reference '".concat(id, "' could not be resolved in the snapshot."));
1871
+ }
1872
+ return inlineComponent(component, ctx, templateScope);
1873
+ };
1874
+ var wrapInlined = function wrapInlined(asset) {
1875
+ return {
1876
+ asset: asset
1877
+ };
1878
+ };
1879
+ var scopedBinding = function scopedBinding(pointer, scope) {
1880
+ if (!pointer || pointer === "/") return scope !== null && scope !== void 0 ? scope : "";
1881
+ if (pointer.startsWith("/")) return pointerToBinding(pointer);
1882
+ if (!scope) return pointerToBinding(pointer);
1883
+ var relative = pointerToBinding(pointer);
1884
+ return relative ? "".concat(scope, "._index_.").concat(relative) : "".concat(scope, "._index_");
1885
+ };
1886
+ var scopedPointer = function scopedPointer(pointer, scope) {
1887
+ if (pointer.startsWith("/")) return pointer;
1888
+ return "/".concat(scope, "/_index_/").concat(pointer);
1889
+ };
1890
+ var translateAction = function translateAction(action, ctx) {
1891
+ if ("event" in action) {
1892
+ var _action_event = action.event, name = _action_event.name, context = _action_event.context;
1893
+ ctx.eventNames.add(name);
1894
+ var result = {
1895
+ value: name
1896
+ };
1897
+ if (context && Object.keys(context).length > 0) {
1898
+ result.exp = buildContextWriteExpressions(context);
1899
+ }
1900
+ return result;
1901
+ }
1902
+ return {
1903
+ exp: translateFunctionCall(action.functionCall, ctx.logger)
1904
+ };
1905
+ };
1906
+ var buildContextWriteExpressions = function buildContextWriteExpressions(context) {
1907
+ return Object.entries(context).map(function(param) {
1908
+ var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
1909
+ var lhs = "{{".concat(A2UI_EVENT_CONTEXT_NAMESPACE, ".").concat(key, "}}");
1910
+ return "".concat(lhs, " = ").concat(renderRhs(value));
1911
+ });
1912
+ };
1913
+ var buildNavigation = function buildNavigation(surfaceId, eventNames) {
1914
+ var view = {
1915
+ state_type: "VIEW",
1916
+ ref: surfaceId,
1917
+ transitions: {
1918
+ "*": "END_Done"
1919
+ }
1920
+ };
1921
+ var endStates = {
1922
+ END_Done: {
1923
+ state_type: "END",
1924
+ outcome: "done"
1925
+ }
1926
+ };
1927
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1928
+ try {
1929
+ for(var _iterator = eventNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1930
+ var name = _step.value;
1931
+ var endName = "END_".concat(name);
1932
+ view.transitions[name] = endName;
1933
+ endStates[endName] = {
1934
+ state_type: "END",
1935
+ outcome: name
1936
+ };
1937
+ }
1938
+ } catch (err) {
1939
+ _didIteratorError = true;
1940
+ _iteratorError = err;
1941
+ } finally{
1942
+ try {
1943
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1944
+ _iterator.return();
1945
+ }
1946
+ } finally{
1947
+ if (_didIteratorError) {
1948
+ throw _iteratorError;
1949
+ }
1950
+ }
1951
+ }
1952
+ var flow = _object_spread({
1953
+ startState: "VIEW_1",
1954
+ VIEW_1: view
1955
+ }, endStates);
1956
+ return {
1957
+ BEGIN: "FLOW_1",
1958
+ FLOW_1: flow
1959
+ };
1960
+ };
1961
+ var adaptA2UIToFlow = function adaptA2UIToFlow(snapshot, logger) {
1962
+ var _snapshot_data;
1963
+ if (!snapshot || !Array.isArray(snapshot.components)) {
1964
+ throw new Error("[a2ui] snapshot.components must be an array");
1965
+ }
1966
+ var byId = /* @__PURE__ */ new Map();
1967
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1968
+ try {
1969
+ for(var _iterator = snapshot.components[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1970
+ var component = _step.value;
1971
+ if (!(component === null || component === void 0 ? void 0 : component.id)) {
1972
+ throw new Error("[a2ui] every component must have an id");
1973
+ }
1974
+ byId.set(component.id, component);
1975
+ }
1976
+ } catch (err) {
1977
+ _didIteratorError = true;
1978
+ _iteratorError = err;
1979
+ } finally{
1980
+ try {
1981
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1982
+ _iterator.return();
1983
+ }
1984
+ } finally{
1985
+ if (_didIteratorError) {
1986
+ throw _iteratorError;
1987
+ }
1988
+ }
1989
+ }
1990
+ var root = byId.get("root");
1991
+ if (!root) {
1992
+ throw new Error("[a2ui] snapshot must contain a component with id 'root'");
1993
+ }
1994
+ var ctx = {
1995
+ byId: byId,
1996
+ inProgress: /* @__PURE__ */ new Set(),
1997
+ eventNames: /* @__PURE__ */ new Set(),
1998
+ logger: logger
1999
+ };
2000
+ var rootAsset = inlineComponent(root, ctx);
2001
+ rootAsset.id = snapshot.surfaceId;
2002
+ var schema = synthesizeSchema(snapshot.components, logger);
2003
+ var flow = {
2004
+ id: snapshot.surfaceId,
2005
+ views: [
2006
+ rootAsset
2007
+ ],
2008
+ data: (_snapshot_data = snapshot.data) !== null && _snapshot_data !== void 0 ? _snapshot_data : {},
2009
+ navigation: buildNavigation(snapshot.surfaceId, ctx.eventNames)
2010
+ };
2011
+ if (schema) flow.schema = schema;
2012
+ return flow;
2013
+ };
1608
2014
  var __create = Object.create;
1609
2015
  var __defProp = Object.defineProperty;
1610
2016
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1905,7 +2311,7 @@ var ReferenceAssetsPlugin = function() {
1905
2311
  }
1906
2312
  return out;
1907
2313
  }
1908
- function isObject(o) {
2314
+ function isObject2(o) {
1909
2315
  return o != null && (typeof o === "undefined" ? "undefined" : _type_of(o)) === "object";
1910
2316
  }
1911
2317
  function addLast2(array, val) {
@@ -1978,7 +2384,7 @@ var ReferenceAssetsPlugin = function() {
1978
2384
  if (idx === path.length - 1) {
1979
2385
  newValue = val;
1980
2386
  } else {
1981
- var nestedObj = isObject(obj) && isObject(obj[key]) ? obj[key] : typeof path[idx + 1] === "number" ? [] : {};
2387
+ var nestedObj = isObject2(obj) && isObject2(obj[key]) ? obj[key] : typeof path[idx + 1] === "number" ? [] : {};
1982
2388
  newValue = doSetIn(nestedObj, path, val, idx + 1);
1983
2389
  }
1984
2390
  return set2(obj, key, newValue);
@@ -2108,7 +2514,7 @@ var ReferenceAssetsPlugin = function() {
2108
2514
  var key = keys[j];
2109
2515
  if (fAddDefaults && out[key] !== void 0) continue;
2110
2516
  var nextVal = obj[key];
2111
- if (fDeep && isObject(out[key]) && isObject(nextVal)) {
2517
+ if (fDeep && isObject2(out[key]) && isObject2(nextVal)) {
2112
2518
  nextVal = doMerge(fAddDefaults, fDeep, out[key], nextVal);
2113
2519
  }
2114
2520
  if (nextVal === void 0 || nextVal === out[key]) continue;
@@ -7909,8 +8315,234 @@ var ReferenceAssetsPlugin = function() {
7909
8315
  ref: Symbol("not-started"),
7910
8316
  status: "not-started"
7911
8317
  };
7912
- var PLAYER_VERSION = true ? "0.15.4-next.0" : "unknown";
7913
- var COMMIT = true ? "23a98a4b8e5d2c8078103ef189e9167a0d96823d" : "unknown";
8318
+ var A2UI_EVENT_CONTEXT_NAMESPACE = "agent.event.context";
8319
+ var NUMERIC_SEGMENT = /^(0|[1-9]\d*)$/;
8320
+ var decodeSegment = function decodeSegment(segment) {
8321
+ return segment.replace(/~1/g, "/").replace(/~0/g, "~");
8322
+ };
8323
+ var isObject = function isObject(v) {
8324
+ return (typeof v === "undefined" ? "undefined" : _type_of(v)) === "object" && v !== null && !Array.isArray(v);
8325
+ };
8326
+ var isPathRef = function isPathRef(v) {
8327
+ return isObject(v) && typeof v.path === "string" && Object.keys(v).length === 1;
8328
+ };
8329
+ var isFunctionCall = function isFunctionCall(v) {
8330
+ return isObject(v) && typeof v.call === "string";
8331
+ };
8332
+ function renderArg(value) {
8333
+ if (value === null) return "null";
8334
+ if (value === void 0) return "null";
8335
+ if (typeof value === "boolean") return String(value);
8336
+ if (typeof value === "number") return String(value);
8337
+ if (typeof value === "string") return JSON.stringify(value);
8338
+ if (Array.isArray(value)) {
8339
+ return "[".concat(value.map(renderArg).join(", "), "]");
8340
+ }
8341
+ if (isPathRef(value)) {
8342
+ return "{{".concat(pointerToBinding(value.path), "}}");
8343
+ }
8344
+ if (isFunctionCall(value)) {
8345
+ var inner = translateFunctionCall(value);
8346
+ return inner.replace(/^@\[/, "").replace(/\]@$/, "");
8347
+ }
8348
+ return JSON.stringify(value);
8349
+ }
8350
+ var INPUT_BINDING_PROPS = {
8351
+ TextField: "text",
8352
+ CheckBox: "checked",
8353
+ DateTimeInput: "value",
8354
+ ChoicePicker: "value",
8355
+ Slider: "value"
8356
+ };
8357
+ var CHECK_TO_VALIDATOR = {
8358
+ required: "required",
8359
+ regex: "regex",
8360
+ email: "email",
8361
+ length: "length",
8362
+ numeric: "numeric"
8363
+ };
8364
+ var TYPE_PREFIX = "T_";
8365
+ var STRUCTURAL_KEYS = /* @__PURE__ */ new Set([
8366
+ "id",
8367
+ "component",
8368
+ "child",
8369
+ "children",
8370
+ "checks",
8371
+ "action"
8372
+ ]);
8373
+ function inlineComponent(component, ctx, templateScope) {
8374
+ if (ctx.inProgress.has(component.id)) {
8375
+ throw new Error("[a2ui] Component cycle detected at id '".concat(component.id, "'. A2UI requires the component graph to be a tree."));
8376
+ }
8377
+ ctx.inProgress.add(component.id);
8378
+ var asset = {
8379
+ id: component.id,
8380
+ type: component.component
8381
+ };
8382
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8383
+ try {
8384
+ for(var _iterator = Object.entries(component)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8385
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
8386
+ if (STRUCTURAL_KEYS.has(key)) continue;
8387
+ asset[key] = translatePropValue(value, templateScope, ctx, key);
8388
+ }
8389
+ } catch (err) {
8390
+ _didIteratorError = true;
8391
+ _iteratorError = err;
8392
+ } finally{
8393
+ try {
8394
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
8395
+ _iterator.return();
8396
+ }
8397
+ } finally{
8398
+ if (_didIteratorError) {
8399
+ throw _iteratorError;
8400
+ }
8401
+ }
8402
+ }
8403
+ if (typeof component.child === "string") {
8404
+ var childId = component.child;
8405
+ asset.child = wrapInlined(resolveAndInline(childId, ctx, templateScope));
8406
+ }
8407
+ if (component.children) {
8408
+ if (Array.isArray(component.children)) {
8409
+ asset.children = component.children.map(function(id) {
8410
+ return wrapInlined(resolveAndInline(id, ctx, templateScope));
8411
+ });
8412
+ } else {
8413
+ var _component_children = component.children, path = _component_children.path, componentId = _component_children.componentId;
8414
+ var data = scopedBinding(path, templateScope);
8415
+ var templateComponent = ctx.byId.get(componentId);
8416
+ if (!templateComponent) {
8417
+ throw new Error("[a2ui] Templated children reference unknown componentId '".concat(componentId, "' on component '").concat(component.id, "'."));
8418
+ }
8419
+ var templated = inlineComponent(_object_spread_props(_object_spread({}, templateComponent), {
8420
+ id: "".concat(templateComponent.id, "-_index_")
8421
+ }), ctx, data);
8422
+ asset.template = [
8423
+ {
8424
+ data: data,
8425
+ output: "children",
8426
+ value: {
8427
+ asset: templated
8428
+ }
8429
+ }
8430
+ ];
8431
+ }
8432
+ }
8433
+ if (component.action) {
8434
+ Object.assign(asset, translateAction(component.action, ctx));
8435
+ }
8436
+ ctx.inProgress.delete(component.id);
8437
+ return asset;
8438
+ }
8439
+ var CHILD_KEY_RE = /(?:^|[a-z])Child$|^child$/;
8440
+ var CHILDREN_KEY_RE = /(?:^|[a-z])Children$|^children$/;
8441
+ function translatePropValue(value, templateScope, ctx, parentKey) {
8442
+ if (value === null || value === void 0) return value;
8443
+ if (parentKey && CHILD_KEY_RE.test(parentKey) && typeof value === "string") {
8444
+ return wrapInlined(resolveAndInline(value, ctx, templateScope));
8445
+ }
8446
+ if (parentKey && CHILDREN_KEY_RE.test(parentKey)) {
8447
+ if (Array.isArray(value) && value.every(function(v) {
8448
+ return typeof v === "string";
8449
+ })) {
8450
+ return value.map(function(id) {
8451
+ return wrapInlined(resolveAndInline(id, ctx, templateScope));
8452
+ });
8453
+ }
8454
+ if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value !== null && !Array.isArray(value) && "componentId" in value) {
8455
+ var _ctx_logger;
8456
+ (_ctx_logger = ctx.logger) === null || _ctx_logger === void 0 ? void 0 : _ctx_logger.warn("[a2ui] Templated children are only supported at top-level 'children'; '".concat(parentKey, "' will be left unresolved."));
8457
+ }
8458
+ }
8459
+ if ((typeof value === "undefined" ? "undefined" : _type_of(value)) !== "object") return value;
8460
+ if (Array.isArray(value)) {
8461
+ return value.map(function(v) {
8462
+ return translatePropValue(v, templateScope, ctx, void 0);
8463
+ });
8464
+ }
8465
+ if (isPathRef(value)) {
8466
+ return scopedBinding(value.path, templateScope);
8467
+ }
8468
+ if (isFunctionCall(value)) {
8469
+ if (templateScope) {
8470
+ return translateFunctionCall(rewritePathsInCall(value, templateScope), ctx.logger);
8471
+ }
8472
+ return translateFunctionCall(value, ctx.logger);
8473
+ }
8474
+ var out = {};
8475
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8476
+ try {
8477
+ for(var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8478
+ var _step_value = _sliced_to_array(_step.value, 2), k = _step_value[0], v = _step_value[1];
8479
+ out[k] = translatePropValue(v, templateScope, ctx, k);
8480
+ }
8481
+ } catch (err) {
8482
+ _didIteratorError = true;
8483
+ _iteratorError = err;
8484
+ } finally{
8485
+ try {
8486
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
8487
+ _iterator.return();
8488
+ }
8489
+ } finally{
8490
+ if (_didIteratorError) {
8491
+ throw _iteratorError;
8492
+ }
8493
+ }
8494
+ }
8495
+ return out;
8496
+ }
8497
+ function rewritePathsInCall(value, scope) {
8498
+ if (!value || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== "object") return value;
8499
+ if (Array.isArray(value)) {
8500
+ return value.map(function(v) {
8501
+ return rewritePathsInCall(v, scope);
8502
+ });
8503
+ }
8504
+ if (isPathRef(value)) {
8505
+ return {
8506
+ path: scopedPointer(value.path, scope)
8507
+ };
8508
+ }
8509
+ if (isFunctionCall(value)) {
8510
+ return _object_spread_props(_object_spread({}, value), {
8511
+ args: value.args ? Object.fromEntries(Object.entries(value.args).map(function(param) {
8512
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
8513
+ return [
8514
+ k,
8515
+ rewritePathsInCall(v, scope)
8516
+ ];
8517
+ })) : value.args
8518
+ });
8519
+ }
8520
+ return Object.fromEntries(Object.entries(value).map(function(param) {
8521
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
8522
+ return [
8523
+ k,
8524
+ rewritePathsInCall(v, scope)
8525
+ ];
8526
+ }));
8527
+ }
8528
+ function renderRhs(value) {
8529
+ if (value === null || value === void 0) return "null";
8530
+ if (typeof value === "boolean") return String(value);
8531
+ if (typeof value === "number") return String(value);
8532
+ if (typeof value === "string") return JSON.stringify(value);
8533
+ if (Array.isArray(value)) {
8534
+ return "[".concat(value.map(renderRhs).join(", "), "]");
8535
+ }
8536
+ if (isPathRef(value)) {
8537
+ return "{{".concat(pointerToBinding(value.path), "}}");
8538
+ }
8539
+ if (isFunctionCall(value)) {
8540
+ return translateFunctionCall(value).replace(/^@\[/, "").replace(/\]@$/, "");
8541
+ }
8542
+ return JSON.stringify(value);
8543
+ }
8544
+ var PLAYER_VERSION = true ? "0.16.0--canary.866.36538" : "unknown";
8545
+ var COMMIT = true ? "0186f1bd04fda238cbc62b8d293c8048ab26efc2" : "unknown";
7914
8546
  var _Player = /*#__PURE__*/ function() {
7915
8547
  function _Player2(config) {
7916
8548
  var _this = this;
@@ -8238,14 +8870,15 @@ var ReferenceAssetsPlugin = function() {
8238
8870
  },
8239
8871
  {
8240
8872
  key: "start",
8241
- value: function start(payload) {
8873
+ value: function start(payload, options) {
8242
8874
  return _async_to_generator(function() {
8243
- var _this, _ref, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
8875
+ var _this, _ref, flow, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
8244
8876
  return _ts_generator(this, function(_state) {
8245
8877
  switch(_state.label){
8246
8878
  case 0:
8247
8879
  _this = this;
8248
- ref = Symbol((_ref = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _ref !== void 0 ? _ref : "payload");
8880
+ flow = (options === null || options === void 0 ? void 0 : options.format) === "a2ui" ? adaptA2UIToFlow(payload, this.logger) : payload;
8881
+ ref = Symbol((_ref = flow === null || flow === void 0 ? void 0 : flow.id) !== null && _ref !== void 0 ? _ref : "payload");
8249
8882
  maybeUpdateState = function maybeUpdateState(newState) {
8250
8883
  if (_this.state.ref !== ref) {
8251
8884
  _this.logger.warn("Received update for a flow that's not the current one");
@@ -8266,7 +8899,7 @@ var ReferenceAssetsPlugin = function() {
8266
8899
  ,
8267
8900
  4
8268
8901
  ]);
8269
- _this_setupFlow = this.setupFlow(payload), state = _this_setupFlow.state, start = _this_setupFlow.start;
8902
+ _this_setupFlow = this.setupFlow(flow), state = _this_setupFlow.state, start = _this_setupFlow.start;
8270
8903
  this.setState(_object_spread({
8271
8904
  ref: ref
8272
8905
  }, state));
@@ -8301,7 +8934,7 @@ var ReferenceAssetsPlugin = function() {
8301
8934
  errorState = {
8302
8935
  status: "error",
8303
8936
  ref: ref,
8304
- flow: payload,
8937
+ flow: flow,
8305
8938
  error: error
8306
8939
  };
8307
8940
  maybeUpdateState(errorState);