qureal-editor 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.es.js +7 -22
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +7 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -6,21 +6,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
6
6
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
var defineProperty = function (obj, key, value) {
|
|
10
|
-
if (key in obj) {
|
|
11
|
-
Object.defineProperty(obj, key, {
|
|
12
|
-
value: value,
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true
|
|
16
|
-
});
|
|
17
|
-
} else {
|
|
18
|
-
obj[key] = value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return obj;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
9
|
var _extends = Object.assign || function (target) {
|
|
25
10
|
for (var i = 1; i < arguments.length; i++) {
|
|
26
11
|
var source = arguments[i];
|
|
@@ -36,8 +21,6 @@ var _extends = Object.assign || function (target) {
|
|
|
36
21
|
};
|
|
37
22
|
|
|
38
23
|
function QurealiFrame(_ref) {
|
|
39
|
-
var _React$createElement;
|
|
40
|
-
|
|
41
24
|
var slug = _ref.slug,
|
|
42
25
|
preview = _ref.preview,
|
|
43
26
|
query = _ref.query,
|
|
@@ -50,15 +33,17 @@ function QurealiFrame(_ref) {
|
|
|
50
33
|
return React.createElement(
|
|
51
34
|
Fragment,
|
|
52
35
|
null,
|
|
53
|
-
React.createElement("iframe",
|
|
36
|
+
React.createElement("iframe", {
|
|
54
37
|
id: "qureal_iframe",
|
|
55
38
|
title: "Qureal"
|
|
56
39
|
// src={`http://localhost:3201/embed/${creation_slug}`}
|
|
57
40
|
, src: type === "creation" ? "https://show.qureal.com/embed/" + slug + "?" + (preview ? "preview&" : "") + query : "https://show.qureal.com/ts/" + slug
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
41
|
+
// src={type === "creation" ? `http://localhost:3201/embed/${slug}?${preview ? "preview&" : ""}${query}` : `https://show.qureal.com/ts/${slug}`}
|
|
42
|
+
, style: _extends({
|
|
43
|
+
width: "100%",
|
|
44
|
+
height: "100vh"
|
|
45
|
+
}, style)
|
|
46
|
+
})
|
|
62
47
|
);
|
|
63
48
|
}
|
|
64
49
|
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {}\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","handler","ev","includes","origin","babelHelpers.typeof","data","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {}\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","handler","ev","includes","origin","babelHelpers.typeof","data","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;QAAvDC,IAAuD,QAAvDA,IAAuD;QAAjDC,OAAiD,QAAjDA,OAAiD;QAAxCC,KAAwC,QAAxCA,KAAwC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B;0BAAdC,KAAc;QAAdA,KAAc,8BAAN,EAAM;;;WAIvE;gBAAA;;;gBAEW,eADP;mBAEU;;cAEN,KAAKD,SAAS,UAAT,sCAAuDH,IAAvD,UAA+DC,UAAU,UAAV,GAAuB,EAAtF,IAA2FC,KAA3F,mCAAmIF;;cAExI;uBACW,MADX;wBAEY;eACLI,KAHP;;KARZ;;;;AAmBJ,qBAAeC,MAAMC,IAAN,CAAWP,YAAX,EAAyB;WAAM,IAAN;CAAzB,CAAf;;ACtBA,IAAMQ,kBAAkB,CAAC,yBAAD,EAA4B,uBAA5B,CAA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ACUC,IADV;iBAEaC,OAFb;eAGW6B,QAAQrB,OAAR,CAHX;cAIUN,IAJV;eAKWC;MANf;;;AAeJ,SAAS0B,OAAT,CAAiBC,GAAjB,EAAsB;QACZC,aAAa,SAAbA,UAAa,CAACC,MAAD,EAASF,GAAT,EAAiB;eACzBG,OAAOC,IAAP,CAAYJ,GAAZ,EACFK,GADE,CACE,eAAO;gBACFC,QAAQN,IAAIO,GAAJ,CAAd;gBACMC,cAAcN,SAAYA,MAAZ,SAAsBK,GAAtB,GAA8BA,GAAlD;gBACI,QAAOD,KAAP,yCAAOA,KAAP,OAAiB,QAAjB,IAA6BA,UAAU,IAA3C,EAAiD;uBACtCL,WAAWO,WAAX,EAAwBF,KAAxB,CAAP;aADJ,MAEO;uBACOE,WAAV,SAAyBF,KAAzB;;SAPL,EAUFG,IAVE,CAUG,GAVH,CAAP;KADJ;;WAcOR,WAAW,EAAX,EAAeD,GAAf,CAAP;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -13,21 +13,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
13
13
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
var defineProperty = function (obj, key, value) {
|
|
17
|
-
if (key in obj) {
|
|
18
|
-
Object.defineProperty(obj, key, {
|
|
19
|
-
value: value,
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
obj[key] = value;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return obj;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
16
|
var _extends = Object.assign || function (target) {
|
|
32
17
|
for (var i = 1; i < arguments.length; i++) {
|
|
33
18
|
var source = arguments[i];
|
|
@@ -43,8 +28,6 @@ var _extends = Object.assign || function (target) {
|
|
|
43
28
|
};
|
|
44
29
|
|
|
45
30
|
function QurealiFrame(_ref) {
|
|
46
|
-
var _React$createElement;
|
|
47
|
-
|
|
48
31
|
var slug = _ref.slug,
|
|
49
32
|
preview = _ref.preview,
|
|
50
33
|
query = _ref.query,
|
|
@@ -57,15 +40,17 @@ function QurealiFrame(_ref) {
|
|
|
57
40
|
return React__default.createElement(
|
|
58
41
|
React.Fragment,
|
|
59
42
|
null,
|
|
60
|
-
React__default.createElement("iframe",
|
|
43
|
+
React__default.createElement("iframe", {
|
|
61
44
|
id: "qureal_iframe",
|
|
62
45
|
title: "Qureal"
|
|
63
46
|
// src={`http://localhost:3201/embed/${creation_slug}`}
|
|
64
47
|
, src: type === "creation" ? "https://show.qureal.com/embed/" + slug + "?" + (preview ? "preview&" : "") + query : "https://show.qureal.com/ts/" + slug
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
// src={type === "creation" ? `http://localhost:3201/embed/${slug}?${preview ? "preview&" : ""}${query}` : `https://show.qureal.com/ts/${slug}`}
|
|
49
|
+
, style: _extends({
|
|
50
|
+
width: "100%",
|
|
51
|
+
height: "100vh"
|
|
52
|
+
}, style)
|
|
53
|
+
})
|
|
69
54
|
);
|
|
70
55
|
}
|
|
71
56
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {}\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","handler","ev","includes","origin","babelHelpers.typeof","data","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {}\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","handler","ev","includes","origin","babelHelpers.typeof","data","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;QAAvDC,IAAuD,QAAvDA,IAAuD;QAAjDC,OAAiD,QAAjDA,OAAiD;QAAxCC,KAAwC,QAAxCA,KAAwC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B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