GithubHelp home page GithubHelp logo

replayio / chromium Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chromium/chromium

19.0 19.0 4.0 28.57 GB

The official GitHub mirror of the Chromium source

Home Page: https://chromium.googlesource.com/chromium/src/

License: BSD 3-Clause "New" or "Revised" License

chromium's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

chromium's Issues

Pass devtools e2e tests

We can run the record/replay devtools against chromium builds now, and should get as many of the existing tests to pass as possible. For now we won't be dealing with source maps or DOM inspection, but other tests should work. Some tests might need alternate versions for chromium though as e.g. stepping behavior differs between chromium and gecko.

"Command exception Pause.getAllFrames SecurityError: Blocked a frame with origin"

Seeing this in the logs for recording 63960e1f-6cf8-4e1d-9d7e-80ad227be54d

[18:53:28.908Z] error UnhandledError {"controlId":"5e5fb0b6-444a-4268-8772-b1ea45909c43","processId":17,"threadId":1,"linkerTime":55.307,"line":"Error: Command exception Pause.getAllFrames SecurityError: Blocked a frame with origin \"https://tag.idsync.analytics.yahoo.com\" from accessing a cross-origin frame."}

Sounds like something in there needs a try-catch, or that our JS code isn't running with enough permissions to access everything on the page.

Report console messages to driver

Console messages are reported via different paths from console errors and need to be handled separately. Ideally we could use the CDP for this, though attempts so far to use its events haven't worked.

Support getters

We should ensure that we're showing getters in object previews

Unable to create recordings with playwright

I'm struggling to create recordings with chromium on linux. The browser launches fine and the playwright tests pass but no recordings are created. After adding RECORD_REPLAY_VERBOSE, I see the error "Can't find directory for saving recordings." but it's unclear to me why the driver would be reporting that

script

const playwright = require("playwright");
const { getExecutablePath } = require("@replayio/playwright");

(async () => {
        const browser = await playwright.chromium.launch({
                headless: true,
                executablePath: getExecutablePath("chromium"),
                env: {
                        RECORD_ALL_CONTENT: 1,
                        RECORD_REPLAY_METADATA: JSON.stringify({
                                title: "Take screenshot of replay.io"
                        })
                },
        });
        const page = await browser.newPage();
        await page.goto("https://replay.io");
        await page.screenshot({ path: "replay.png" });

        await page.close();
        await browser.close();
})();

output

ubuntu@ip-172-31-15-249:~/ryan/pw-chromium$ RECORD_REPLAY_DIRECTORY=/home/ubuntu/ryan/replay  RECORD_REPLAY_VERBOSE=1 DEBUG="pw:browser" node ./test.js
  pw:browser <launching> /home/ubuntu/ryan/replay/playwright/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-hwPIQn --remote-debugging-pipe --no-startup-window +0ms
  pw:browser <launched> pid=3819835 +8ms
  pw:browser [pid=3819835][err] [0422/164514.829814:ERROR:gl_implementation.cc(394)] Failed to load /home/ubuntu/ryan/replay/playwright/chrome-linux/swiftshader/libGLESv2.so: /home/ubuntu/ryan/replay/playwright/chrome-linux/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory +122ms
  pw:browser [pid=3819835][err] [0422/164514.834619:ERROR:viz_main_impl.cc(161)] Exiting GPU process due to errors during initialization +4ms
  pw:browser [pid=3819835][err] [0422/164514.849218:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is disabled +14ms
  pw:browser [pid=3819835][err] Can't find directory for saving recordings. +84ms
  pw:browser [pid=3819835][err] [0422/164523.354520:WARNING:audio_manager_linux.cc(69)] Falling back to ALSA for audio output. PulseAudio is not available or could not be initialized. +8s
  pw:browser [pid=3819835] <gracefully close start> +2s
  pw:browser [pid=3819835] <process did exit: exitCode=0, signal=null> +37ms
  pw:browser [pid=3819835] starting temporary directories cleanup +0ms
  pw:browser [pid=3819835] finished temporary directories cleanup +4ms
  pw:browser [pid=3819835] <gracefully close end> +1ms
ubuntu@ip-172-31-15-249:~/ryan/pw-chromium$ echo $HOME
/home/ubuntu
ubuntu@ip-172-31-15-249:~/ryan/pw-chromium$ RECORD_REPLAY_VERBOSE=1 DEBUG="pw:browser" node ./test.js
  pw:browser <launching> /home/ubuntu/.replay/playwright/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-Wx3tQH --remote-debugging-pipe --no-startup-window +0ms
  pw:browser <launched> pid=3820395 +7ms
  pw:browser [pid=3820395][err] [0422/164620.240253:ERROR:gl_implementation.cc(394)] Failed to load /home/ubuntu/.replay/playwright/chrome-linux/swiftshader/libGLESv2.so: /home/ubuntu/.replay/playwright/chrome-linux/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory +107ms
  pw:browser [pid=3820395][err] [0422/164620.244077:ERROR:viz_main_impl.cc(161)] Exiting GPU process due to errors during initialization +3ms
  pw:browser [pid=3820395][err] [0422/164620.250838:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is disabled +6ms
  pw:browser [pid=3820395][err] Can't find directory for saving recordings. +91ms
  pw:browser [pid=3820395][err] [0422/164628.031185:WARNING:audio_manager_linux.cc(69)] Falling back to ALSA for audio output. PulseAudio is not available or could not be initialized. +8s
  pw:browser [pid=3820395] <gracefully close start> +2s
  pw:browser [pid=3820395] <process did exit: exitCode=0, signal=null> +38ms
  pw:browser [pid=3820395] starting temporary directories cleanup +1ms
  pw:browser [pid=3820395] finished temporary directories cleanup +4ms
  pw:browser [pid=3820395] <gracefully close end> +0ms
ubuntu@ip-172-31-15-249:~/ryan/pw-chromium$ 

Support command callbacks using CDP

In the node port we have some JS code that handles commands from the driver by synchronously running commands over the CDP. We should port this over to chromium because it's nice and clean and having two identical implementations will make it easier to keep this stuff in sync over time.

Render graphics while replaying

We need to render the tab's graphics when replaying in order to send them to the driver and then on to clients looking at the recording. I've looked around at how compositing works in chromium (both looking at the code and documentation, http://dev.chromium.org/developers/design-documents/gpu-accelerated-compositing-in-chrome is a good resource). The renderer process (aka content process in gecko) renders the tab's state down to a sequence of CompositorFrame structures which are sent to a dedicated GPU process via IPC. This architecture is the same AFAICT whether hardware acceleration is enabled or not. The only difference when not using hardware acceleration is that a software layer, SwiftShader (https://github.com/google/swiftshader), is used to handle graphics layer calls instead of the GPU. I think this will work out well, as we can use the regular hardware compositor in the GPU process when recording, and have an in process compositor using SwiftShader to render in the replaying process. This should even work on WebGL, which we don't support at all on gecko.

Support recording real websites

So far we've only been able to record/replay our simple e2e test pages with chromium, which have a small amount of text and nothing else. Before we can start using our test infrastructure to exercise a variety of real websites, we need to actually be able to replay those sites when running the backend locally.

After a few days of work we're now able to record whatsmyuseragent.com, which isn't a super impressive site but does have a lot more going on than our e2e pages.

Screen Shot 2021-04-05 at 8 07 44 AM

This recording was created using playwright, which works on an unmodified chromium.

Next up are some static sites like npr.org and facebook.com, and then going through our existing playwright test harness to make sure they can all replay at least once.

Support WebGL

Recording pages with WebGL contexts is running into some problems where synchronous communication with the GPU process causes the main thread to fail to finish the recording. This could be fixed, but there are likely to be other problems using WebGL and for now we are disabling it, similarly to gecko-dev (replayio/gecko-dev#58).

Rebase

Our chromium fork is based on a three month old chromium revision. While we didn't rebase before starting on the port a couple weeks ago, now that things are ready to start testing on real websites it's a good time to rebase across upstream changes.

Upload source maps

Gecko uploads source map info via the protocol for any source maps it comes across while recording. At some point we'll want to do the same thing for chromium as well, though this might not be an important issue for automated testing if we use https://github.com/RecordReplay/backend/issues/1526 to separately upload source maps.

Linux port

Right now chromium recording only works on macOS. We're mainly interested in linux --- it's what we'll need for a cloud recorder, and will be more popular for automated testing than macOS --- and since we can deal with some sophisticated sites now (e.g. we can record the facebook news feed, see #13) it's a good time to switch gears and start focusing on linux.

error: undefined symbol: logging::CheckError::~CheckError()

hi i am try to build this chromium on mac. but found some errors can not compiled

ld64.lld: error: undefined symbol: logging::CheckError::~CheckError()

referenced by obj/chrome/chrome_helper_app_default_executable/chrome_exe_main_mac.o

can you give me some suggestions thanks

Support DOM requests

Commands to inspect the DOM need to be supported in order to use the elements panel with chromium recordings.

Support separate inspector sessions

Playwright partially works with recording processes, but breaks when trying to actually interact with the page. The problem is that we create a separate V8Inspector to allow the driver to inspect the process state, but this conflicts with the V8Inspector that is always created in renderer (aka content) processes. V8 only allows one inspector per thread, and inspector methods get confused and fail when playwright is trying to send the process CDP commands. This can be fixed by attaching a separate session to the existing V8Inspector.

Support Target.getHTMLSource

We need to support this command in order to show the original HTML when viewing recordings in the devtools. I don't see existing hooks for getting this via the CDP, but we can modify the HTML parser to notify V8 about new HTML content and report the final files from there, like we do in gecko.

Explicitly hang onto garbage collected objects whose finalizers can trigger mismatches

GCs occur at different points when recording vs. replaying, and collect different sets of objects. This is a problem when finalizers for those objects interact with the recording --- accessing ordered locks and so forth. Eventually we want a system that can cope with this robustly, but for now we want to prevent these finalizers from running. Currently we do that by never doing major GCs. This mostly works, but we're seeing a lot of OOM and scavenger related crashes. It should be less invasive to chrome/v8's behavior and much more efficient in memory usage to allow GCs to happen normally, but have a list of all the objects with problematic finalizers which we can mark at the start of GCs and prevent them from being collected. This is how we deal with this problem in gecko.

Getting multiple sources with same sourceId

For recording 63960e1f-6cf8-4e1d-9d7e-80ad227be54d we are seeing errors in our logs about duplicate sources. Looks like it used build linux-chromium-20210504-255662444 and linker-linux-4972-8aa48c2a.

I added some logging to our sapling initial scan to log any sources with sourceId: "60" since that was the one showing up as a duplicate, and I'm getting two separate sources in the replay output:

{
    id: '60',
    kind: 'inlineScript',
    text: `!function(n){var r={};function o(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}o.m=n,o.c=r,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=3)}([function(t,e,n){"use strict";var r=function(t){var e=document.createElement("iframe");return e.width=e.height=e.frameBorder=0,e.body||e.appendChild(document.createElement("body")),e.head||e.appendChild(document.createElement("head")),t&&(e.src=t),document.body.appendChild(e),e};e.a={createIframe:r,createIframeWithCSP:function(t,e){var a=r(),n=-1<window.navigator.userAgent.toLowerCase().indexOf("firefox")?500:0;setTimeout(function(){!function(t,e){var n=a.contentWindow.document,r=n.createElement("meta");r.httpEquiv="Content-Security-Policy",r.content="default-src 'self'; img-src ".concat(e.join(" "));var o=n.head;n.head||(o=n.createElement("head"),n.appendChild(o)),o.appendChild(r)}(0,t),e(a.contentWindow.document)},n)}}},function(t,e,n){"use strict";e.a={firePixels:function(t,e){for(var n=0;n<t.length;n++)r=t[n].url,a=void 0,(a=(o=e).createElement("img")).width=0,a.height=0,a.src=r,o.body.appendChild(a);var r,o,a}}},function(t,e,n){"use strict";e.a={firingLimit:5,storageKey:"_vm_datax_pixels",commonCspDomains:["*.yahoo.com"],pixels:[{id:"BLKAI",url:"https://cms.analytics.yahoo.com/cms?partner_id=BLKAI&orig=ono",cspDomains:"tags.bluekai.com",frequency:336},{id:"ADOBE",url:"https://cms.analytics.yahoo.com/cms?partner_id=ADOBE&orig=ono",cspDomains:"dpm.demdex.net",frequency:336},{id:"VISPP",url:"https://cms.analytics.yahoo.com/vzn?partner_id=VISPP&orig=ono",cspDomains:"auth.svcs.verizon.com:* pixel.claro.com.br idsyncmxedge.com idsync.claro.com.co idsyncapp.claro.com.ar",frequency:1},{id:"NEUAR",url:"https://cms.analytics.yahoo.com/cms?partner_id=NEUAR&orig=ono",cspDomains:"*.agkn.com",frequency:336},{id:"AUDPR",url:"https://cms.analytics.yahoo.com/cms?partner_id=AUDPR&orig=ono",cspDomains:"audex.userreport.com",frequency:336},{id:"SEMAS",url:"https://cms.analytics.yahoo.com/cms?partner_id=SEMAS&orig=ono&sInitiator=external",cspDomains:"*.semasio.net",frequency:336}]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(4),o=n(5),a=n(6),i=n(8);Object(r.a)(function(t,e){e&&(!t.gdprApplies||t.vendor&&t.vendor.consents&&t.vendor.consents[25])&&(Object(a.a)(),Object(i.a)(),Object(o.a)())})},function(t,e,n){"use strict";n.d(e,"a",function(){return r});var r=function(n){if(!window.__tcfapi){if(window===window.top)return void n({msg:"API not found"},!1);i=function(t){for(var e,n=window;n;){try{if(n.frames.__tcfapiLocator){e=n;break}}catch(t){}if(n===window.top)break;n=n.parent}return e}(),c={},window.__tcfapi=function(t,e,n,r){if(i){var o=Math.random()+"",a={__tcfapiCall:{command:t,parameter:r,version:e,callId:o}};c[o]=n,i.postMessage(a,"*")}else n({msg:"CMP not found"},!1)},window.addEventListener("message",function(t){!function(t,e,n){var r={};try{r="string"==typeof t.data?JSON.parse(t.data):t.data}catch(t){}var o=r.__tcfapiReturn;o&&"function"==typeof n[o.callId]&&(n[o.callId](o.returnValue,o.success),n[o.callId]=null)}(t,0,c)},!1)}var i,c;window.__tcfapi("addEventListener",2,function(t,e){e&&"error"!==t.cmpStatus?"tcloaded"!==t.eventStatus&&"useractioncomplete"!==t.eventStatus||n(t,!0):n(void 0,!1)})}},function(t,e,n){"use strict";var o=n(0),a=n(1),i=n(2);function c(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var s=Math.round(Date.now()/1e3/60/60),u=function(){try{return JSON.parse(window.localStorage.getItem(i.a.storageKey))||{}}catch(t){return{}}};e.a=function(){var r=function(){for(var t=i.a.pixels,e=u(),n=[],r=0;r<t.length;r++){var o=t[r];if(!o||n.length>=i.a.firingLimit)break;var a=e[o.id]||0;s-a>o.frequency&&n.push(o)}return n}();if(r.length){var t=[].concat(c(i.a.commonCspDomains),c(r.map(function(t){return t.cspDomains})));o.a.createIframeWithCSP(t,function(t){a.a.firePixels(r,t);for(var e=u(),n=0;n<r.length;n++)e[r[n].id]=s;!function(t){try{window.localStorage.setItem(i.a.storageKey,JSON.stringify(t))}catch(t){}}(e)})}}},function(t,e,n){"use strict";var r=n(0),o=n(7);e.a=function(){var t=o.a.parse(document.location.search.slice(1));if("4"!==t.id){var e=decodeURIComponent(t.referrer||document.location.href);r.a.createIframe("https://tag.idsync.analytics.yahoo.com/sp-frame.html?referrer=".concat(escape(e)))}}},function(t,e,n){"use strict";e.a={parse:function(t){if(!t)return{};var e='{"'+decodeURI(t).replace(/"/g,'\\\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}',n={};try{n=JSON.parse(e)}catch(t){}return n}}},function(t,e,n){"use strict";var c=n(9),o=n(0),a=n(1),s=n(10),u=n(2);function i(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var f=null;e.a=function(){var t,e;t=new RegExp("APID=[^;]+"),e=document.cookie.match(t),f=null!==e?e[0].split("=")[1]:null;var n=function(){for(var t=new Date("January 1, 2011 00:00:00").getTime()/1e3,e=(new Date).getTime()/1e3,n=parseInt((e-t)/60/60),r=s.a.pixels,o=[],a=0;a<r.length;a++){var i=r[a];if(!i||o.length>=u.a.firingLimit)break;n-c.a.getLastSyncTime(i.id)>i.frequency&&(i.fireWithApid&&f&&(i.url=i.url.replace("{{APID}}",f),o.push(i)),i.fireWithApid||f||o.push(i))}return o}();if(n.length){var r=[].concat(i(s.a.commonCspDomains),i(n.map(function(t){return t.cspDomains})));o.a.createIframeWithCSP(r,function(t){a.a.firePixels(n,t);for(var e=0;e<n.length;e++)c.a.resetLastSyncTime(n[e].id);!function(t){for(var e=[],n=0;n<t.length;n++)e.push("pixelId"+t[n].id+"=0");(new Image).src="https://ups.analytics.yahoo.com/ups/log?"+e.join("&")}(n)})}}},function(t,e,n){"use strict";var m,d=function(){var t=new Date("January 1, 2011 00:00:00 GMT").getTime()/1e3,e=(new Date).getTime()/1e3;return parseInt((e-t)/60/60)},r=function(){var t=function(t){return parseInt(t,36)};m={};var e=new RegExp("IDSYNC=[^;]+"),n=document.cookie.match(e),r=n?n[0]:null;if(r){for(var o=(r=r.split("=")[1].replace(/"/g,"")).split(":"),a={},i=null,c=0;c<o.length;c++){var s=t((i=o[c].split("~"))[0]),u=t(i[1]);if(void 0!==s){var f=d();u=f<u?f:u,a[s]=u}}m=a}return m};r(),e.a={getLastSyncTime:function(t){return m[t]||0},resetLastSyncTime:function(t){var e=d();m[t]=e;var n=window.location.hostname,r=(new Date).getTime()+31536e6,o=n.indexOf("advertising");o<0&&(o=n.indexOf("analytics.yahoo.com"));var a="."+n.substring(o),i="IDSYNC="+function(t){var e=function(t){return parseInt(t).toString(36)},n=[];for(var r in t)/\\d+/.test(r)?n.push(e(r)+"~"+e(t[r])):n.push(r+"~"+e(t[r]));return n.join(":")}(m)+"; expires="+new Date(r).toUTCString()+"; path=/; domain="+a+"; SameSite=None; Secure";document.cookie=i},loadCookieData:r}},function(t,e,n){"use strict";e.a={firingLimit:5,commonCspDomains:["pixel.advertising.com","ups.analytics.yahoo.com"],pixels:[{id:"55357",url:"https://cms.analytics.yahoo.com/cms?partner_id=AOL&apid={{APID}}&orig=ono",cspDomains:"cms.analytics.yahoo.com",frequency:168,fireWithApid:!0},{id:"55357",url:"https://cms.analytics.yahoo.com/cms?partner_id=AOL&orig=ono&redir=true",cspDomains:"cms.analytics.yahoo.com",frequency:168,fireWithApid:!1}]}}])`,
    url: 'https://opus.analytics.yahoo.com/tag/opus-frame.html?id=4'
  }

and

{
    id: '60',
    kind: 'scriptSource',
    text: `!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("wafer",[],t):"object"==typeof exports?exports.wafer=t():e.wafer=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="https://s.yimg.com/aaq/wf/",t(t.s="./src/entry.js")}({"./src/entry.js":function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function u(e){return Array.isArray(e)?e:Array.from(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var m={};n.d(m,"localStorage",function(){return y}),n.d(m,"visibilityMeta",function(){return p}),n.d(m,"transformProperty",function(){return g}),n.d(m,"mutationObserver",function(){return b}),n.d(m,"nativeLazyLoadingSupported",function(){return _}),n.d(m,"isSlowBrowser",function(){return E}),n.d(m,"performanceMarkSupported",function(){return T}),n.d(m,"isTouchSafariDevice",function(){return k}),n.d(m,"smoothScroll",function(){return C});var w={};n.d(w,"isVisible",function(){return J}),n.d(w,"debounce",function(){return q}),n.d(w,"elementInView",function(){return $}),n.d(w,"throttle",function(){return G}),n.d(w,"bindEvent",function(){return Q}),n.d(w,"unbindEvent",function(){return Z}),n.d(w,"get",function(){return ee}),n.d(w,"loadScriptAsync",function(){return te}),n.d(w,"loadCSSSync",function(){return ne}),n.d(w,"each",function(){return re}),n.d(w,"findAncestor",function(){return ie}),n.d(w,"fireBeacon",function(){return oe}),n.d(w,"isNodeName",function(){return ae}),n.d(w,"parseUrl",function(){return se}),n.d(w,"getElementsByAttrValues",function(){return ce}),n.d(w,"convertNodeListToArray",function(){return ue}),n.d(w,"clearAndSetInnerHTML",function(){return le}),n.d(w,"getConfigFromJSONScriptNode",function(){return fe}),n.d(w,"getTemplateContent",function(){return de}),n.d(w,"getWaferInstanceForElem",function(){return ve}),n.d(w,"urlify",function(){return he}),n.d(w,"fetchWithCache",function(){return me}),n.d(w,"removeCookie",function(){return we}),n.d(w,"setCookie",function(){return ye}),n.d(w,"getCookie",function(){return pe}),n.d(w,"clearAllTimeout",function(){return ge}),n.d(w,"clearTimeout",function(){return be}),n.d(w,"clearTimeoutForInstance",function(){return _e}),n.d(w,"setTimeout",function(){return Ee});var y=function(){try{return window.localStorage.setItem("test","test"),window.localStorage.removeItem("test"),!0}catch(e){return!1}}(),p=function(){var e=void 0,t=void 0;return void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),{hidden:e,visibilityChange:t}}(),g=function(){return"string"==typeof document.documentElement.style.transform?"transform":"WebkitTransform"}(),b=function(){for(var e=["WebKit","Moz","O","Ms",""],t=0;t<e.length;t++)if(e[t]+"MutationObserver"in window)return!0;return!1}(),_=function(){return"loading"in HTMLImageElement.prototype}(),E=function(){var e=void 0;return new Promise(function(t){if(void 0!==e)return t(e);var n=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(n){var r=n.effectiveType;if("slow-2g"===r||"2g"===r)return e=!0,t(!0),!0}if(!("storage"in navigator&&"estimate"in navigator.storage))return t(!1);navigator.storage.estimate().then(function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.usage,i=n.quota;return Math.round(r/i*100)>=70?(e=!0,t(!0)):t(!1)}).catch(function(){return t(!1)})})}(),T=function(){var e=window,t=e.performance;return t&&"clearMarks"in t}(),k=function(){return"ontouchstart"in window&&/Safari/i.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)}(),C=function(){var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}return e}(),S=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},O=["rid","crumb","subscrumb"],A={omit:1,"same-origin":1,include:1},L=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments[1];return e.replace(new RegExp("[?&]"+t+"=[^&#]*(#.*)?$"),"$1").replace(new RegExp("([?&])"+t+"=[^&]*&"),"$1")},x=function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")},j=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.body,r=t.cache,i=void 0===r?1:r,o=t.cacheKey,a=t.cacheStrategy,s=void 0===a?"networkFirst":a,c=t.cacheTtl,u=void 0===c?60:c,l=t.clientHeaders,f=void 0===l?{}:l,d=t.credentials,v=void 0===d?"same-origin":d,h=t.importance,m=t.method,w=void 0===m?"GET":m,y=t.mode,p=t.paramsToNotCache,g=void 0===p?{}:p,b=t.retries,_=t.timeout,E=void 0===_?6e3:_,T=t.useRid,k=void 0===T||T;return new Promise(function(t,r){var a=Date.now(),c=x(g),l=-1===e.indexOf("?")?"?":"&",d=c?e+l+c:e;o||(o=e,O.forEach(function(e){o=L(o,e)})),v||A[v]||(v="same-origin");var m=i,p=!1,_=void 0,T=void 0,C=!1;if(n)try{n=JSON.stringify(JSON.parse(n)),w="GET"===w?"POST":w,m=!1}catch(e){n={}}var j=setTimeout(function(){if(p=!0,_)return void t(Object.assign({},_,{_fetchMeta:{duration:Date.now()-a,source:"CACHE_IS_STALE"}}));r(new Error("Request timed out"))},E);T=m&&window.wafer.db&&"cacheFirst"===s?window.wafer.db.get(o,"fetch",{timeout:1e3}).then(function(e){if(e){var n=e.ttl,r=e.value,i=e.cachedTime,o=(Date.now()-i)/1e3;try{_=JSON.parse(r)}catch(e){}o<n&&(clearTimeout(j),p||(C=!0,t(Object.assign({},_,{_fetchMeta:{duration:Date.now()-a,source:"CACHE"}}))))}}).catch(function(e){}):Promise.resolve(!1),T.then(function(){if(!C){var e=new Headers,i=window.wafer.base,s=i.adLiteConfig,c=void 0===s?{}:s,g=i.fetchHeaders,T=i.rid,O=c||{},A=O.adLite,L=O.subscrumb;for(var x in g)g.hasOwnProperty(x)&&e.append(x,g[x]);k&&T&&-1===d.indexOf("rid=")&&(d+=l+"rid="+T),A&&L&&"cors"!==y&&(d+=l+"adLite="+A+l+"subscrumb="+encodeURIComponent(L));for(var D in f)f.hasOwnProperty(D)&&e.append(D,f[D]);"POST"!==w&&"PUT"!==w&&"DELETE"!==w||e.append("Content-Type","application/json"),b&&"cors"!==y&&e.append("x-wf-retry-count",b);var P={credentials:v,headers:e,method:w};y&&(P.mode=y),n&&(P.body=n),h&&(P.importance=h),fetch(d,P).then(function(e){if(clearTimeout(j),!p){var n=e.status;if(n>=200&&n<=299&&("PUT"===w||"DELETE"===w)){var r={duration:Date.now()-a,source:"NETWORK_WITHOUT_CACHE"};return void e.json().then(function(e){t(S({},e,{_fetchMeta:r}))}).catch(function(){t({_fetchMeta:r})})}if(200===n){var i=e.headers.get("Content-Type");if(m&&window.wafer.db&&u&&i&&i.match(/application\\/json/i)){var s=Date.now();e.clone().text().then(function(e){return window.wafer.db.set({ttl:u,key:o,value:e,cachedTime:s},"fetch",{timeout:E}).catch(function(e){}),!0})}return e.json().then(function(e){if(Object(e)!==e)throw new Error("Malformed response");t(Object.assign({},e,{_fetchMeta:{duration:Date.now()-a,source:m?_?"NETWORK_AS_CACHE_IS_EXPIRED":"NETWORK":"NETWORK_WITHOUT_CACHE"}}))}).catch(function(e){throw new Error("Malformed response")})}if(204===n)throw m=!1,_=null,new Error("No Content");if("no-cors"===y&&0===n)return t(Object.assign({html:""},{_fetchMeta:{duration:Date.now()-a,source:m?_?"NETWORK_AS_CACHE_IS_EXPIRED":"NETWORK":"NETWORK_WITHOUT_CACHE"}})),!0;throw new Error(404===n?"Not found":"Malformed response")}}).catch(function(e){if(!p)if(clearTimeout(j),_)t(Object.assign({},_,{_fetchMeta:{duration:Date.now()-a,source:"CACHE_IS_STALE"}}));else if(m){if(!window.wafer.db)return void r(e);window.wafer.db.get(o,"fetch",{timeout:E}).then(function(n){if(!n)return void r(e);var i=n.ttl,o=n.value,s=n.cachedTime,c=(Date.now()-s)/1e3;try{_=JSON.parse(o)}catch(e){}t(Object.assign({},_,{_fetchMeta:{duration:Date.now()-a,source:c<i?"CACHE_SECOND_ATTEMPT":"CACHE_SECOND_ATTEMPT_STALE"}}))}).catch(function(e){r(e)})}else r(e)})}})}).then(function(e){var t=e.assets,n=void 0===t?{}:t,r=n.css,i=void 0===r?[]:r;return i?Promise.all(i.map(function(e){var t=e.value;return window.wafer.base._loadAsset(t,"css")})).then(function(){return e}):e})},D=function(e){return"string"==typeof e&&e},P=/;\\s/g,I=/([^=]+)=/i,M=function(e){if(D(e)){var t=new Date(0).toUTCString();window.document.cookie=e+"=''; expires="+t}},R=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.expires,i=n.domain,o=n.path;if(D(e)){var a=e+"="+t;r&&r instanceof Date&&(a+="; expires="+r.toUTCString()),i&&D(i)&&(a+="; domain="+i),o&&D(o)&&(a+="; path="+o),window.document.cookie=a}},N=function(e){if(!D(e))return null;var t=null;return e=e.trim(),window.document.cookie.split(P).some(function(n){var r=void 0,i=void 0,o=n.match(I);if(Array.isArray(o))try{r=decodeURIComponent(o[1]),i=decodeURIComponent(n.substring(r.length+1))}catch(e){}return r===e&&(t=i.trim(),!0)}),t},W=this,B=function(){var e=new Map;return{setTimeout:function(e){function t(t,n,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(t,n,r){var i=r||W;if(!i)return setTimeout(t,n);e.has(i)||e.set(i,new Map);var o=setTimeout(function(){var n=Array.prototype.slice.call(arguments);e.get(i).delete(o),t.apply(this,n)},n);return e.get(i).set(o,o),o}),clearAllTimeout:function(){if(e&&e.size){var t=!0,n=!1,r=void 0;try{for(var i,o=e.values()[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value,s=!0,c=!1,u=void 0;try{for(var l,f=a.values()[Symbol.iterator]();!(s=(l=f.next()).done);s=!0){var d=l.value;clearTimeout(d)}}catch(e){c=!0,u=e}finally{try{!s&&f.return&&f.return()}finally{if(c)throw u}}}}catch(e){n=!0,r=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw r}}e.clear()}},clearTimeoutForInstance:function(t){var n=e.get(t);if(n&&n.size){var r=!0,i=!1,o=void 0;try{for(var a,s=n[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var c=a.value;clearTimeout(c)}}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}e.get(t).clear()}},clearTimeout:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(t,n){var r=n||W,i=e.get(r);if(!i)return void clearTimeout(t);var o=i.get(t);clearTimeout(o),e.get(r).delete(t)})}}(),H=B.clearAllTimeout,z=B.clearTimeout,V=B.clearTimeoutForInstance,U=B.setTimeout,K=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.offsetX,i=void 0===r?0:r,o=n.offsetY,a=void 0===o?0:o;return e.right+i>=t.left&&e.bottom+a>=t.top&&e.left-i<=t.right&&e.top-a<=t.bottom},Y=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},F=function e(t,n,r,i){if(r.hasAttribute(t)){var o=r.getAttribute(t);i[o]&&i[o].push(r)}var a=r.children;if(!a)return i;for(var s=a.length;s--;)e(t,n,a[s],i);return i},X=function(e){if(!e)return e;if("content"in document.createElement("template"))return e;var t=e.childNodes,n=void 0;if(t.length){n=document.createElement("div");for(var r=0;r<t.length;r++)n.appendChild(t[r].cloneNode(!0));window.wafer.base.destroy(e),e.innerHTML=""}else n=e;return n},J=Y,q=function(e,t,n){var r=void 0;return function(){for(var i=arguments.length,o=Array(i),a=0;a<i;a++)o[a]=arguments[a];window.clearTimeout(r),r=window.setTimeout(function(){e.apply(n,o)},t)}},$=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.containerClass,r=t.offsetX,i=void 0===r?0:r,o=t.offsetY,a=void 0===o?0:o,s=arguments[2];if(!Y(e))return!1;if(n&&Element.prototype.closest){var c=e.closest(n);if(c){var u=c.getBoundingClientRect();if(K(u,s)){var l=u.bottom+a,f=u.left-i,d=u.right+i,v=u.top-a,h={top:v>s.top?v:s.top,right:d<s.right?d:s.right,bottom:l<s.bottom?l:s.bottom,left:f>s.left?f:s.left},m=e.getBoundingClientRect();return K(m,h)}return!1}}var w=e.getBoundingClientRect();return K(w,s,{offsetX:i,offsetY:a})},G=function(e,t,n){var r=0;return function(){for(var i=arguments.length,o=Array(i),a=0;a<i;a++)o[a]=arguments[a];var s=+new Date;s-r<t||(r=s,e.apply(n,o))}},Q=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.passive,o=void 0===i||i;k&&"click"===t&&(e.style.cursor="pointer"),e.addEventListener(t,n,{capture:!1,passive:o})},Z=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.passive,o=void 0===i||i;e.removeEventListener(t,n,{capture:!1,passive:o})},ee=function(e,t){return t.reduce(function(e,t){return e&&e[t]?e[t]:null},e)},te=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.src,r=t.type,i=t.text,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},a=arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(a&&ee(window,a.split(".")))return void o();if("text/javascript"!==(r=r||"text/javascript"))return void o(new Error("can load only script of type text/javascript"));var c=document.createElement("script");c.type=r,n?(c.src=n,c.async=!0,c.defer=!0,c.readyState?c.onreadystatechange=function(){"loaded"!==c.readyState&&"complete"!==c.readyState||(c.onreadystatechange=null,o(null,c))}:c.onload=function(){o(null,c)},c.onerror=function(){s<=2?e({src:n,type:r,text:i},o,a,++s):o(new Error("could not load script"))}):(c.textContent="try{"+i+"}catch(e){window.console && window.console.error(e);}",o(null,c)),document.getElementsByTagName("head")[0].appendChild(c)},ne=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.src,r=t.text,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=document.getElementsByTagName("head")[0];if(r){var s=document.createElement("style");s.type="text/css",s.styleSheet?s.styleSheet.cssText=r:s.appendChild(document.createTextNode(r)),a.appendChild(s),i()}else{var c=document.createElement("link");c.rel="stylesheet",c.href=n,a.appendChild(c),c.addEventListener("load",function(){i()}),c.addEventListener("error",function(){o<=2?e({src:n,text:r},i,++o):i()})}},re=function(e,t){if(e&&t)for(var n=e.length,r=0;r<n&&!1!==t(e[r],r);r++);},ie=function(e,t){for(;e&&!e.classList.contains(t);)e=e.parentElement;return e},oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.useNavigator,r=void 0===n||n,i=t.useTimestamp,o=void 0===i||i,a=!1;if(r)if(window.navigator&&"function"==typeof window.navigator.sendBeacon)try{window.navigator.sendBeacon(e)||(a=!0)}catch(e){a=!0}else a=!0;else a=!0;if(a){var s=new Image;Q(s,"error",function(){s=null}),Q(s,"load",function(){s=null}),Q(s,"abort",function(){s=null}),s.src=o?e+(-1===e.indexOf("?")?"?":"&")+(new Date).getTime():e}},ae=function(e,t){return e.nodeName.toLowerCase()===t},se=function(e){if(!(e=e?e.split("?")[0]:"")||"/"===e.charAt(0))return{host:"undefined"!=typeof window?window.location.host:"",pathname:e||""};var t=e.split("/");return{host:t[2],pathname:"/"+t.slice(3).join("/")}},ce=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:document.body;if(!Array.isArray(t))return{};var r={};return t.forEach(function(e){r[e]=[]}),F(e,t,n,r),r},ue=function(e){for(var t,n=[],r=0;t=e[r];++r)n.push(t);return n},le=function(e,t){e.innerHTML="",e.innerHTML=t},fe=function(e){if(!e)return{};var t={};try{t=JSON.parse(e.textContent)}catch(e){}return t},de=function(e){var t=X(e),n=t.innerHTML;if(n)return n;for(var r="",i=t.childNodes,o=0;o<i.length;o++)r+=i[o].outerHTML;return r},ve=function(e,t){var n=window.wafer.wafers[t];if(!n)return null;var r=void 0;return r=!0===n.__esModule?n.default._state:n._state,r.elementInstances.get(e)},he=x,me=j,we=M,ye=R,pe=N,ge=H,be=z,_e=V,Ee=U,Te=Object.freeze({ATTR_PREFIX:"data-wf-",DISPLAY_BLOCK:"block",DISPLAY_NONE:"none",WAFER_DESTROYED:"wafer-destroyed"}),ke=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ce=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),Se=function(){function e(){r(this,e)}return Ce(e,[{key:"init",value:function(){this._util={listeners:{}}}},{key:"emit",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this._util.listeners;n&&n[e]&&setTimeout(function(){n[e].forEach(function(n){n.call(void 0,ke({type:e},t))})},0)}},{key:"on",value:function(e,t){var n=this._util.listeners;n&&t&&e&&(n[e]||(n[e]=[]),n[e].push(t))}},{key:"removeListener",value:function(e,t){var n=this._util.listeners;if(n&&n[e]){var r=n[e].indexOf(t);r>-1&&n[e].splice(r,1)}}},{key:"destroy",value:function(){this._util.listeners=null}}]),e}(),Oe=Se,Ae=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),Le=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.name,r=void 0===n?"wafer":n,o=t.version,a=void 0===o?1:o,s=t.tables,c=void 0===s?["fetch"]:s,u=t.cb,l=void 0===u?function(){}:u;i(this,e),this._utils={cb:l,connection:null,db:null,name:r,startTime:Date.now(),tables:c};var f=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;f&&r&&a&&(this._utils.connection=f.open(r,a),this.addEventListener())}return Ae(e,[{key:"addEventListener",value:function(){var e=this,t=this._utils,n=t.cb,r=t.connection,i=t.startTime,o=t.tables;r.onsuccess=function(t){var r=t.target.result,a=!0;o.some(function(e){return!r.objectStoreNames.contains(e)&&(a=!1,!0)}),a&&(e._utils.db=r,n("success",{duration:Date.now()-i}))},r.onerror=function(t){e._utils.db=null,n("error",{duration:Date.now()-i})},r.onupgradeneeded=function(t){var r=t.target.result;o.forEach(function(e){r.createObjectStore(e,{keyPath:"key"}).createIndex("key",["cachedTime","key","ttl"])}),t.target.transaction.oncomplete=function(){e._utils.db=r,n("success",{duration:Date.now()-i})}}}},{key:"get",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=r.timeout,o=void 0===i?1e3:i,a=this._utils.db;return new Promise(function(r,i){if(!a)return void i(new Error("Connection missing"));if(!t)return void i(new Error("Table missing"));var s=!1,c=setTimeout(function(){s=!0,i(new Error("Cache lookup timed out"))},o);if(!a.objectStoreNames.contains(t))return clearTimeout(c),void i(new Error("Store does not exist : "+t));var u=void 0;try{u=n._utils.db.transaction(t,"readonly")}catch(e){return clearTimeout(c),void i(e)}u.onerror=function(e){clearTimeout(c),s||i(e)},u.onabort=function(e){clearTimeout(c),s||i(e)};var l=u.objectStore(t);if(!l)return clearTimeout(c),void i(new Error("store doesn't exist for table : "+t));var f=l.get(e);f.onsuccess=function(e){if(clearTimeout(c),!s){var t=e.target.result;r(t)}},f.onerror=function(e){clearTimeout(c),s||i(e)}})}},{key:"set",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=r.timeout,o=void 0===i?1e3:i,a=this._utils,s=a.cb,c=a.db;return new Promise(function(r,i){if(!c)return void i(new Error("Connection missing"));if(!t)return void i(new Error("Table missing"));var a=!1,u=setTimeout(function(){a=!0,i(new Error("Cache write timed out"))},o);if(!c.objectStoreNames.contains(t))return clearTimeout(u),s("error",{action:"deleting db",message:"Store does not exist : "+t}),n.deleteDB().catch(function(){}),void i(new Error("Store does not exist : "+t));var l=void 0;try{l=n._utils.db.transaction(t,"readwrite")}catch(e){return clearTimeout(u),e instanceof DOMException&&(s("error",{action:"deleting db",message:e.message}),n.deleteDB().catch(function(){})),void i(e)}l.onerror=function(e){clearTimeout(u),a||i(e)},l.onabort=function(e){clearTimeout(u),a||i(e)};var f=l.objectStore(t);if(!f)return clearTimeout(u),void i(new Error("store doesn't exist for table : "+t));var d=f.put(e);d.onsuccess=function(e){if(clearTimeout(u),!a){var t=e.target.result;r(t)}},d.onerror=function(e){clearTimeout(u),a||i(e)}})}},{key:"delete",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=r.timeout,o=void 0===i?1e3:i,a=this._utils.db;return new Promise(function(r,i){if(!a)return void i(new Error("Connection missing"));if(!t)return void i(new Error("Table missing"));var s=!1,c=setTimeout(function(){s=!0,i(new Error("Cache delete timed out"))},o);if(!a.objectStoreNames.contains(t))return clearTimeout(c),void i(new Error("Store does not exist : "+t));var u=void 0;try{u=n._utils.db.transaction(t,"readwrite")}catch(e){return clearTimeout(c),void i(e)}u.onerror=function(e){clearTimeout(c),s||i(e)},u.onabort=function(e){clearTimeout(c),s||i(e)};var l=u.objectStore(t);if(!l)return clearTimeout(c),void i(new Error("store doesn't exist for table : "+t));var f=l.delete(e);f.onsuccess=function(e){if(clearTimeout(c),!s){var t=e.target.result;r(t)}},f.onerror=function(e){clearTimeout(c),s||i(e)}})}},{key:"clean",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.timeout,i=void 0===r?1e4:r,o=n.timeDiffToDelete,a=void 0===o?864e5:o,s=this._utils.db,c=Date.now();return new Promise(function(n,r){if(!s)return void r(new Error("Connection missing"));if(!e)return void r(new Error("Table missing"));var o=!1,u=setTimeout(function(){o=!0,r(new Error("Cache clean timed out"))},i);if(!s.objectStoreNames.contains(e))return clearTimeout(u),void r(new Error("Store does not exist : "+e));var l=void 0;try{l=t._utils.db.transaction(e,"readonly")}catch(e){return clearTimeout(u),void r(e)}l.onerror=function(e){clearTimeout(u),o||r(e)},l.onabort=function(e){clearTimeout(u),o||r(e)};var f=l.objectStore(e);if(!f)return clearTimeout(u),void r(new Error("store doesn't exist for table : "+e));var d=f.openCursor(),v=[];d.onsuccess=function(i){if(clearTimeout(u),!o){var s=i.target.result;if(s){var l=s.value.cachedTime;c-l>a&&v.push(t.delete(s.key,e)),s.continue()}else Promise.all(v).then(function(e){n(e)}).catch(function(e){r(e)})}},d.onerror=function(e){clearTimeout(u),o||r(e)}})}},{key:"deleteDB",value:function(){var e=this,t=this._utils.db,n=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;return new Promise(function(r,i){if(!n)return void i(new Error("Connection missing"));t&&(t.close(),e._utils.db=null);var o=e._utils.name,a=!1,s=setTimeout(function(){a=!0,i(new Error("Could not delete"))},1e3),c=n.deleteDatabase(o);c.onerror=function(e){clearTimeout(s),a||i(new Error("Could not delete"))},c.onsuccess=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};clearTimeout(s),a||r(e.result)}})}}]),e}(),xe=Le,je=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},De=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),Pe=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),Ie=/(wf-[a-z-]+)/,Me=function(e){if(document.attachEvent&&void 0!==document.attachEvent){var t=!1;document.attachEvent("onreadystatechange",function(){var n=document,r=n.readyState;"interactive"===r?(t=!0,setTimeout(e,0)):"complete"===r&&(!t&&setTimeout(e,0),t=!0)})}else"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e,{capture:!1,passive:!0}):setTimeout(e,0)},Re=function(){function e(){var t=this;a(this,e),this._viewport={top:0,left:0},this._state={},this._assetLoadedMapping=new Map,this._isPageVisible=!0,this._observerMapping={},this._saveViewportOffset(),this._updateState(),this._initHostConfig(),this._props={head:document.getElementsByTagName("head")[0]},this._handleVisibilityChange=this._handleVisibilityChange.bind(this),Me(function(){var e=!1;window.wafer&&window.wafer.utils&&(t._initDB(function(){e||(t.__executeAllRegisteredReadyFns(),e=!0)}),t._setup(),setTimeout(function(){e||(t.__executeAllRegisteredReadyFns(),e=!0)},20))})}return Pe(e,[{key:"addObserver",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};this._observerMapping[e]||(this._observerMapping[e]=[]),this._observerMapping[e].push(t)}},{key:"removeObserver",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};if(this._observerMapping[e]){var n=this._observerMapping[e].indexOf(t);this._observerMapping[e].splice(n,1)}}},{key:"sync",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this._sync)return void window.wafer.ready(function(){e.sync(t)});this._sync(t)}},{key:"syncWithStateUpdate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this._sync)return void window.wafer.ready(function(){e.syncWithStateUpdate(t)});this._sync(t);for(var n in this._observerMapping)this._observerMapping.hasOwnProperty(n)&&this._observerMapping[n].forEach(function(e){e({force:!0})})}},{key:"pauseVideo",value:function(e){this._handleVideoPlayPause("pause",e)}},{key:"resumeVideo",value:function(e){this._handleVideoPlayPause("resume",e)}},{key:"lock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._wafers.forEach(function(t){t.lock&&t.lock(e)})}},{key:"unlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._wafers.forEach(function(t){t.lock&&t.lock(e,!1)})}},{key:"syncUI",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._wafers.forEach(function(t){t._state&&t._state.mounted&&t.handleResize&&t.handleResize(e)})}},{key:"syncAssets",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.js,r=void 0===n?[]:n,i=t.blob,o=[],a=[],s=window.wafer.wafers,c=[];if(r.forEach(function(e){var t=e.value;if(-1!==t.indexOf("wf-")){var n=t.match(Ie),r=De(n,1),i=r[0];i=i.slice(0,-1).replace("wf-","wafer-"),"wafer-core"===i||s[i]||o.push(e)}else a.push(e)}),Array.isArray(i)&&i.length){var u=document.createElement("div"),l=window.wafer.utils.convertNodeListToArray,f=this._props.head;i.forEach(function(e){Object(e)===e&&(u.innerHTML+=e.value||"")}),c=l(u.querySelectorAll("script")),l(u.getElementsByTagName("style")).forEach(function(e){f.appendChild(e)})}var d=void 0;d=a.length?Promise.all(a.map(function(t){return e._loadAsset(t.value,"js")})).catch(function(){}):Promise.resolve(),d.then(function(){var e=window.wafer.utils.loadScriptAsync;c.forEach(function(t){var n=t.getAttribute("type")||"text/javascript",r=t.innerText;r&&"text/javascript"===n&&e({type:n,text:r})})}),o.map(function(t){return e._loadAsset(t.value,"js")})}},{key:"trigger",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e&&e.classList.add("wf-trigger-activated"),this._wafers.forEach(function(t){t._state&&t._state.mounted&&t.handleTrigger&&t.handleTrigger(e)})}},{key:"prefetch",value:function(e){this._wafers.forEach(function(t){var n=t&&t.configs;if(n){var r=n.allowPrefetch,i=n.selector;r&&i&&Array.prototype.slice.call(e.getElementsByClassName(i.replace(".",""))).forEach(function(e){return t.loadElement(e)})}});var t=window.wafer,n=t.features,r=t.utils,i=r.getElementsByAttrValues;n.nativeLazyLoadingSupported&&i("loading",["lazy"],e).lazy.forEach(function(e){e.setAttribute("loading","eager")})}},{key:"emitError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.elem,n=e.meta,r=e.name,i=e.stack;this._emit({elem:t,meta:n,name:r,stack:i})}},{key:"emitLog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.elem,n=e.meta,r=e.name;this._emit({elem:t,meta:n,name:r},"log")}},{key:"emitWaferEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.elem,r=t.meta;this._emit({elem:n,meta:r},e)}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.destroySelf,r=void 0===n||n,i=window.wafer.utils,o=i.unbindEvent;if(e){var a=e.children;if(a)for(var s=a.length;s--;)this.destroy(a[s])}else o(document,window.wafer.features.visibilityMeta.visibilityChange,this._handleVisibilityChange),o(window,"resize",this._handleResizeWithThrottle),o(window,"keydown",this._handleKeyDown),o(window,"scroll",this._handleScrollWithThrottle),o(document.body,"click",this._handleDelegatedEvent,{passive:!1}),o(document.body,"change",this._handleDelegatedEvent,{passive:!1}),i.clearAllTimeout(),this._ee.destroy();r&&this._wafers.forEach(function(t){t.destroy&&t.destroy(e)})}},{key:"clearOldCache",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.timeDiffToDelete,r=void 0===n?432e5:n;window.wafer.db&&window.wafer.db.clean("fetch",{timeDiffToDelete:r}).catch(function(t){e.emitError({meta:{},name:"clearOldCache",stack:t.stack})})}},{key:"_initDB",value:function(e){var t=this,n=document.getElementById("wafer-db-config"),r={};if(n)try{Object.assign(r,JSON.parse(n.textContent))}catch(e){this.emitError({meta:{},name:"initDb",stack:e.stack})}window.wafer.db=new xe(Object.assign({},r,{cb:function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(e(),n){case"success":t.emitLog({name:"IDB-connection-success",meta:r});break;case"error":t.emitError({name:"IDB",meta:r}),t.emitLog({name:"IDB-connection-error",meta:r})}}}))}},{key:"_initHostConfig",value:function(){var e=document.getElementById("wafer-config");if(e)try{var t=JSON.parse(e.textContent),n=t.assetsLoaded,r=void 0===n?{}:n,i=o(t,["assetsLoaded"]),a=window.YAHOO||{},s=a.context,c=void 0===s?{}:s,u=a.subscriptions,l=void 0===u?{}:u,f=c||{},d=f.rid,v=l||{},h=v.adLite,m=v.crumb;d&&(i.rid=d),h&&m&&(i.adLite=h,i.subscrumb=m);for(var w in r)r.hasOwnProperty(w)&&this._assetLoadedMapping.set(w,!0);Object.defineProperty(this,"_hostConfig",{value:i,writable:!1})}catch(e){this.emitError({meta:{},name:"initConfig",stack:e.stack})}}},{key:"_emit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error";this._ee&&this._ee.emit(t,e)}},{key:"_setup",value:function(){var e=this;if(!this._ee){var t=window.wafer,n=t.features,r=t.utils,i=r.bindEvent,o=r.throttle,a=n.isSlowBrowser;this._ee=new Oe,this._ee.init(),window.wafer.on=this._ee.on.bind(this._ee),window.wafer.removeListener=this._ee.removeListener.bind(this._ee),Object.defineProperty(window.wafer,"state",{configurable:!0,set:function(t){e.state=t}}),a.then(function(t){e.emitLog({name:"BrowserType",meta:{slow:t}})}).catch(function(){}),this._handleResizeWithThrottle=o(function(){return e._handleResize.call(e)},10,this),this._handleScrollWithThrottle=o(function(){return e._handleScroll.call(e)},10,this),this._handleDelegatedEvent=this._handleDelegatedEvent.bind(this),this._sync=o(function(t){e._wafers.forEach(function(e){e.sync&&e.sync(t)}),e._updateState(t)},0,this),this._saveViewportOffsetWithThrottle=o(function(){e._saveViewportOffset()},50,this),i(document,window.wafer.features.visibilityMeta.visibilityChange,this._handleVisibilityChange),i(window,"keydown",this._handleKeyDown),i(window,"resize",this._handleResizeWithThrottle),i(window,"scroll",this._handleScrollWithThrottle),i(document.body,"click",this._handleDelegatedEvent,{passive:!1}),i(document.body,"change",this._handleDelegatedEvent,{passive:!1})}}},{key:"_saveViewportOffset",value:function(){this._viewport.bottom=window.innerHeight||document.documentElement.clientHeight,this._viewport.right=window.innerWidth||document.documentElement.clientWidth}},{key:"_updateState",value:function(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,n=t.querySelectorAll("script.wafer-state"),r=0;e=n[r];++r){if(!e.classList){try{this.state=JSON.parse(e.textContent)}catch(e){}return}if(!e.classList.contains("state-added")){try{this.state=JSON.parse(e.textContent)}catch(t){e.classList.add("state-error")}e.classList.add("state-added")}}}},{key:"_handleResize",value:function(){this._saveViewportOffsetWithThrottle(),this._wafers.forEach(function(e){e._state&&e._state.mounted&&e.handleResize&&e.handleResize()})}},{key:"_handleVisibilityChange",value:function(){var e=!document[window.wafer.features.visibilityMeta.hidden];this._isPageVisible=e,this._ee.emit("pageVisibilityChange",{isActive:e}),this._wafers.forEach(function(t){t._state&&t._state.mounted&&t.handleVisibilityChange&&t.handleVisibilityChange(e)})}},{key:"_handleScroll",value:function(){var e={scrollX:window.scrollX||window.pageXOffset,scrollY:window.scrollY||window.pageYOffset};this._ee.emit("scroll",e),this._wafers.forEach(function(t){t._state&&t._state.mounted&&t.handleScroll&&t.handleScroll(e)})}},{key:"_loadAsset",value:function(e,t){var n=this,r=this._hostConfig||{},i=r.assetsLoadedHost,o=void 0===i?"s.yimg.com":i,a=r.assetsLoadedProtocol,s=void 0===a?"https://":a;return new Promise(function(r){if(n._assetLoadedMapping.get(e))return r();n._assetLoadedMapping.set(e,!0);var i=0===e.indexOf("/"),a=i?""+s+o+e:e;if("css"===t)return void window.wafer.utils.loadCSSSync({src:a},function(){r()});window.wafer.utils.loadScriptAsync({src:a},function(){r()})})}},{key:"_getElementComposedMap",value:function(e){for(var t=e,n=new Map;t;)n.set(t,!0),t=t.parentElement;return n}},{key:"_handleDelegatedEvent",value:function(e){var t=this,n=e.target;e.waferComposedMap=function(){var e=void 0;return function(){return e||(e=t._getElementComposedMap(n)),{get:function(t){return!e.get(document.body)||e.get(t)}}}}();var r=n;for(this._wafers.forEach(function(t){t._state&&t._state.mounted&&(t.handleEvent("clickOutside",r,e),r.classList.contains(t._options.selector.replace(".",""))&&t.handleEvent(e.type,r,e))}),r=r.parentElement;r;)this._wafers.forEach(function(t){t._state&&t._state.mounted&&r.classList.contains(t._options.selector.replace(".",""))&&t.handleEvent(e.type,r,e)}),r=r.parentElement}},{key:"_handleKeyDown",value:function(e){if(13===e.keyCode){var t=e.target;"button"===t.nodeName.toLowerCase()&&t.click()}}},{key:"_handleVideoPlayPause",value:function(e,t){var n=window.wafer.wafers["wafer-video"];n&&(!0===n.__esModule?n.default[e].call(n.default,t):n[e].call(n,t))}},{key:"viewport",get:function(){return this._viewport}},{key:"state",get:function(){return this._state},set:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var n in t)!function(n){if(t.hasOwnProperty(n)){var r=e._state[n];if(void 0===r){var i=e._observerMapping||{};Object.defineProperty(e._state,n,{configurable:!0,get:function(){return r},set:function(e){var t=i[n]||[];r=e,setTimeout(function(){for(var e=t.length-1;e>=0;e--)t[e]()},0)}})}Object(t[n])===t[n]?e._state[n]=je({},e._state[n],t[n]):e._state[n]=t[n]}}(n)}},{key:"isPageVisible",get:function(){return this._isPageVisible}},{key:"isIORetrySupported",get:function(){var e=this._hostConfig||{},t=e.retryIODisable;return!(void 0!==t&&t)}},{key:"fetchHeaders",get:function(){var e=this._hostConfig||{},t=e.fetchHeaders;return void 0===t?{}:t}},{key:"lang",get:function(){return(this._hostConfig||{}).lang}},{key:"rid",get:function(){return(this._hostConfig||{}).rid}},{key:"adLiteConfig",get:function(){var e=this._hostConfig||{};return{adLite:e.adLite,subscrumb:e.subscrumb}}},{key:"liveAriaRegion",get:function(){if(this._state){var e=this._state.liveRegionElem;if(this._state.liveRegionElem=e||document.querySelector('[aria-live="polite"]'),!this._state.liveRegionElem){var t=this._state.liveRegionElem=document.createElement("div");t.classList.add("Hidden"),t.setAttribute("aria-atomic","true"),t.setAttribute("aria-live","polite"),t.setAttribute("role","alert"),document.body.appendChild(t)}return this._state.liveRegionElem}}},{key:"_wafers",get:function(){return(window.wafer.wafers&&Object.keys(window.wafer.wafers)||[]).reduce(function(e,t){return!0===window.wafer.wafers[t].__esModule?(e.push(window.wafer.wafers[t].default),e):(e.push(window.wafer.wafers[t]),e)},[])}}]),e}(),Ne=Re,We="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Be=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),He=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),ze=/\\[([\\w\\.-]+)]/g,Ve=/\\[([\\w\\.-]+)]/g,Ue="wf-state-undefined",Ke="wf-state-reset",Ye=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.get;return e.replace(ze,function(e){e=e.slice(1,-1);var t=e.split("."),r=t.slice(1,t.length);return n(window.wafer.base.state,r)||Ue})},Fe=new Map([["focusin",{passive:!1}],["focusout",{passive:!1}],["keydown",{passive:!1}],["keyup",{passive:!1}],["focusin",{passive:!1}],["mousedown",{passive:!1}],["mouseup",{passive:!0}],["mouseleave",{passive:!1}],["mouseover",{passive:!1}],["mousemove",{passive:!0}],["mouseenter",{passive:!0}],["touchstart",{passive:!0}],["touchend",{passive:!0}],["touchmove",{passive:!1}],["drag",{passive:!1}],["dragenter",{passive:!1}],["dragleave",{passive:!1}],["dragover",{passive:!1}],["dragstart",{passive:!1}],["dragend",{passive:!1}],["drop",{passive:!1}]]),Xe=function(){function e(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.selector,o=arguments[2],a=o.STATE_ATTRS,s=o.DEFAULT_STATE_KEY_TO_UPDATE,c=void 0===s?"":s;l(this,e),this._util={elem:t,selector:i};var f=window.wafer,d=f.constants,v=f.utils,h=d.ATTR_PREFIX,m=void 0===h?"data-wf-":h,w=window.wafer.base,y=this.stateDidUpdate&&this.stateDidUpdate.bind(this),p=(t.getAttribute(m+"on")||"").split(":"),g=Be(p,3),b=g[0],_=void 0===b?"complete":b,E=g[1],T=void 0===E?"setState":E,k=g[2],C=void 0===k?c:k;_=_||"complete",C&&"complete"===_&&("setState"===T?this._util.shouldUpdateState=!0:"toggleState"===T&&(this._util.shouldToggleState=!0),this._util.stateKeysToUpdate=C.split(".")),y&&a.forEach(function(e){var r=t.getAttribute(m+"["+e+"]")||t.getAttribute(m+"state-"+e),i=t.getAttribute(""+m+e);if(r)for(var o=void 0;null!==(o=Ve.exec(r));){var a=o[1],s=a.split("."),c=u(s),l=c[0],f=c.slice(1);"state"===l&&function(){var t=n,o=Be(f,1),a=o[0],s=Ye(r,v);i||-1!==s.indexOf(Ue)||(n._util[e]=s);var c=function n(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=i.force,s=void 0!==o&&o;if(t._destroyed)return void w.removeObserver.call(w,a,n);var c=t._util[e];t._util[e]=Ye(r,v),-1!==t._util[e].indexOf(Ue)||!s&&c===t._util[e]?t._util[e]=c:-1===t._util[e].indexOf(Ke)&&y({stateAttr:e})};setTimeout(function(){c()},0),w.addObserver(a,c)}()}})}return He(e,[{key:"addEventListeners",value:function(){this._addEventListenerToEvents(window.wafer.utils.bindEvent,"bindEvent")}},{key:"removeEventListeners",value:function(){this._addEventListenerToEvents(window.wafer.utils.unbindEvent,"unbindEvent")}},{key:"_addEventListenerToEvents",value:function(e,t){var n=this,r=this._util.elem,i=this.constructor.events,o="bindEvent"===t;if(i){for(var a in i){(function(t){if(i.hasOwnProperty(t)){var a=function(){if(!Fe.has(t))return{v:"continue"};var a=i[t],s=Fe.get(t),u=!0,l=!1,f=void 0;try{for(var d,v=a[Symbol.iterator]();!(u=(d=v.next()).done);u=!0){var h=d.value,m=Be(h,2),w=m[0],y=m[1];!function(i,a){var u=void 0;(u="_self"===i?r:[].concat(c(r.getElementsByClassName(i))))&&n[a]&&(o&&(n[a]=n[a].bind(n)),Array.isArray(u)?u.forEach(function(r){e.call(n,r,t,n[a],s)}):e.call(n,u,t,n[a],s))}(w,y)}}catch(e){l=!0,f=e}finally{try{!u&&v.return&&v.return()}finally{if(l)throw f}}}();if("object"===(void 0===a?"undefined":We(a)))a.v}})(a)}}}},{key:"didComplete",value:function(e,t){var n=this._util,r=n.shouldToggleState,i=n.shouldUpdateState,o=n.stateKeysToUpdate;if(i){var a={};o.reduce(function(e,n,r){return e[n]=e[n]||{},r===o.length-1&&(e[n]=t),e[n]},a),window.wafer.base.state=a}else if(r){var c=u(o),l=c[0],f=c.slice(1),d=f.length;if(d){var v=window.wafer.base.state[l]||{};f.reduce(function(e,t,n){return e[t]=n===d-1?!e[t]:e[t]||{},e[t]},v),window.wafer.state=s({},l,v)}else window.wafer.state=s({},l,!window.wafer.base.state[l])}}},{key:"destroy",value:function(){var e=this._util,t=e.elem,n=e.selector;window.wafer.utils.clearTimeoutForInstance(this),t&&(n&&t.classList.remove(n.replace(".","")),t.classList.add("wafer-destroyed")),this._util={},this._state={},this._destroyed=!0}},{key:"lock",set:function(e){this._state=this._state||{},this._state.locked=e,e?this.didLock&&this.didLock():this.didUnLock&&this.didUnLock()}}]),e}(),Je=Xe,qe=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),$e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ge=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),Qe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.root,r=t.selector,i=t.props,o=void 0===i?{}:i,a=t.WaferClass;f(this,e),this._state={elementInstances:new Map,mounted:!1},this._options={props:o,root:n,selector:r,WaferClass:a},a&&a.events&&Object.keys(a.events).forEach(function(e){a.events[e]=new Map(a.events[e])})}return Ge(e,[{key:"handleResize",value:function(){var e=this._state.elementInstances,t=!0,n=!1,r=void 0;try{for(var i,o=e.values()[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value,s=a.instance,c=s.handleResize;!0!==(s._state||{}).locked&&c&&c.call(s)}}catch(e){n=!0,r=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw r}}}},{key:"handleEvent",value:function(e,t,n){var r=this._options.WaferClass,i=this._state.elementInstances;if("clickOutside"!==e){if(r&&r.events){var o=i.get(t);o&&this._handleEvent(e,n,o)}}else{var a=!0,s=!1,c=void 0;try{for(var u,l=i.values()[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var f=u.value,d=f.instance;if(d){var v=d.handleClickOutside;v&&v.call(d,n)}}}catch(e){s=!0,c=e}finally{try{!a&&l.return&&l.return()}finally{if(s)throw c}}}}},{key:"lock",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this._state.elementInstances,r=this._options,i=r.root,o=r.selector,a=r.successClass,s=[];o&&(s=Array.prototype.slice.call((e||i).getElementsByClassName(o.replace(".",""))).filter(function(e){return!e.classList.contains(a)})),s.length&&s.forEach(function(e){if(n.has(e)){var r=n.get(e),i=r.instance;i?i.lock=t:e.setAttribute("data-wf-lock",t?"1":"0")}})}},{key:"sync",value:function(e){var t=this._state.elementInstances,n=this._options,r=n.props,i=n.root,o=n.selector,a=n.successClass,s=n.WaferClass,c=[];o&&(c=Array.prototype.slice.call((e||i).getElementsByClassName(o.replace(".",""))).filter(function(e){return!e.classList.contains(a)}));var u=c.length;if(u){var l=this.willSync;l&&l.call(this,e),c.forEach(function(e){if(!t.has(e)){var n=void 0;if(s){n=new s(e,$e({},r,{selector:o}));var i=n.destroy;n.destroy=function(){t.delete(e);for(var r=arguments.length,o=Array(r),a=0;a<r;a++)o[a]=arguments[a];i.apply(n,o)}}t.set(e,{instance:n})}})}if(this.validate(e),u){var f=this.didSync;f&&f.call(this,e)}}},{key:"handleTrigger",value:function(e){var t=this._options,n=t.selector,r=t.successClass;if(e.classList.contains(n.replace(".",""))&&!e.classList.contains(r)){var i=this.willTrigger,o=this.trigger,a=this.didTrigger;i&&i.call(this,e),o&&this.trigger(e),a&&a.call(this,e)}}},{key:"validate",value:function(e){var t=this._state.elementInstances;if(0===t.size)return void this.destroy();var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t.entries()[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var c=a.value,u=qe(c,2),l=u[0],f=u[1],d=f.instance;if(d){!0!==(d._state||{}).locked&&n.push(l)}else n.push(l)}}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}if(n.length){var v=this.willValidate;v&&v.call(this,n)}this._state.mounted=!0}},{key:"destroy",value:function(e){var t=this.willDestroy,n=this.didDestroy;if(e){var r=this._state.elementInstances;if(r.has(e)){t&&t.call(this,e);var i=r.get(e),o=i.instance;o&&o.destroy(),r.delete(e),n&&n.call(this,e)}}else t&&t.call(this),this._destroyAll(),n&&n.call(this)}},{key:"_destroyAll",value:function(){var e=this._state,t=!0,n=!1,r=void 0;try{for(var i,o=e.elementInstances.values()[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value,s=a.instance;s&&s.destroy()}}catch(e){n=!0,r=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw r}}e.elementInstances.clear(),e.mounted=!1}},{key:"_handleEvent",value:function(e,t,n){var r=this._options.WaferClass,i=r.events[e];if(i)for(var o=t.target;o;)if(o.className){var a=void 0,s=!0,c=!1,u=void 0;try{for(var l,f=i.entries()[Symbol.iterator]();!(s=(l=f.next()).done);s=!0){var d=l.value,v=qe(d,2),h=v[0],m=v[1];if(o.classList.contains(h)){var w=n.instance,y=w&&w[m];t.eventTarget=o,y&&y(t),a=!0;break}}}catch(e){c=!0,u=e}finally{try{!s&&f.return&&f.return()}finally{if(c)throw u}}o=a?null:o.parentElement}else o=o.parentElement}}]),e}(),Ze=Qe,et=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),tt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nt=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),rt=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.containerClass,r=void 0===n?null:n,i=e.error,o=void 0!==i&&i,a=e.errorClass,s=void 0===a?"wafer-error":a,c=e.root,u=void 0===c?document:c,l=e.selector,f=e.src,h=void 0===f?"data-wf-src":f,m=e.success,w=void 0!==m&&m,y=e.successClass,p=void 0===y?"wafer-lazy-loaded":y,g=e.validateDelay,b=void 0===g?25:g;d(this,t);var _=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{root:u,selector:l})),E=window.wafer.utils.throttle;return _._options=tt({},_._options,{container:!!r&&u.getElementsByClassName(r),containerClass:r,error:o,errorClass:s,isRetina:window.devicePixelRatio>1,src:h,success:w,successClass:p}),_._validateWithThrottle=E(function(){_.validate()},b,_),_}return h(t,e),nt(t,[{key:"handleScroll",value:function(){this._validateWithThrottle()}},{key:"handleResize",value:function(){this._validateWithThrottle()}},{key:"willDestroy",value:function(){var e=this,t=this._options.container;if(t){var n=window.wafer.utils,r=n.each,i=n.unbindEvent;r(t,function(t){i(t,"scroll",e._validateWithThrottle)})}}},{key:"didSync",value:function(){var e=this,t=this._state,n=t.elementInstances,r=t.mounted;if(0!==n.size){var i=this._options,o=i.container,a=i.defaultOffsetY,s=void 0===a?100:a,c=i.defaultOffsetX,u=void 0===c?0:c,l=!0,f=!1,d=void 0;try{for(var v,h=n.entries()[Symbol.iterator]();!(l=(v=h.next()).done);l=!0){var m=v.value,w=et(m,2),y=w[0],p=w[1];p=void 0===p?{}:p;var g=p.offsetX,b=p.offsetY;if(void 0===g||void 0===b){var _=n.get(y),E=(y.getAttribute("data-wf-margin")||"").split(" "),T=et(E,2),k=T[0],C=T[1];_.offsetY=Number(k)||s,_.offsetX=Number(C)||u}}}catch(e){f=!0,d=e}finally{try{!l&&h.return&&h.return()}finally{if(f)throw d}}if(!r&&(this._state.mounted=!0,o)){var S=window.wafer.utils,O=S.bindEvent;(0,S.each)(o,function(t){O(t,"scroll",e._validateWithThrottle)})}}}},{key:"willValidate",value:function(){var e=this._state.elementInstances,t=window.wafer,n=t.base,r=t.features,i=t.utils,o=i.elementInView,a=this._options,s=r.nativeLazyLoadingSupported,c=!0,u=!1,l=void 0;try{for(var f,d=e.entries()[Symbol.iterator]();!(c=(f=d.next()).done);c=!0){var v=f.value,h=et(v,2),m=h[0],w=h[1];w=void 0===w?{}:w;var y=w.offsetX,p=w.offsetY;if(!parseInt(m.getAttribute("data-wf-lock"),10)){var g=m.getAttribute("data-wf-trigger")||"viewport",b=m.tagName.toLowerCase();"onLoad"===g?(this._load(m),e.delete(m)):s&&("img"===b||"picture"===b)&&this.nativeLazyLoadElement?(this.nativeLazyLoadElement(m),e.delete(m)):(o(m,tt({},a,{offsetX:y,offsetY:p}),n.viewport)||m.classList.contains(a.successClass))&&(this._load(m),e.delete(m))}}}catch(e){u=!0,l=e}finally{try{!c&&d.return&&d.return()}finally{if(u)throw l}}}},{key:"_shouldLoadElement",value:function(e){var t=this._options.successClass;return!e.classList.contains(t)}},{key:"_loadElement",value:function(e){var t=this,n=this._state.elementInstances,r=n.get(e),i=parseInt(e.getAttribute("data-wf-timeout"),10)||0;!0!==r.pending&&(i?setTimeout(function(){return t.loadElement(e)},i):this.loadElement(e),r.pending=!0)}},{key:"_load",value:function(e){var t=this;if(e&&void 0===e.length)this._loadElement(e);else{(0,window.wafer.utils.each)(e,function(e){t._loadElement(e)})}}},{key:"_itemLoaded",value:function(e){var t=this._options,n=t.src,r=t.selector,i=t.success,o=t.successClass;e.classList.remove(r.replace(".","")),e.classList.add(o),i&&i(e),e.removeAttribute(n)}}]),t}(Ze),it=rt,ot=function(){var e=[],t={};return{add:function(n,r,i){if("function"==typeof n&&(i=r,r=n,n=void 0),"function"==typeof r){if(n){if(t[n])return;t[n]=!0}if(window.wafer.on)return void r.call(i);e.push({scope:i,fn:r})}},executeAll:function(){e.forEach(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.fn,n=e.scope;t.call(n)}),e=[]}}}();n.d(t,"base",function(){return ct}),n.d(t,"controllers",function(){return ut}),n.d(t,"ready",function(){return st}),n.d(t,"constants",function(){return Te}),n.d(t,"features",function(){return m}),n.d(t,"utils",function(){return w}),n.d(t,"WaferBaseClass",function(){return Je});var at=ot.executeAll,st=ot.add,ct=new Ne;ct.__executeAllRegisteredReadyFns=at,ct.supportStateReset=!0;var ut={WaferBaseController:Ze,WaferLazyController:it}}})});`,
    url: 'https://s.yimg.com/aaq/wf/wf-core-1.45.1-modern.js'
  }

Is there maybe a race on whatever increments the sourceId or something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.