@flourish/sdk 3.17.2 → 3.17.3

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/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 3.17.3
2
+ * Use seeded random sample of column values to interpret columns
3
+
1
4
  # 3.17.2
2
5
  * Fixes an issue which could cause template publication to fail
3
6
 
package/lib/log.js CHANGED
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
 
3
- const colors = require("colors");
3
+ const pc = require("picocolors");
4
4
 
5
5
  function victory(...lines) {
6
- for (let line of lines) console.log(colors.bold.green("👻 " + line));
6
+ for (let line of lines) console.log(pc.bold(pc.green("👻 " + line)));
7
7
  }
8
8
  function success(...lines) {
9
- for (let line of lines) console.log(colors.green(" " + line));
9
+ for (let line of lines) console.log(pc.green(" " + line));
10
10
  }
11
11
  function info(...lines) {
12
- for (let line of lines) console.log(colors.yellow(" " + line));
12
+ for (let line of lines) console.log(pc.yellow(" " + line));
13
13
  }
14
14
  function warn(...lines) {
15
- for (let line of lines) console.warn(colors.yellow("⚠️ " + line));
15
+ for (let line of lines) console.warn(pc.yellow("⚠️ " + line));
16
16
  }
17
17
  function warn_bold(...lines) {
18
- for (let line of lines) console.warn(colors.bold.yellow(" " + line));
18
+ for (let line of lines) console.warn(pc.bold(pc.yellow(" " + line)));
19
19
  }
20
20
  function problem(...lines) {
21
- for (let line of lines) console.error(colors.red("😱 " + line));
21
+ for (let line of lines) console.error(pc.red("😱 " + line));
22
22
  }
23
23
 
24
24
  function die(...lines) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flourish/sdk",
3
- "version": "3.17.2",
3
+ "version": "3.17.3",
4
4
  "description": "The Flourish SDK",
5
5
  "module": "src/index.js",
6
6
  "scripts": {
@@ -23,7 +23,6 @@
23
23
  "@rollup/plugin-commonjs": "^17.1.0",
24
24
  "archiver": "^5.0.2",
25
25
  "chokidar": "^3.4.3",
26
- "colors": "^1.4.0",
27
26
  "cross-spawn": "^7.0.3",
28
27
  "d3-dsv": "^2.0.0",
29
28
  "express": "^4.17.1",
@@ -32,8 +31,9 @@
32
31
  "js-yaml": "^3.14.0",
33
32
  "minimist": "^1.2.5",
34
33
  "ncp": "^2.0.0",
35
- "node-fetch": "^2.6.6",
34
+ "node-fetch": "^2.6.7",
36
35
  "parse5": "^6.0.1",
36
+ "picocolors": "^1.0.0",
37
37
  "read": "^1.0.7",
38
38
  "resolve": "^1.18.1",
39
39
  "rewrite-links": "^1.1.0",
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@rollup/plugin-node-resolve": "^9.0.0",
47
47
  "d3-request": "^1.0.6",
48
- "mocha": "^9.1.2",
48
+ "mocha": "^9.2.0",
49
49
  "npm-audit-resolver": "^2.3.0",
50
50
  "rollup": "^2.32.1",
51
51
  "sinon": "^9.2.0",
package/server/data.js CHANGED
@@ -175,12 +175,43 @@ function extractData(data_binding, data_by_id, column_types_by_id, template_data
175
175
 
176
176
  function getColumnTypesForData(data) {
177
177
  return transposeNestedArray(data)
178
- .map(function(d, i) {
179
- const type_id = interpretColumn(d)[0].id;
178
+ .map(function(column, i) {
179
+ const sliced_column = getSlicedData(column);
180
+ const sample_size = 1000;
181
+ let sample_data;
182
+ if (sliced_column.length > (sample_size * 2)) sample_data = getRandomSeededSample(sliced_column, sample_size);
183
+ else sample_data = sliced_column;
184
+ const type_id = interpretColumn(sample_data)[0].id;
180
185
  return { type_id: type_id, index: i, output_format_id: type_id };
181
186
  });
182
187
  }
183
188
 
189
+ // Returns a random seeded sample of column values based on the column length.
190
+ // The sample is consistent and will update if the length of column changes.
191
+ function getRandomSeededSample(column, sample_size) {
192
+ if (column.length <= sample_size * 2) return column;
193
+ const rng = mulberry32(column.length);
194
+
195
+ while (column.length > sample_size) {
196
+ const random_index = Math.floor(rng() * column.length);
197
+
198
+ column.splice(random_index, 1);
199
+ }
200
+
201
+ return column;
202
+ }
203
+
204
+ // Seeded RNG implementation taken from https://github.com/bryc/code/blob/master/jshash/PRNGs.md#mulberry32
205
+ function mulberry32(seed) {
206
+ let a = seed;
207
+ return function() {
208
+ a |= 0; a = a + 0x6D2B79F5 | 0;
209
+ var t = Math.imul(a ^ a >>> 15, 1 | a);
210
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
211
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
212
+ };
213
+ }
214
+
184
215
  function trimTrailingEmptyRows(data) {
185
216
  for (var i = data.length; i-- > 1;) {
186
217
  if (!data[i] || !data[i].length || (Array.isArray(data[i]) && data[i].findIndex(function(col) { return col !== null && col !== ""; }) == -1)) {
@@ -194,9 +225,11 @@ function trimTrailingEmptyRows(data) {
194
225
  function dropReturnCharacters(data) {
195
226
  for (const row of data) {
196
227
  for (let i = 0; i < row.length; i++) {
197
- // Replace new-line character and surrounding whitespace with single space
198
- // This fixes issue with pasting cells containing long strings from Excel into HoT
199
- row[i] = row[i].replace(/(\r\n|\n|\r)/g, " ");
228
+ // Due to a bug in HoT, pasting long lines from Excel can lead to the addition of
229
+ // a newline character and a space *before* a space character.
230
+ // This leads to a pattern of new line character followed by two spaces.
231
+ // Here we identify that pattern and revert it.
232
+ row[i] = row[i].replace(/(\r\n|\n|\r) {2}/g, " ");
200
233
  }
201
234
  }
202
235
  return data;
@@ -262,8 +295,10 @@ function interpretColumn(arr) {
262
295
  exports.dropReturnCharacters = dropReturnCharacters;
263
296
  exports.extractData = extractData;
264
297
  exports.getColumnTypesForData = getColumnTypesForData;
298
+ exports.getRandomSeededSample = getRandomSeededSample;
265
299
  exports.getSlicedData = getSlicedData;
266
300
  exports.interpretColumn = interpretColumn;
301
+ exports.mulberry32 = mulberry32;
267
302
  exports.transposeNestedArray = transposeNestedArray;
268
303
  exports.trimTrailingEmptyRows = trimTrailingEmptyRows;
269
304
  exports.trimWhitespace = trimWhitespace;
package/site/embedded.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){"use strict";var e,i,t=!1;function n(e){if(t&&window.top!==window.self){var i=window;"srcdoc"===i.location.pathname&&(i=i.parent);var n,o=(n={},window._Flourish_template_id&&(n.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(n.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(n.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(n.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(n.story_id=window.Flourish.app.story.id,n.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(n.slide_index=window.Flourish.app.current_slide.index+1),n),r={sender:"Flourish",method:"customerAnalytics"};for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);for(var a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);i.parent.postMessage(JSON.stringify(r),"*")}}function o(e){if("function"!=typeof e)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(e)}function r(){t=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(e){document.body.addEventListener(e.event_name,(function(){n({action:e.action_name})}),e.use_capture)}))}function a(){if(null==e){var i=function(){var e=window.location;"about:srcdoc"==e.href&&(e=window.parent.location);var i={};return function(e,t,n){for(;n=t.exec(e);)i[decodeURIComponent(n[1])]=decodeURIComponent(n[2])}(e.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),i}();e="referrer"in i?/^https:\/\/medium.com\//.test(i.referrer):!("auto"in i)}return e}function s(e){var i=e||window.innerWidth;return i>999?650:i>599?575:400}function l(e,t){if(window.top!==window.self){var n=window;if("srcdoc"==n.location.pathname&&(n=n.parent),i)return e=parseInt(e,10),void n.parent.postMessage({sentinel:"amp",type:"embed-size",height:e},"*");var o={sender:"Flourish",context:"iframe.resize",method:"resize",height:e,src:n.location.toString()};if(t)for(var r in t)o[r]=t[r];n.parent.postMessage(JSON.stringify(o),"*")}}function d(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function u(e){window.addEventListener("message",(function(i){if(null!=i.source&&(i.origin===document.location.origin||i.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$/))){var t;try{t=JSON.parse(i.data)}catch(e){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(i.data))}if("Flourish"===t.sender){for(var n=document.querySelectorAll("iframe"),o=0;o<n.length;o++)if(n[o].contentWindow==i.source||n[o].contentWindow==i.source.parent)return void e(t,n[o]);console.warn("could not find frame",t)}}})),d()&&(window.addEventListener("resize",h),h())}function h(){for(var e=document.querySelectorAll(".flourish-embed"),i=0;i<e.length;i++){var t=e[i];if(!t.getAttribute("data-width")){var n=t.querySelector("iframe");if(n){var o=window.getComputedStyle(t),r=t.offsetWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight);n.style.width=r+"px"}}}}function c(e,i,t,n,o){var r=document.createElement("iframe");if(r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),r.setAttribute("title","Interactive or visual content"),r.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),i.appendChild(r),r.offsetParent||"fixed"===getComputedStyle(r).position)f(e,i,r,t,n,o);else{var a={embed_url:e,container:i,iframe:r,width:t,height:n,play_on_load:o};if(window._flourish_poll_items?window._flourish_poll_items.push(a):window._flourish_poll_items=[a],window._flourish_poll_items.length>1)return r;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(e){return!e.iframe.offsetParent||(f(e.embed_url,e.container,e.iframe,e.width,e.height,e.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return r}function f(e,i,t,n,o,r){var a;return n&&"number"==typeof n?(a=n,n+="px"):n&&n.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(a=parseFloat(n)),o&&"number"==typeof o&&(o+="px"),n?t.style.width=n:d()?t.style.width=i.offsetWidth+"px":t.style.width="100%",!!o||(e.match(/\?/)?e+="&auto=1":e+="?auto=1",o=s(a||t.offsetWidth)+"px"),o&&("%"===o.charAt(o.length-1)&&(o=parseFloat(o)/100*i.parentNode.offsetHeight+"px"),t.style.height=o),t.setAttribute("src",e+(r?"#play-on-load":"")),t}function w(e){return!Array.isArray(e)&&"object"==typeof e&&null!=e}function p(e,i){for(var t in i)w(e[t])&&w(i[t])?p(e[t],i[t]):e[t]=i[t];return e}!function(){var e,t=window.top===window.self,h=t?null:(i="#amp=1"==window.location.hash,{createEmbedIframe:c,isFixedHeight:a,getHeightForBreakpoint:s,startEventListeners:u,notifyParentWindow:l,isSafari:d,initCustomerAnalytics:r,addAnalyticsListener:o,sendCustomerAnalyticsMessage:n}),f=!0;function w(){var i;Flourish.fixed_height||(null!=e?i=e:f&&(i=h.getHeightForBreakpoint()),i!==window.innerHeight&&h.notifyParentWindow(i))}function m(){w(),window.addEventListener("resize",w)}Flourish.warn=function(e){if("string"==typeof e&&(e={message:e}),t||"editor"!==Flourish.environment)console.warn(e.message);else{var i={sender:"Flourish",method:"warn",message:e.message,explanation:e.explanation};window.parent.postMessage(JSON.stringify(i),"*")}},Flourish.uploadImage=function(e){if(t||"story_editor"!==Flourish.environment)throw"Invalid upload request";var i={sender:"Flourish",method:"request-upload",name:e.name,accept:e.accept};window.parent.postMessage(JSON.stringify(i),"*")},Flourish.setSetting=function(e,i){if("editor"===Flourish.environment||"sdk"===Flourish.environment){var t={sender:"Flourish",method:"setSetting",name:e,value:i};window.parent.postMessage(JSON.stringify(t),"*")}else if("story_editor"===Flourish.environment){var n={};n[e]=i,p(window.template.state,function(e){var i={};for(var t in e){for(var n=i,o=t.indexOf("."),r=0;o>=0;o=t.indexOf(".",r=o+1)){var a=t.substring(r,o);a in n||(n[a]={}),n=n[a]}n[t.substring(r)]=e[t]}return i}(n))}},Flourish.setHeight=function(i){Flourish.fixed_height||(e=i,f=null==i,w())},Flourish.checkHeight=function(){if(!t){var e=Flourish.__container_height;null!=e?(Flourish.fixed_height=!0,h.notifyParentWindow(e)):h.isFixedHeight()?Flourish.fixed_height=!0:(Flourish.fixed_height=!1,w())}},Flourish.fixed_height=t||h.isFixedHeight(),Flourish.enableCustomerAnalytics=function(){h&&h.initCustomerAnalytics()},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",m):m()}()}();
1
+ !function(){"use strict";var e,t,n=!1;function i(e){if(n&&window.top!==window.self){var t=window;"srcdoc"===t.location.pathname&&(t=t.parent);var i,o=(i={},window._Flourish_template_id&&(i.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(i.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(i.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(i.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(i.story_id=window.Flourish.app.story.id,i.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(i.slide_index=window.Flourish.app.current_slide.index+1),i),r={sender:"Flourish",method:"customerAnalytics"};for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);for(var a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);t.parent.postMessage(JSON.stringify(r),"*")}}function o(e){if("function"!=typeof e)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(e)}function r(){n=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(e){document.body.addEventListener(e.event_name,(function(){i({action:e.action_name})}),e.use_capture)}))}function a(){if(null==e){var t=function(){var e=window.location;"about:srcdoc"==e.href&&(e=window.parent.location);var t={};return function(e,n,i){for(;i=n.exec(e);)t[decodeURIComponent(i[1])]=decodeURIComponent(i[2])}(e.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),t}();e="referrer"in t?/^https:\/\/medium.com\//.test(t.referrer):!("auto"in t)}return e}function s(e){var t=e||window.innerWidth;return t>999?650:t>599?575:400}function l(e,n){if(window.top!==window.self){var i=window;if("srcdoc"==i.location.pathname&&(i=i.parent),t)return e=parseInt(e,10),void i.parent.postMessage({sentinel:"amp",type:"embed-size",height:e},"*");var o={sender:"Flourish",context:"iframe.resize",method:"resize",height:e,src:i.location.toString()};if(n)for(var r in n)o[r]=n[r];i.parent.postMessage(JSON.stringify(o),"*")}}function d(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function u(e){return"string"==typeof e||e instanceof String}function c(e){return"warn"!==e.method?(console.warn("BUG: validateWarnMessage called for method"+e.method),!1):!(null!=e.message&&!u(e.message))&&!(null!=e.explanation&&!u(e.explanation))}function h(e){return"resize"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!u(e.src)&&(!!u(e.context)&&!!("number"==typeof(t=e.height)?!isNaN(t)&&t>=0:u(t)&&/\d/.test(t)&&/^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(t)));var t}function f(e){throw new Error("Validation for setSetting is not implemented yet; see issue #4328")}function w(e){return"customerAnalytics"===e.method||(console.warn("BUG: validateCustomerAnalyticsMessage called for method"+e.method),!1)}function p(e){return"request-upload"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!u(e.name)&&!(null!=e.accept&&!u(e.accept))}function m(e,t){var n=function(e){for(var t={warn:c,resize:h,setSetting:f,customerAnalytics:w,"request-upload":p},n={},i=0;i<e.length;i++){var o=e[i];if(!t[o])throw new Error("No validator found for method "+o);n[o]=t[o]}return n}(t);window.addEventListener("message",(function(t){if(null!=t.source&&(t.origin===document.location.origin||t.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$/))){var i;try{i=JSON.parse(t.data)}catch(e){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(t.data))}if("Flourish"===i.sender)if(i.method)if(Object.prototype.hasOwnProperty.call(n,i.method))if(n[i.method](i)){for(var o=document.querySelectorAll("iframe"),r=0;r<o.length;r++)if(o[r].contentWindow==t.source||o[r].contentWindow==t.source.parent)return void e(i,o[r]);console.warn("could not find frame",i)}else console.warn("Validation failed for the message",i);else console.warn("No validator implemented for message",i);else console.warn("The 'method' property was missing from message",i)}})),d()&&(window.addEventListener("resize",g),g())}function g(){for(var e=document.querySelectorAll(".flourish-embed"),t=0;t<e.length;t++){var n=e[t];if(!n.getAttribute("data-width")){var i=n.querySelector("iframe");if(i){var o=window.getComputedStyle(n),r=n.offsetWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight);i.style.width=r+"px"}}}}function v(e,t,n,i,o){var r=document.createElement("iframe");if(r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),r.setAttribute("title","Interactive or visual content"),r.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),t.appendChild(r),r.offsetParent||"fixed"===getComputedStyle(r).position)_(e,t,r,n,i,o);else{var a={embed_url:e,container:t,iframe:r,width:n,height:i,play_on_load:o};if(window._flourish_poll_items?window._flourish_poll_items.push(a):window._flourish_poll_items=[a],window._flourish_poll_items.length>1)return r;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(e){return!e.iframe.offsetParent||(_(e.embed_url,e.container,e.iframe,e.width,e.height,e.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return r}function _(e,t,n,i,o,r){var a;return i&&"number"==typeof i?(a=i,i+="px"):i&&i.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(a=parseFloat(i)),o&&"number"==typeof o&&(o+="px"),i?n.style.width=i:d()?n.style.width=t.offsetWidth+"px":n.style.width="100%",!!o||(e.match(/\?/)?e+="&auto=1":e+="?auto=1",o=s(a||n.offsetWidth)+"px"),o&&("%"===o.charAt(o.length-1)&&(o=parseFloat(o)/100*t.parentNode.offsetHeight+"px"),n.style.height=o),n.setAttribute("src",e+(r?"#play-on-load":"")),n}function y(e){return!Array.isArray(e)&&"object"==typeof e&&null!=e}function F(e,t){for(var n in t)y(e[n])&&y(t[n])?F(e[n],t[n]):e[n]=t[n];return e}!function(){var e,n=window.top===window.self,u=n?null:(t="#amp=1"==window.location.hash,{createEmbedIframe:v,isFixedHeight:a,getHeightForBreakpoint:s,startEventListeners:m,notifyParentWindow:l,isSafari:d,initCustomerAnalytics:r,addAnalyticsListener:o,sendCustomerAnalyticsMessage:i}),c=!0;function h(){var t;Flourish.fixed_height||(null!=e?t=e:c&&(t=u.getHeightForBreakpoint()),t!==window.innerHeight&&u.notifyParentWindow(t))}function f(){h(),window.addEventListener("resize",h)}Flourish.warn=function(e){if("string"==typeof e&&(e={message:e}),n||"editor"!==Flourish.environment)console.warn(e.message);else{var t={sender:"Flourish",method:"warn",message:e.message,explanation:e.explanation};window.parent.postMessage(JSON.stringify(t),"*")}},Flourish.uploadImage=function(e){if(n||"story_editor"!==Flourish.environment)throw"Invalid upload request";var t={sender:"Flourish",method:"request-upload",name:e.name,accept:e.accept};window.parent.postMessage(JSON.stringify(t),"*")},Flourish.setSetting=function(e,t){if("editor"===Flourish.environment||"sdk"===Flourish.environment){var n={sender:"Flourish",method:"setSetting",name:e,value:t};window.parent.postMessage(JSON.stringify(n),"*")}else if("story_editor"===Flourish.environment){var i={};i[e]=t,F(window.template.state,function(e){var t={};for(var n in e){for(var i=t,o=n.indexOf("."),r=0;o>=0;o=n.indexOf(".",r=o+1)){var a=n.substring(r,o);a in i||(i[a]={}),i=i[a]}i[n.substring(r)]=e[n]}return t}(i))}},Flourish.setHeight=function(t){Flourish.fixed_height||(e=t,c=null==t,h())},Flourish.checkHeight=function(){if(!n){var e=Flourish.__container_height;null!=e?(Flourish.fixed_height=!0,u.notifyParentWindow(e)):u.isFixedHeight()?Flourish.fixed_height=!0:(Flourish.fixed_height=!1,h())}},Flourish.fixed_height=n||u.isFixedHeight(),Flourish.enableCustomerAnalytics=function(){u&&u.initCustomerAnalytics()},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",f):f()}()}();
2
2
  //# sourceMappingURL=embedded.js.map