UNPKG

@datafinder/embed-sdk

Version:

Embed SDK for DataFinder

3 lines (2 loc) 25.9 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).embedSDK={})}(this,(function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))}function a(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var i=["dashboard","report","behavior-detail","user-cohort/edit-cohort/:type/:id?","fusion-dashboard","event-analysis","retention-analysis","funnel-analysis"],c={width:"100%",height:"100%",frameBorder:"0"};function s(e){var t=Object.keys(e).filter((function(t){return null!=e[t]})).reduce((function(t,n){var o;return r(r({},t),((o={})[n]=e[n],o))}),{});return new URLSearchParams(t)}var u,l=function(e){return Object.entries(e).map((function(e){var t=e[0],n=e[1];return void 0===n||!1===n?"":"".concat(t,"=").concat(n)})).filter(Boolean).join("&")},d=function(e){var t=e.dashboardId,n=e.filterId,o=e.crossOrigin,a=e.proxyPath,i=e.dorToken,c=e.from,s=e.customRequestHeaders,u=e.locale,l=e.embedQueryParams;return r({filter_id:n,dashboardId:t,crossOrigin:o,proxyPath:a,dorToken:i,from:c,locale:u,crh:s?JSON.stringify(s):void 0},l)},p=function(e,t){var n=e.resultId,r=e.reportId,o=d(e);return n?"".concat(t,"/result/").concat(n,"?").concat(l(o)):r?"".concat(t,"/").concat(r,"?").concat(l(o)):"".concat(t,"?").concat(l(o))};function f(e){var t=e.targetNode;if(function(e){if(!(e.targetNode instanceof HTMLElement))return console.error("Given targetNode is not a valid HTMLElement."),!1;return!0}(e)){e.proxyPath;var n=e.iframeOptions,o=void 0===n?c:n,a=e.onSuccess,i=e.onError;try{var s=document.createElement("iframe");return Object.assign(s,r({src:v(e)},o)),t.appendChild(s),null==a||a(),s}catch(e){null==i||i(e.message),console.error(e)}}}function v(e){var t=e.basePath,n=void 0===t?"/datafinder":t,o=e.needsMinibaseRedirect,a=void 0!==o&&o,c=e.host,s=e.proxyPath,u=e.appId,d=e.projectId,f=e.dashboardId,v=e.reportId,h=e.filterId,m=e.crossOrigin,_=void 0===m||m,y=e.customRequestHeaders,g=e.dorToken,E=e.from,T=e.locale,b=e.embedQueryParams,I=e.showOriginUrl,w=void 0!==I&&I,O=c?c.replace(/\/*$/,""):"",A=function(e){if(e.page)return e.page;if(e.reportId)return"report";return"dashboard"}(e),N=b||{};Object.entries(N).forEach((function(e){var t=e[0],n=e[1];N[t]=n&&"object"==typeof n?encodeURIComponent(JSON.stringify(n)):encodeURIComponent(n)}));var C=r({dashboardId:f,reportId:v,filter_id:h,crossOrigin:_,proxyPath:s,dorToken:g,from:E,crh:y?JSON.stringify(y):void 0,hideBelongTo:A!==i[4],locale:T},N),R=void 0===d||null==d;if(R&&(void 0===u||null==u))throw new Error("At least one argument must be proviced in appId or projectId");var P=function(){var t="";switch(t=R?"".concat(O).concat(n,"/app/").concat(u,"/").concat(w?"":"embed-").concat(A):"".concat(O).concat(n,"/project/").concat(d,"/").concat(w?"":"embed-").concat(A),A){case i[5]:return p(e,t);case i[6]:return p(e,"".concat(t,"/custom"));default:return"".concat(t,"?").concat(l(C))}}();return a?"".concat(O).concat("/minibase/fronted-check/iframe","?app=datafinder&redirectURI=").concat(encodeURIComponent(P)):P}e.PostDataType=void 0,(u=e.PostDataType||(e.PostDataType={})).ExtensionInit="__uba_extension_init__",u.SendReportData="__uba_dash_report_data__",u.ExtensionLoaded="__uba_dash_extension_loaded__";var h={init:function(){var t;return null===(t=window.parent)||void 0===t||t.postMessage({type:e.PostDataType.ExtensionInit,data:{}},"*"),{fetchData:function(){return new Promise((function(t){var n=function(r){var o=r.data;o.type===e.PostDataType.SendReportData&&(null==t||t(o)),window.removeEventListener("message",n)};window.addEventListener("message",n)}))},loaded:function(){var t;null===(t=window.parent)||void 0===t||t.postMessage({type:e.PostDataType.ExtensionLoaded,data:{}},"*")}}}},m={iframe:null},_=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self,{exports:{}});!function(e,t){!function(e){const t=Symbol("Comlink.proxy"),n=Symbol("Comlink.endpoint"),r=Symbol("Comlink.releaseProxy"),o=Symbol("Comlink.thrown"),a=e=>"object"==typeof e&&null!==e||"function"==typeof e,i=new Map([["proxy",{canHandle:e=>a(e)&&e[t],serialize(e){const{port1:t,port2:n}=new MessageChannel;return c(e,t),[n,[n]]},deserialize:e=>(e.start(),l(e))}],["throw",{canHandle:e=>a(e)&&o in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function c(e,t=self){t.addEventListener("message",(function n(r){if(!r||!r.data)return;const{id:a,type:i,path:s}=Object.assign({path:[]},r.data),l=(r.data.argumentList||[]).map(E);let d;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),n=s.reduce(((e,t)=>e[t]),e);switch(i){case"GET":d=n;break;case"SET":t[s.slice(-1)[0]]=E(r.data.value),d=!0;break;case"APPLY":d=n.apply(t,l);break;case"CONSTRUCT":d=_(new n(...l));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;c(e,n),d=m(t,[t])}break;case"RELEASE":d=void 0;break;default:return}}catch(e){d={value:e,[o]:0}}Promise.resolve(d).catch((e=>({value:e,[o]:0}))).then((e=>{const[r,o]=g(e);t.postMessage(Object.assign(Object.assign({},r),{id:a}),o),"RELEASE"===i&&(t.removeEventListener("message",n),u(t))}))})),t.start&&t.start()}function s(e){return"MessagePort"===e.constructor.name}function u(e){s(e)&&e.close()}function l(e,t){return p(e,[],t)}function d(e){if(e)throw new Error("Proxy has been released and is not useable")}function p(e,t=[],o=function(){}){let a=!1;const i=new Proxy(o,{get(n,o){if(d(a),o===r)return()=>T(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{u(e),a=!0}));if("then"===o){if(0===t.length)return{then:()=>i};const n=T(e,{type:"GET",path:t.map((e=>e.toString()))}).then(E);return n.then.bind(n)}return p(e,[...t,o])},set(n,r,o){d(a);const[i,c]=g(o);return T(e,{type:"SET",path:[...t,r].map((e=>e.toString())),value:i},c).then(E)},apply(r,o,i){d(a);const c=t[t.length-1];if(c===n)return T(e,{type:"ENDPOINT"}).then(E);if("bind"===c)return p(e,t.slice(0,-1));const[s,u]=v(i);return T(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:s},u).then(E)},construct(n,r){d(a);const[o,i]=v(r);return T(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:o},i).then(E)}});return i}function f(e){return Array.prototype.concat.apply([],e)}function v(e){const t=e.map(g);return[t.map((e=>e[0])),f(t.map((e=>e[1])))]}const h=new WeakMap;function m(e,t){return h.set(e,t),e}function _(e){return Object.assign(e,{[t]:!0})}function y(e,t=self,n="*"){return{postMessage:(t,r)=>e.postMessage(t,n,r),addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}function g(e){for(const[t,n]of i)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},h.get(e)||[]]}function E(e){switch(e.type){case"HANDLER":return i.get(e.name).deserialize(e.value);case"RAW":return e.value}}function T(e,t,n){return new Promise((r=>{const o=b();e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===o&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)}))}function b(){return new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-")}e.createEndpoint=n,e.expose=c,e.proxy=_,e.proxyMarker=t,e.releaseProxy=r,e.transfer=m,e.transferHandlers=i,e.windowEndpoint=y,e.wrap=l,Object.defineProperty(e,"__esModule",{value:!0})}(t)}(0,_.exports);var y,g="internal-embed-volc.js",E=function(){var e;if("undefined"==typeof document)return"";var t=document.currentScript;if(null==t?void 0:t.src)return t.src;for(var n=document.getElementsByTagName("script"),r=n.length-1;r>=0;r-=1){var o=null===(e=n[r])||void 0===e?void 0:e.src;if(o&&/\/dist\/index\.js(?:\?|#|$)/.test(o))return o}return""}();function T(){return window.__DATAFINDER_INTERNAL_EMBED_VOLC__?Promise.resolve(window.__DATAFINDER_INTERNAL_EMBED_VOLC__):y||(y=new Promise((function(e,t){var n=document.createElement("script");n.async=!0,n.src=E?new URL(g,E).href:g,n.onload=function(){var n=window.__DATAFINDER_INTERNAL_EMBED_VOLC__;n?e(n):t(new Error("internal embed volc runtime load failed"))},n.onerror=function(){t(new Error("Failed to load ".concat(n.src)))},document.head.appendChild(n)})))}function b(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,T()];case 1:return[2,(0,t.sent().getVolcIframeUrlSimple)(e)]}}))}))}var I,w,O,A=function(){var e=this;this.openPage=function(t){return o(e,void 0,void 0,(function(){var e,n,i,s,u,l,d,p,f,h,m,y,g,E,T,I,w=this;return a(this,(function(O){switch(O.label){case 0:n=(e=this).state,i=e.eventTrace,n.proxyPath,s=n.targetNode,u=n.iframeOptions,l=void 0===u?c:u,d=n.onSuccess,p=n.onError,O.label=1;case 1:return O.trys.push([1,7,,8]),f=v(n),(null==(h=n.internalEmbedVolc)?void 0:h.enabled)&&h.volcAccountId?[4,b({volcURL:f,volcAccountId:h.volcAccountId})]:[3,3];case 2:return y=O.sent(),[3,4];case 3:y=f,O.label=4;case 4:return m=y,[4,new Promise((function(e){w.iframe=t||document.createElement("iframe"),Object.assign(w.iframe,r({src:m},l)),s.appendChild(w.iframe),w.iframe.onload=function(){console.log("iframe init success"),null==d||d(),e()}}))];case 5:return O.sent(),g=this.iframe,this.comlinkController=_.exports.wrap(_.exports.windowEndpoint(g.contentWindow,self,"*"),self),E=this.comlinkController,[4,new Promise((function(e,t){_.exports.expose(_.exports.proxy({onReady:function(r){return o(this,void 0,void 0,(function(){var o;return a(this,(function(a){switch(a.label){case 0:if(r!==g.name)return console.log("iframeName ".concat(r," not equals iframe.name ").concat(null==g?void 0:g.name)),[2];a.label=1;case 1:return a.trys.push([1,5,,6]),console.log("tea-next init ready",E),[4,E.setSdkState()];case 2:return a.sent(),[4,E.updateInterfaceConfig(n.interfaceSetting)];case 3:return a.sent(),[4,E.getSdkState()];case 4:if(!a.sent())throw new Error("tea-embed-sdk init failed");return console.log("update interface setting end",n.interfaceSetting),console.log("iframe src:",null==g?void 0:g.src),i(),e(),[3,6];case 5:return o=a.sent(),console.log(o),t(o),[3,6];case 6:return[2]}}))}))}}),_.exports.windowEndpoint(g.contentWindow,self,"*"))}))];case 6:return O.sent(),[3,8];case 7:throw T=O.sent(),I=T,null==p||p(I.message),T;case 8:return[2]}}))}))},this.getDsl=function(){var t;return null===(t=e.comlinkController)||void 0===t?void 0:t.getDsl()},this.getResultId=function(){var t;return null===(t=e.comlinkController)||void 0===t?void 0:t.getResultId()},this.getCurrentUrl=function(){var t;return null===(t=e.comlinkController)||void 0===t?void 0:t.getCurrentUrl()},this.getTeaUrl=function(){var t;return null===(t=e.comlinkController)||void 0===t?void 0:t.getTeaUrl()},this.updateResultId=function(t,n){var r;return null===(r=e.comlinkController)||void 0===r?void 0:r.updateResultId(t,n)},this.setFilters=function(t){var n;return console.log(t,"setFilters by custom"),null===(n=e.comlinkController)||void 0===n?void 0:n.setFilters(t)},this.copyResultId=function(t){var n;return null===(n=e.comlinkController)||void 0===n?void 0:n.copyResultId(t)}},N=function(e){function t(t){var n=e.call(this)||this;return n.eventTrace=function(){var e=n,t=e.comlinkController;e.state,null==t||t.eventTracer()},n.getDsl=function(){var e;return null===(e=n.comlinkController)||void 0===e?void 0:e.getDsl()},n.state=r(r({},t),{page:"event-analysis"}),n}return n(t,e),t}(A),C=function(e){function t(t){var n=e.call(this)||this;return n.eventTrace=function(){var e=n,t=e.comlinkController;e.state,null==t||t.eventTracer()},n.getDsl=function(){var e;return null===(e=n.comlinkController)||void 0===e?void 0:e.getDsl()},n.state=r(r({},t),{page:"retention-analysis"}),n}return n(t,e),t}(A),R=function(e){function t(t){var n=e.call(this)||this;return n.eventTrace=function(){var e=n,t=e.comlinkController;e.state,null==t||t.eventTracer()},n.getDsl=function(){var e;return null===(e=n.comlinkController)||void 0===e?void 0:e.getDsl()},n.state=r(r({},t),{page:"funnel-analysis"}),n}return n(t,e),t}(A);e.EAttrOp=void 0,(I=e.EAttrOp||(e.EAttrOp={})).EQ="=",I.NE="!=",I.NEQ_CONTAIN_NULL="not_equal_contain_null",I.NEQ_NOT_CONTAIN_NULL="not_equal_not_contain_null",I.GT=">",I.LT="<",I.GE=">=",I.LE="<=",I.CONTAIN="contain",I.CUSTOM_CONTAIN="custom_contain",I.NOT_CONTAIN="not_contain",I.NOT_CONTAIN_NOT_CONTAIN_NULL="not_contain_not_contain_null",I.NOT_CONTAIN_CONTAIN_NULL="not_contain_contain_null",I.LIST_CONTAIN="list_contain",I.LIST_NOT_CONTAIN="list_not_contain",I.BETWEEN="between",I.TIME_FIXED="time_fixed",I.TIME_NOT_FIXED="time_not_fixed",I.TIME_RELATIVE_TO_TODAY="time_relative_to_today",I.TIME_NOT_RELATIVE_TO_TODAY="time_not_relative_to_today",I.TIME_WITH_TODAY="time_with_today",I.TIME_NOT_WITH_TODAY="time_not_with_today",I.TIME_RELATIVE_TO_EVENT="time_relative_to_event",I.TIME_NOT_RELATIVE_TO_EVENT="time_not_relative_to_event",I.IS_NULL="is_null",I.IS_NOT_NULL="is_not_null",I.MATCH="match",I.NOT_MATCH="not_match",I.TIME="time",e.MetaPropertyType=void 0,(w=e.MetaPropertyType||(e.MetaPropertyType={})).PROFILE="profile",w.COMMON_PARAM="common_param",w.EVENT_PARAM="event_param",w.ITEM_PARAM="item_param",w.USER_TAG="user_tag",w.CDP_TAG="cdp_tag",w.COHORT="cohort",w.USER_PROFILE="user_profile",w.PARAM="param",w.CDP_COHORT="cdp_cohort",w.CUSTOM_PROPERTY_GROUP="custom_property_group",e.MetaPropertyComposeType=void 0,(O=e.MetaPropertyComposeType||(e.MetaPropertyComposeType={})).ORIGIN="origin",O.VIRTUAL="virtual",O.PROFILE="profile",O.ITEM="item";var P,L,x,S=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r._targetNode=t,r._options=n,r.exposeFunction("onCohortCreate",r._options.onCohortCreate),r}return n(t,e),t.prototype.setTitle=function(e){var t;null===(t=this._remote)||void 0===t||t.setTitle(e)},t.prototype.getViewPath=function(){var e=this._options,t=e.cohortType,n=e.cohortId;return null==n?"/embed-user-cohort/edit-cohort/".concat(t):"/embed-user-cohort/edit-cohort/".concat(t,"/").concat(n)},t.prototype.getViewSearchParams=function(){return null},t}(function(){function e(e,t){var n;this._targetNode=e,this._options=t,this._createIframe(),(null===(n=this._iframeElement)||void 0===n?void 0:n.contentWindow)&&(this._endpoint=_.exports.windowEndpoint(this._iframeElement.contentWindow),this._remote=_.exports.wrap(this._endpoint)),this.exposeFunction("onReady",this._options.onReady)}return e.prototype.destroy=function(){var e;null===(e=this._iframeElement)||void 0===e||e.remove()},Object.defineProperty(e.prototype,"iframe",{get:function(){return this._iframeElement},enumerable:!1,configurable:!0}),e.prototype.exposeFunction=function(e,t){var n;t&&_.exports.expose(_.exports.proxy(((n={})[e]=t,n)),this._endpoint)},e.prototype._createIframe=function(){var e=this._options.iframeAttrs,t=void 0===e?c:e,n=document.createElement("iframe");Object.assign(n,r({src:this._getIFrameURL()},t)),this._targetNode.appendChild(n),this._iframeElement=n},e.prototype._getIFrameURL=function(){var e=this._options,t=e.basePath,n=void 0===t?"/datafinder":t,o=e.appId,a=e.dorToken,i=e.from,c=e.customSearchParams,u=e.customRequestHeaders,l=r(r({dorToken:a,from:i,crh:u?JSON.stringify(u):void 0},this.getViewSearchParams()),c);return[this._getIFrameOrigin(),n,"/app/".concat(o),this.getViewPath(),"?".concat(s(l))].join("")},e.prototype._getIFrameOrigin=function(){var e=this._options.customDomain;return e||""},e}());!function(e){e.SINGLETON="singleton",e.PARALLEL="parallel"}(P||(P={})),function(e){e.AND="and",e.OR="or"}(L||(L={}));var M=new Uint8Array(16);function D(){if(!x&&!(x="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return x(M)}var U=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function k(e){return"string"==typeof e&&U.test(e)}for(var j=[],F=0;F<256;++F)j.push((F+256).toString(16).substr(1));function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(j[e[t+0]]+j[e[t+1]]+j[e[t+2]]+j[e[t+3]]+"-"+j[e[t+4]]+j[e[t+5]]+"-"+j[e[t+6]]+j[e[t+7]]+"-"+j[e[t+8]]+j[e[t+9]]+"-"+j[e[t+10]]+j[e[t+11]]+j[e[t+12]]+j[e[t+13]]+j[e[t+14]]+j[e[t+15]]).toLowerCase();if(!k(n))throw TypeError("Stringified UUID is invalid");return n}function H(e,t,n){function r(e,r,o,a){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=function(e){if(!k(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var i=new Uint8Array(16+e.length);if(i.set(r),i.set(e,r.length),(i=n(i))[6]=15&i[6]|t,i[8]=63&i[8]|128,o){a=a||0;for(var c=0;c<16;++c)o[a+c]=i[c];return o}return V(i)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function G(e){return 14+(e+64>>>9<<4)+1}function W(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function B(e,t,n,r,o,a){return W((i=W(W(t,e),W(r,a)))<<(c=o)|i>>>32-c,n);var i,c}function Y(e,t,n,r,o,a,i){return B(t&n|~t&r,e,t,o,a,i)}function q(e,t,n,r,o,a,i){return B(t&r|n&~r,e,t,o,a,i)}function z(e,t,n,r,o,a,i){return B(t^n^r,e,t,o,a,i)}function Q(e,t,n,r,o,a,i){return B(n^(t|~r),e,t,o,a,i)}function J(e,t,n){var r=(e=e||{}).random||(e.rng||D)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return V(r)}function X(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function $(e,t){return e<<t|e>>>32-t}H("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var a=e[o>>5]>>>o%32&255,i=parseInt(r.charAt(a>>>4&15)+r.charAt(15&a),16);t.push(i)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[G(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,a=271733878,i=0;i<e.length;i+=16){var c=n,s=r,u=o,l=a;n=Y(n,r,o,a,e[i],7,-680876936),a=Y(a,n,r,o,e[i+1],12,-389564586),o=Y(o,a,n,r,e[i+2],17,606105819),r=Y(r,o,a,n,e[i+3],22,-1044525330),n=Y(n,r,o,a,e[i+4],7,-176418897),a=Y(a,n,r,o,e[i+5],12,1200080426),o=Y(o,a,n,r,e[i+6],17,-1473231341),r=Y(r,o,a,n,e[i+7],22,-45705983),n=Y(n,r,o,a,e[i+8],7,1770035416),a=Y(a,n,r,o,e[i+9],12,-1958414417),o=Y(o,a,n,r,e[i+10],17,-42063),r=Y(r,o,a,n,e[i+11],22,-1990404162),n=Y(n,r,o,a,e[i+12],7,1804603682),a=Y(a,n,r,o,e[i+13],12,-40341101),o=Y(o,a,n,r,e[i+14],17,-1502002290),n=q(n,r=Y(r,o,a,n,e[i+15],22,1236535329),o,a,e[i+1],5,-165796510),a=q(a,n,r,o,e[i+6],9,-1069501632),o=q(o,a,n,r,e[i+11],14,643717713),r=q(r,o,a,n,e[i],20,-373897302),n=q(n,r,o,a,e[i+5],5,-701558691),a=q(a,n,r,o,e[i+10],9,38016083),o=q(o,a,n,r,e[i+15],14,-660478335),r=q(r,o,a,n,e[i+4],20,-405537848),n=q(n,r,o,a,e[i+9],5,568446438),a=q(a,n,r,o,e[i+14],9,-1019803690),o=q(o,a,n,r,e[i+3],14,-187363961),r=q(r,o,a,n,e[i+8],20,1163531501),n=q(n,r,o,a,e[i+13],5,-1444681467),a=q(a,n,r,o,e[i+2],9,-51403784),o=q(o,a,n,r,e[i+7],14,1735328473),n=z(n,r=q(r,o,a,n,e[i+12],20,-1926607734),o,a,e[i+5],4,-378558),a=z(a,n,r,o,e[i+8],11,-2022574463),o=z(o,a,n,r,e[i+11],16,1839030562),r=z(r,o,a,n,e[i+14],23,-35309556),n=z(n,r,o,a,e[i+1],4,-1530992060),a=z(a,n,r,o,e[i+4],11,1272893353),o=z(o,a,n,r,e[i+7],16,-155497632),r=z(r,o,a,n,e[i+10],23,-1094730640),n=z(n,r,o,a,e[i+13],4,681279174),a=z(a,n,r,o,e[i],11,-358537222),o=z(o,a,n,r,e[i+3],16,-722521979),r=z(r,o,a,n,e[i+6],23,76029189),n=z(n,r,o,a,e[i+9],4,-640364487),a=z(a,n,r,o,e[i+12],11,-421815835),o=z(o,a,n,r,e[i+15],16,530742520),n=Q(n,r=z(r,o,a,n,e[i+2],23,-995338651),o,a,e[i],6,-198630844),a=Q(a,n,r,o,e[i+7],10,1126891415),o=Q(o,a,n,r,e[i+14],15,-1416354905),r=Q(r,o,a,n,e[i+5],21,-57434055),n=Q(n,r,o,a,e[i+12],6,1700485571),a=Q(a,n,r,o,e[i+3],10,-1894986606),o=Q(o,a,n,r,e[i+10],15,-1051523),r=Q(r,o,a,n,e[i+1],21,-2054922799),n=Q(n,r,o,a,e[i+8],6,1873313359),a=Q(a,n,r,o,e[i+15],10,-30611744),o=Q(o,a,n,r,e[i+6],15,-1560198380),r=Q(r,o,a,n,e[i+13],21,1309151649),n=Q(n,r,o,a,e[i+4],6,-145523070),a=Q(a,n,r,o,e[i+11],10,-1120210379),o=Q(o,a,n,r,e[i+2],15,718787259),r=Q(r,o,a,n,e[i+9],21,-343485551),n=W(n,c),r=W(r,s),o=W(o,u),a=W(a,l)}return[n,r,o,a]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(G(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),H("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,i=Math.ceil(a/16),c=new Array(i),s=0;s<i;++s){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*s+4*l]<<24|e[64*s+4*l+1]<<16|e[64*s+4*l+2]<<8|e[64*s+4*l+3];c[s]=u}c[i-1][14]=8*(e.length-1)/Math.pow(2,32),c[i-1][14]=Math.floor(c[i-1][14]),c[i-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<i;++d){for(var p=new Uint32Array(80),f=0;f<16;++f)p[f]=c[d][f];for(var v=16;v<80;++v)p[v]=$(p[v-3]^p[v-8]^p[v-14]^p[v-16],1);for(var h=n[0],m=n[1],_=n[2],y=n[3],g=n[4],E=0;E<80;++E){var T=Math.floor(E/20),b=$(h,5)+X(T,m,_,y)+g+t[T]+p[E]>>>0;g=y,y=_,_=$(m,30)>>>0,m=h,h=b}n[0]=n[0]+h>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+g>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));var K={render:f,getFinderIFrameURL:v,ExtensionClient:h,ExtensionContainer:m,PostDataType:e.PostDataType};e.CohortEditor=S,e.EventAnalysisController=N,e.ExtensionClient=h,e.ExtensionContainer=m,e.FunnelAnalysisController=R,e.RetentionAnalysisController=C,e.default=K,e.generateFunnelQueryEvents=function(e){return e.map((function(e,t){var n;return{label:"".concat(t+1),type:P.SINGLETON,uuid:J(),events:[{label:"".concat(t+1),label_alias:e.eventName,uuid:J(),data_archive_id:e.dataArchiveId,event:{event_name:e.eventName,show_name:e.showName,event_type:e.eventType,data_archive_id:e.dataArchiveId},conditions:{logic:L.AND,conditions:(null===(n=e.paramFilters)||void 0===n?void 0:n.map((function(t){var n,r=t.operation||"=";return{logic:L.OR,uuid:J(),data_archive_id:e.dataArchiveId,conditions:[{uuid:J(),filter:{property_type:t.propertyType,property_compose_type:t.propertyComposeType,name:t.name,data_archive_id:e.dataArchiveId},operation:{label:r,value:r},operationValues:null===(n=t.propertyValues)||void 0===n?void 0:n.map((function(e){return{value:e,label:e}}))}]}})))||[]}}]}}))},e.getFinderIFrameURL=v,e.handleAnalysis=p,e.handleRetentionAnalysis=function(e,t){var n=e.resultId,r=e.reportId,o=d(e);return n?"".concat(t,"/result/").concat(n,"?").concat(l(o)):r?"".concat(t,"/").concat(r,"?").concat(l(o)):t},e.render=f,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=index.js.map