{"size": 17881, "ext": "js", "max_stars_repo_path": "server/plugins/stencil-editor/public/dist/stencil-preview-sdk.js", "max_stars_repo_name": "angry-penguins/big-cli", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/plugins/stencil-editor/public/dist/stencil-preview-sdk.js", "max_issues_repo_name": "angry-penguins/big-cli", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/plugins/stencil-editor/public/dist/stencil-preview-sdk.js", "max_forks_repo_name": "angry-penguins/big-cli", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 8940.5, "max_line_length": 17833, "alphanum_fraction": 0.6961020077}
!function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,exports,t){e.exports=t(1)},function(e,exports,t){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}var o=t(2),i=n(o),r=t(3),s=n(r),a=t(5),c=n(a),d=t(6),u=n(d),l=new i["default"](window,c["default"],u["default"]);window.previewSdk={iframeSdk:l,themeEditor:new s["default"](window.document,l)}},function(e,exports){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),o=exports.STAPLER_PROXY_COOKIE_NAME="bc_upstream",i=exports.STAPLER_PROXY_COOKIE_VALUE="nodejs",r=exports.STENCIL_COOKIE_NAME="stencil_preview",s=function(){function e(n,o,i){var r=this;return t(this,e),this.chan=null,this.configurationId="",this.cookieDomain=this.getCookieDomain(n.location.hostname),this.document=n.document,this.jsChannel=o,this.jsCookie=i,this.sessionId="",this.versionId="",this.window=n,this.ready=!1,this.runningInIframe()?(this.chan=o.build({window:n.parent,origin:"*",onReady:function(){return r.onReady()},scope:"stencilEditor"}),this.parseCookie(),this.registerWindowEvents(),void this.registerEvents()):void this.closePreview()}return n(e,[{key:"getCookieDomain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"localhost";return"localhost"!==e&&"www."!==e.substr(0,4)?"."+e:e}},{key:"closePreview",value:function(){this.removeCookies(),this.reloadPage()}},{key:"parseCookie",value:function(){var e=this.jsCookie.get(r).split("@");if(e.length<2)throw new Error("Invalid preview cookie");this.versionId=e[0],this.configurationId=e[1],this.sessionId=e[2]||""}},{key:"bind",value:function(e,t){var n=this;this.chan.bind(e,function(o,i){var r=JSON.parse(i);n.debug&&console.log("received",e,r),t(r,o)})}},{key:"call",value:function(e,t,n,o){this.debug&&console.log("sent",e,t),this.chan.call({method:e,params:t||{},success:n||function(){},error:o||function(){}})}},{key:"registerEvents",value:function(){var e=this;this.bind("reload-page",function(){return e.reloadPage()}),this.bind("set-cookie",function(t){e.configurationId=t.configurationId||e.configurationId,e.versionId=t.versionId||e.versionId,e.sessionId=t.sessionId||e.sessionId,e.setCookies(),t.reloadPage===!0&&e.reloadPage()})}},{key:"registerWindowEvents",value:function(){var e=this;this.window.addEventListener("focus",function(){e.setCookies()}),this.window.onbeforeunload=function(){e.ready=!1,e.call("sdk-not-ready")}}},{key:"reloadPage",value:function(){return this.document.location.reload(!0),!0}},{key:"runningInIframe",value:function(){try{return this.window.self!==this.window.top}catch(e){return!0}}},{key:"setCookies",value:function(){var e=this.sessionId?this.versionId+"@"+this.configurationId+"@"+this.sessionId:this.versionId+"@"+this.configurationId;this.setCookie(r,e),this.setCookie(o,i)}},{key:"setCookie",value:function(e,t){if(this.jsCookie.set(e,t,{domain:this.cookieDomain}),this.cookieDomain.match(/^www\./)){var n=this.cookieDomain.substr(3,this.cookieDomain.length);this.jsCookie.set(e,t,{domain:n})}}},{key:"onReady",value:function(){this.ready=!0,this.call("sdk-ready")}},{key:"removeCookies",value:function(){if(this.removeCookie(r),this.removeCookie(o),this.cookieDomain.match(/^www\./)){var e=this.cookieDomain.substr(3,this.cookieDomain.length);this.removeCookie(r,e),this.removeCookie(o,e)}}},{key:"removeCookie",value:function(e,t){this.jsCookie.remove(e,{domain:t||this.cookieDomain})}}]),e}();exports["default"]=s},function(e,exports,t){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=t(4),s=n(r),a=function(){function e(t,n){o(this,e),this.document=t,this.sdk=n,this.registerSdkEvents()}return i(e,[{key:"addFont",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.document.createElement("link");n.error=n.error||function(){},n.success=n.success||function(){},o.setAttribute("rel","stylesheet"),o.setAttribute("href",e);var i=o.addEventListener("load",function(){n.success(e),o.removeEventListener("load",i),t.document.body.focus()});return this.document.head.appendChild(o),!0}},{key:"rewriteStylesheetUrl",value:function(e){var t=e.indexOf("?"),n=t!==-1?e.substring(0,t):e,o=/[-|\/](\w+)\/stencil\/(.*)/i,i=n.match(o);if(i){var r=i[1],s=i[2];n="/stencil/s-"+r+"/"+s}if(0!==n.indexOf("/stencil"))throw new Error("Invalid stylesheet url");return n}},{key:"getStylesheetBaseUrl",value:function(e){var t=e.match(/(^\/stencil\/s-.*?)\//i);return t?t[1]:"/stencil"}},{key:"getStylesheetRelativePath",value:function(e){var t="(?:[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12})",n=new RegExp("/(css/.*)-"+t+"\\.css","i"),o=e.match(n);if(!o)throw new Error("Invalid stylesheet url");return o[1]+"-"+this.sdk.configurationId+".css?preview="+Date.now()}},{key:"generateStylesheetUrl",value:function(e){var t=this.rewriteStylesheetUrl(e),n=this.getStylesheetBaseUrl(t),o=this.getStylesheetRelativePath(t);return this.sdk.sessionId?n+"/"+this.sdk.versionId+"/e/"+this.sdk.sessionId+"/"+o:n+"/"+this.sdk.versionId+"/"+o}},{key:"getStylesheets",value:function(){var e=this.document.head.querySelectorAll("link[data-stencil-stylesheet]");return Array.prototype.slice.call(e)}},{key:"registerSdkEvents",value:function(){var e=this;this.sdk.bind("add-font",function(t,n){return n.delayReturn(!0),e.addFont(t.fontUrl,{error:function(e){n.error(e)},success:function(e){n.complete(e)}})}),this.sdk.bind("reload-stylesheets",function(t,n){e.sdk.configurationId=t.configurationId;var o=e.getStylesheets().filter(function(e){return!e.hasAttribute("data-is-loading")}),i={error:s["default"].callOnce(function(e){return n.error(e)}),success:s["default"].callAfterNTimes(o.length,function(e){return n.complete(e)})};return n.delayReturn(!0),e.sdk.setCookies(),e.reloadStylesheets(i)})}},{key:"reloadStylesheets",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.error=e.error||function(){},e.success=e.success||function(){},this.getStylesheets().forEach(this.updateStylesheet.bind(this,e)),!0}},{key:"updateStylesheet",value:function(e,t){function n(){s.removeAttribute("data-is-loading"),s.removeEventListener("error",o),s.removeEventListener("load",n),i.document.head.removeChild(t),e.success(r),i.document.body.focus()}function o(){e.error(r),s.removeEventListener("error",o),s.removeEventListener("load",n),i.document.head.removeChild(s)}var i=this,r=t.getAttribute("href"),s=void 0;r&&(t.hasAttribute("data-is-loading")?this.document.head.removeChild(t):(s=t.cloneNode(!1),s.setAttribute("href",this.generateStylesheetUrl(r)),s.setAttribute("data-is-loading",!0),s.addEventListener("load",n),s.addEventListener("error",o),this.document.head.insertBefore(s,t)))}}]),e}();exports["default"]=a},function(e,exports){"use strict";function t(e,t){var n=this,o=e;return function(){for(var e=arguments.length,i=Array(e),r=0;r<e;r++)i[r]=arguments[r];return--o<1?t.apply(n,i):null}}function n(e){var t=!1,n=void 0;return function(){if(!t){t=!0;for(var o=arguments.length,i=Array(o),r=0;r<o;r++)i[r]=arguments[r];n=e.apply(this,i)}return n}}function o(e){var t=document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState;t?e():document.addEventListener("DOMContentLoaded",e)}function i(){var e=document.querySelector("[data-preview-sdk-container]");return e||(e=document.createElement("div"),e.setAttribute("data-preview-sdk-container",1),document.body.appendChild(e)),e}function r(e){var t=document.createElement("div");return t.innerHTML=e,t.firstChild}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]={callAfterNTimes:t,callOnce:n,documentReady:o,getAppContainer:i,convertHtmlToElement:r}},function(e,exports,t){var n,o=function(){"use strict";function e(e,t,n,o){function r(t){for(var n=0;n<t.length;n++)if(t[n].win===e)return!0;return!1}var s=!1;if("*"===t){for(var a in i)if(i.hasOwnProperty(a)&&"*"!==a&&"object"==typeof i[a][n]&&(s=r(i[a][n])))break}else i["*"]&&i["*"][n]&&(s=r(i["*"][n])),!s&&i[t]&&i[t][n]&&(s=r(i[t][n]));if(s)throw"A channel is already bound to the same window which overlaps with origin '"+t+"' and has scope '"+n+"'";"object"!=typeof i[t]&&(i[t]={}),"object"!=typeof i[t][n]&&(i[t][n]=[]),i[t][n].push({win:e,handler:o})}function t(e,t,n){for(var o=i[t][n],r=0;r<o.length;r++)o[r].win===e&&o.splice(r,1);0===i[t][n].length&&delete i[t][n]}function n(e){return Array.isArray?Array.isArray(e):e.constructor.toString().indexOf("Array")!=-1}var o=Math.floor(1000001*Math.random()),i={},r={},s=function(e){try{var t=JSON.parse(e.data);if("object"!=typeof t||null===t)throw"malformed"}catch(e){return}var n,o,s,a=e.source,c=e.origin;if("string"==typeof t.method){var d=t.method.split("::");2==d.length?(n=d[0],s=d[1]):s=t.method}if("undefined"!=typeof t.id&&(o=t.id),"string"==typeof s){var u=!1;if(i[c]&&i[c][n])for(var l=0;l<i[c][n].length;l++)if(i[c][n][l].win===a){i[c][n][l].handler(c,s,t),u=!0;break}if(!u&&i["*"]&&i["*"][n])for(var l=0;l<i["*"][n].length;l++)if(i["*"][n][l].win===a){i["*"][n][l].handler(c,s,t);break}}else"undefined"!=typeof o&&r[o]&&r[o](c,s,t)};return window.addEventListener?window.addEventListener("message",s,!1):window.attachEvent&&window.attachEvent("onmessage",s),{build:function(i){var s=function(e){if(i.debugOutput&&window.console&&window.console.log){try{"string"!=typeof e&&(e=JSON.stringify(e))}catch(t){}window.console.log("["+d+"] "+e)}};if(!window.postMessage)throw"jschannel cannot run this browser, no postMessage";if(!window.JSON||!window.JSON.stringify||!window.JSON.parse)throw"jschannel cannot run this browser, no JSON parsing/serialization";if("object"!=typeof i)throw"Channel build invoked without a proper object argument";if(!i.window||!i.window.postMessage)throw"Channel.build() called without a valid window argument";if(window===i.window)throw"target window is same as present window -- not allowed";var a=!1;if("string"==typeof i.origin){var c;"*"===i.origin?a=!0:null!==(c=i.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/))&&(i.origin=c[0].toLowerCase(),a=!0)}if(!a)throw"Channel.build() called with an invalid origin";if("undefined"!=typeof i.scope){if("string"!=typeof i.scope)throw"scope, when specified, must be a string";if(i.scope.split("::").length>1)throw"scope may not contain double colons: '::'"}var d=function(){for(var e="",t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",n=0;n<5;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}(),u={},l={},f={},h=!1,v=[],p=function(e,t,n){var o=!1,i=!1;return{origin:t,invoke:function(t,o){if(!f[e])throw"attempting to invoke a callback of a nonexistent transaction: "+e;for(var i=!1,r=0;r<n.length;r++)if(t===n[r]){i=!0;break}if(!i)throw"request supports no such callback '"+t+"'";y({id:e,callback:t,params:o})},error:function(t,n){if(i=!0,!f[e])throw"error called for nonexistent message: "+e;delete f[e],y({id:e,error:t,message:n})},complete:function(t){if(i=!0,!f[e])throw"complete called for nonexistent message: "+e;delete f[e],y({id:e,result:t})},delayReturn:function(e){return"boolean"==typeof e&&(o=e===!0),o},completed:function(){return i}}},g=function(e,t,n){return window.setTimeout(function(){if(l[e]){var o="timeout ("+t+"ms) exceeded on method '"+n+"'";(0,l[e].error)("timeout_error",o),delete l[e],delete r[e]}},t)},m=function(e,t,o){if("function"==typeof i.gotMessageObserver)try{i.gotMessageObserver(e,o)}catch(a){s("gotMessageObserver() raised an exception: "+a.toString())}if(o.id&&t){if(u[t]){var c=p(o.id,e,o.callbacks?o.callbacks:[]);f[o.id]={};try{if(o.callbacks&&n(o.callbacks)&&o.callbacks.length>0)for(var d=0;d<o.callbacks.length;d++){for(var h=o.callbacks[d],v=o.params,g=h.split("/"),m=0;m<g.length-1;m++){var w=g[m];"object"!=typeof v[w]&&(v[w]={}),v=v[w]}v[g[g.length-1]]=function(){var e=h;return function(t){return c.invoke(e,t)}}()}var y=u[t](c,o.params);c.delayReturn()||c.completed()||c.complete(y)}catch(a){var k="runtime_error",b=null;if("string"==typeof a?b=a:"object"==typeof a&&(a&&n(a)&&2==a.length?(k=a[0],b=a[1]):"string"==typeof a.error&&(k=a.error,a.message?"string"==typeof a.message?b=a.message:a=a.message:b="")),null===b)try{b=JSON.stringify(a),"undefined"==typeof b&&(b=a.toString())}catch(C){b=a.toString()}c.error(k,b)}}}else o.id&&o.callback?l[o.id]&&l[o.id].callbacks&&l[o.id].callbacks[o.callback]?l[o.id].callbacks[o.callback](o.params):s("ignoring invalid callback, id:"+o.id+" ("+o.callback+")"):o.id?l[o.id]?(o.error?(0,l[o.id].error)(o.error,o.message):void 0!==o.result?(0,l[o.id].success)(o.result):(0,l[o.id].success)(),delete l[o.id],delete r[o.id]):s("ignoring invalid response: "+o.id):t&&u[t]&&u[t]({origin:e},o.params)};e(i.window,i.origin,"string"==typeof i.scope?i.scope:"",m);var w=function(e){return"string"==typeof i.scope&&i.scope.length&&(e=[i.scope,e].join("::")),e},y=function(e,t){if(!e)throw"postMessage called with null message";var n=h?"post  ":"queue ";if(s(n+" message: "+JSON.stringify(e)),t||h){if("function"==typeof i.postMessageObserver)try{i.postMessageObserver(i.origin,e)}catch(o){s("postMessageObserver() raised an exception: "+o.toString())}i.window.postMessage(JSON.stringify(e),i.origin)}else v.push(e)},k=function(e,t){if(s("ready msg received"),h&&!i.reconnect)throw"received ready message while in ready state.  help!";for(h=!1,d.length<6&&(d+="ping"===t?"-R":"-L"),i.reconnect||b.unbind("__ready"),h=!0,s("ready msg accepted."),"ping"===t&&b.notify({method:"__ready",params:"pong"});v.length;)y(v.pop());"function"==typeof i.onReady&&i.onReady(b)},b={unbind:function(e){if(u[e]){if(!delete u[e])throw"can't delete method: "+e;return!0}return!1},bind:function(e,t){if(!e||"string"!=typeof e)throw"'method' argument to bind must be string";if(!t||"function"!=typeof t)throw"callback missing from bind params";if(u[e])throw"method '"+e+"' is already bound!";return u[e]=t,this},call:function(e){if(!e)throw"missing arguments to call function";if(!e.method||"string"!=typeof e.method)throw"'method' argument to call must be string";if(!e.success||"function"!=typeof e.success)throw"'success' callback missing from call";var t={},n=[],i=[],s=function(e,o){if(i.indexOf(o)>=0)throw"params cannot be a recursive data structure";if(i.push(o),"object"==typeof o)for(var r in o)if(o.hasOwnProperty(r)){var a=e+(e.length?"/":"")+r;"function"==typeof o[r]?(t[a]=o[r],n.push(a),delete o[r]):"object"==typeof o[r]&&s(a,o[r])}};s("",e.params);var a={id:o,method:w(e.method),params:e.params};n.length&&(a.callbacks=n),e.timeout&&g(o,e.timeout,w(e.method)),l[o]={callbacks:t,error:e.error,success:e.success},r[o]=m,o++,y(a)},notify:function(e){if(!e)throw"missing arguments to notify function";if(!e.method||"string"!=typeof e.method)throw"'method' argument to notify must be string";y({method:w(e.method),params:e.params})},destroy:function(){t(i.window,i.origin,"string"==typeof i.scope?i.scope:""),window.removeEventListener?window.removeEventListener("message",m,!1):window.detachEvent&&window.detachEvent("onmessage",m),h=!1,u={},f={},l={},i.origin=null,v=[],s("channel destroyed"),d=""}};return b.bind("__ready",k),setTimeout(function(){y({method:w("__ready"),params:"ping"},!0)},0),b}}}();n=function(){return o}.call(exports,t,exports,e),!(void 0!==n&&(e.exports=n)),"undefined"!=typeof e&&void 0!==e.exports&&(e.exports=o)},function(e,exports,t){var n,o;!function(i){var r=!1;if(n=i,o="function"==typeof n?n.call(exports,t,exports,e):n,!(void 0!==o&&(e.exports=o)),r=!0,e.exports=i(),r=!0,!r){var s=window.Cookies,a=window.Cookies=i();a.noConflict=function(){return window.Cookies=s,a}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}function t(n){function o(t,i,r){var s;if("undefined"!=typeof document){if(arguments.length>1){if(r=e({path:"/"},o.defaults,r),"number"==typeof r.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*r.expires),r.expires=a}r.expires=r.expires?r.expires.toUTCString():"";try{s=JSON.stringify(i),/^[\{\[]/.test(s)&&(i=s)}catch(c){}i=n.write?n.write(i,t):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)),t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),t=t.replace(/[\(\)]/g,escape);var d="";for(var u in r)r[u]&&(d+="; "+u,r[u]!==!0&&(d+="="+r[u]));return document.cookie=t+"="+i+d}t||(s={});for(var l=document.cookie?document.cookie.split("; "):[],f=/(%[0-9A-Z]{2})+/g,h=0;h<l.length;h++){var v=l[h].split("="),p=v.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var g=v[0].replace(f,decodeURIComponent);if(p=n.read?n.read(p,g):n(p,g)||p.replace(f,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(c){}if(t===g){s=p;break}t||(s[g]=p)}catch(c){}}return s}}return o.set=o,o.get=function(e){return o.call(o,e)},o.getJSON=function(){return o.apply({json:!0},[].slice.call(arguments))},o.defaults={},o.remove=function(t,n){o(t,"",e(n,{expires:-1}))},o.withConverter=t,o}return t(function(){})})}]);
//# sourceMappingURL=stencil-preview-sdk.js.map