@liascript/exporter
Version:
A generic exporter for LiaScript
1 lines • 21.9 kB
JavaScript
!function(){function e(e,r,o,n){Object.defineProperty(e,r,{get:o,set:n,enumerable:!0,configurable:!0})}var r=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire55a5;r.register("kjbyJ",(function(o,n){e(o.exports,"Sync",(function(){return m}));var t=r("f1evb"),i=r("hnmIs"),a=r("9Klpk"),s=r("3bWnf"),c=r("eT7f3"),l=r("9WzNc"),d=r("div3d"),u=r("kb0qF"),p=r("bgoEC"),h=r("bWNdT"),f=r("32Euv"),v=r("auvHb"),y=r("48SmG"),g=r("733OA"),m=function(e){"use strict";(0,u.default)(o,e);var r=(0,h.default)(o);function o(){var e;return(0,a.default)(this,o),e=r.apply(this,arguments),(0,c.default)((0,t.default)(e),"syncFallbackTimer",null),e}return(0,s.default)(o,[{key:"destroy",value:function(){var e;null!==this.syncFallbackTimer&&(clearTimeout(this.syncFallbackTimer),this.syncFallbackTimer=null),(0,l.default)((0,d.default)(o.prototype),"destroy",this).call(this),null===(e=this.provider)||void 0===e||e.disconnect()}},{key:"connect",value:function(e){var r=this,n=this;return(0,i.default)((function(){var t,i,a,s;return(0,f.__generator)(this,(function(c){if((0,l.default)((0,d.default)(o.prototype),"connect",r).call(n,e),n.host=(null===(t=e.config)||void 0===t?void 0:t.host)||void 0,n.port=(null===(i=e.config)||void 0===i?void 0:i.port)?parseInt(e.config.port,10):void 0,n.peerPath=(null===(a=e.config)||void 0===a?void 0:a.path)||void 0,null===(s=e.config)||void 0===s?void 0:s.iceServers)try{n.iceServers=JSON.parse(e.config.iceServers)}catch(r){console.warn("PeerJS: invalid iceServers JSON, ignoring:",e.config.iceServers)}return window.Peer?n.init(!0):n.load(["//unpkg.com/peerjs@1.5.4/dist/peerjs.min.js"],n),[2]}))}))()}},{key:"init",value:function(e,r){var o=this,n=this.uniqueID();if(e&&window.Peer&&n)(function(e){return w.apply(this,arguments)})(n).then((function(e){var r={};o.host&&(r.host=o.host,r.secure=!0),void 0!==o.port&&(r.port=o.port),o.peerPath&&(r.path=o.peerPath),o.iceServers&&(r.config={iceServers:o.iceServers}),o.transport=new(0,y.PeerJSTransport)((0,p.default)({peer:window.Peer},Object.keys(r).length>0?{peerOptions:r}:{},o.password?{password:o.password}:{})),o.provider=new(0,g.GenericProvider)(o.db.doc,o.transport),o.db.setAwareness(o.provider.awareness);var n=!1,t=function(){n||(n=!0,null!==o.syncFallbackTimer&&(clearTimeout(o.syncFallbackTimer),o.syncFallbackTimer=null),o.sendConnect())};o.provider.on("synced",(function(e){console.log("PeerJS: document synchronized",e.synced),t()})),o.provider.on("status",(function(e){var r=e.state;console.log("PeerJS status: ".concat(r)),"connected"===r?o.syncFallbackTimer=setTimeout((function(){console.log("PeerJS: sync fallback, proceeding as first peer"),t()}),2e3):"disconnected"===r&&console.warn("PeerJS: disconnected")})),o.provider.pubsub.subscribe("*",(function(e,r){var n,t;null===(t=(n=o).onReceive)||void 0===t||t.call(n,r,e)})),o.provider.connect((0,p.default)({room:e},o.password?{password:o.password}:{}))}));else{var t="PeerJS unknown error";r?t="Could not load resource: "+r:window.Peer||(t="Could not load PeerJS library"),this.sendDisconnectError(t)}}},{key:"pubsubSend",value:function(e,r){var o;this.provider&&(this.provider.pubsub.publish(e,r),this.replyOnReceive&&(null===(o=this.onReceive)||void 0===o||o.call(this,e,r)))}}]),o}(v.Sync);function w(){return(w=(0,i.default)((function(e){var r,o;return(0,f.__generator)(this,(function(n){switch(n.label){case 0:return r=(new TextEncoder).encode(e),[4,crypto.subtle.digest("SHA-256",r)];case 1:return o=n.sent(),[2,Array.from(new Uint8Array(o)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")]}}))}))).apply(this,arguments)}})),r.register("48SmG",(function(o,n){e(o.exports,"PeerJSTransport",(function(){return u}));var t=r("hnmIs"),i=r("9Klpk"),a=r("3bWnf"),s=r("bgoEC"),c=r("5ENmm"),l=r("6Wo7Q"),d=r("32Euv"),u=function(){"use strict";function e(r){if((0,i.default)(this,e),this._connected=!1,this._room="",this.peer=null,this.peerId="",this.peers=new Map,this.knownPeers=new Set,this.isCoordinator=!1,this.coordinatorPeerId="",this.roomPeers=new Set,this.reElectionInProgress=!1,!r.peer)throw new Error('PeerJSTransport requires the "peer" option. Please provide the PeerJS constructor: import Peer from "peerjs"; new PeerJSTransport({ peer: Peer, ... })');var o,n,t,a;this.options={peer:r.peer,peerOptions:null!==(o=r.peerOptions)&&void 0!==o?o:{},password:null!==(n=r.password)&&void 0!==n?n:"",maxConns:null!==(t=r.maxConns)&&void 0!==t?t:20+Math.floor(15*Math.random()),debug:null!==(a=r.debug)&&void 0!==a&&a}}return(0,a.default)(e,[{key:"connect",value:function(e){var r=this;return(0,t.default)((function(){return(0,d.__generator)(this,(function(o){if(r._connected)throw new Error("Already connected");return r._room=e.room,r.coordinatorPeerId="yjs-coordinator-".concat(r._room),[2,new Promise((function(e,o){try{var n=new r.options.peer(r.coordinatorPeerId,(0,s.default)({debug:r.options.debug?3:0},r.options.peerOptions)),t=setTimeout((function(){n.destroy(),r.createRegularPeer(e,o)}),3e3);n.on("open",(function(o){clearTimeout(t),o===r.coordinatorPeerId&&(r.log("Coordinator: claimed ID"),r.peer=n,r.peerId=o,r.isCoordinator=!0,r.roomPeers.add(r.peerId),r._connected=!0,r.setupPeerDiscovery(),r.peer.on("connection",(function(e){r.handleIncomingConnection(e)})),e())})),n.on("error",(function(i){clearTimeout(t),i.message.includes("ID is taken")||i.message.includes("taken")||i.message.includes("already")||"unavailable-id"===i.type?(n.destroy(),r.createRegularPeer(e,o)):(r.log("❌ Unexpected error claiming coordinator:",i),n.destroy(),r.createRegularPeer(e,o))}))}catch(e){o(e)}}))]}))}))()}},{key:"createRegularPeer",value:function(e,r){var o=this,n=Math.random().toString(36).substring(7);this.peerId="yjs-".concat(this._room,"-").concat(n),this.peer=new this.options.peer(this.peerId,(0,s.default)({debug:this.options.debug?3:0},this.options.peerOptions)),this.peer.on("open",(function(r){o.peerId=r,o._connected=!0,o.setupPeerDiscovery(),o.peer.on("connection",(function(e){o.handleIncomingConnection(e)})),o.setupCrossBrowserDiscovery().then((function(){e()})).catch((function(r){o.log("⚠️ Cross-browser discovery failed, continuing with BroadcastChannel only:",r),e()}))})),this.peer.on("error",(function(e){o.log("Peer error:",e),o._connected||r(e)})),this.peer.on("disconnected",(function(){o.log("Peer disconnected, attempting reconnect...")}))}},{key:"disconnect",value:function(){if(this._connected){if(this.discoveryInterval&&(clearInterval(this.discoveryInterval),this.discoveryInterval=void 0),this.broadcastChannel&&(this.broadcastChannel.postMessage({type:"leave",peerId:this.peerId}),this.broadcastChannel.close(),this.broadcastChannel=void 0),this.coordinatorConn){try{this.sendCoordinationMessage(this.coordinatorConn,{type:"leave",peerId:this.peerId}),this.coordinatorConn.close()}catch(e){}this.coordinatorConn=void 0}if(this.isCoordinator){var e=!0,r=!1,o=void 0;try{for(var n,t=this.roomPeers[Symbol.iterator]();!(e=(n=t.next()).done);e=!0){var i=n.value;if(i!==this.peerId){var a=this.peers.get(i);if(a&&a.connected)try{this.sendCoordinationMessage(a.conn,{type:"coordinator-leaving",peerId:this.peerId})}catch(e){}}}}catch(e){r=!0,o=e}finally{try{e||null==t.return||t.return()}finally{if(r)throw o}}this.isCoordinator=!1,this.roomPeers.clear()}var s=!0,c=!1,l=void 0;try{for(var d,u=this.peers.values()[Symbol.iterator]();!(s=(d=u.next()).done);s=!0){var p=d.value;try{p.conn.close()}catch(e){}}}catch(e){c=!0,l=e}finally{try{s||null==u.return||u.return()}finally{if(c)throw l}}this.peers.clear(),this.knownPeers.clear(),this.reElectionInProgress=!1,this.peer&&(this.peer.destroy(),this.peer=null),this._connected=!1}}},{key:"onPeerConnect",value:function(e){var r=this;return this._peerConnectCallback=e,function(){r._peerConnectCallback=void 0}}},{key:"send",value:function(e){if(this._connected){var r=this.options.password?this.encrypt(e,this.options.password):e,o=!0,n=!1,t=void 0;try{for(var i,a=this.peers.values()[Symbol.iterator]();!(o=(i=a.next()).done);o=!0){var s=i.value;if(s.connected)try{s.conn.send(r)}catch(e){this.log("Error sending to peer:",s.peerId,e)}}}catch(e){n=!0,t=e}finally{try{o||null==a.return||a.return()}finally{if(n)throw t}}}else this.log("Not connected, cannot send")}},{key:"onMessage",value:function(e){var r=this;return this._callback=e,function(){r._callback=void 0}}},{key:"isConnected",get:function(){return this._connected}},{key:"connectedPeers",get:function(){return Array.from(this.peers.values()).filter((function(e){return e.connected})).length}},{key:"setupPeerDiscovery",value:function(){var e=this;if("undefined"!=typeof BroadcastChannel){var r="yjs-peerjs-".concat(this._room);this.broadcastChannel=new BroadcastChannel(r),this.broadcastChannel.onmessage=function(r){var o=r.data;o.peerId!==e.peerId&&("announce"===o.type?(e.knownPeers.add(o.peerId),e.connectToPeer(o.peerId)):"leave"===o.type&&(e.knownPeers.delete(o.peerId),e.removePeer(o.peerId)))},this.announcePeer(),this.discoveryInterval=setInterval((function(){e._connected&&e.peers.size<e.options.maxConns&&e.announcePeer()}),5e3)}else this.log("❌ BroadcastChannel not available in this browser")}},{key:"announcePeer",value:function(){if(this.broadcastChannel){var e={type:"announce",peerId:this.peerId};this.broadcastChannel.postMessage(e)}}},{key:"setupCrossBrowserDiscovery",value:function(){var e=this;return(0,t.default)((function(){return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,500)}))];case 1:return r.sent(),[2,new Promise((function(r,o){var n=!1,t=setTimeout((function(){if(!n){n=!0;var r=new Error("Timeout connecting to coordinator");e.log("⏱️ Timeout connecting to coordinator"),o(r)}}),5e3);try{var i=e.peer.connect(e.coordinatorPeerId,{reliable:!0,serialization:"binary",metadata:{role:"peer",peerId:e.peerId}});i.on("open",(function(){var o,a;if(!n){n=!0,clearTimeout(t),e.log("Connected to coordinator"),e.coordinatorConn=i;var s={conn:i,connected:!0,peerId:e.coordinatorPeerId};e.peers.set(e.coordinatorPeerId,s),e.knownPeers.add(e.coordinatorPeerId),null===(a=(o=e)._peerConnectCallback)||void 0===a||a.call(o,e.coordinatorPeerId),e.sendCoordinationMessage(i,{type:"join",peerId:e.peerId}),i.on("data",(function(r){var o=r instanceof Uint8Array?r:new Uint8Array(r),n=e.tryDecodeCoordinationMessage(o);if(n)e.handleCoordinatorMessage(n);else if(e._callback)try{var t=e.options.password?e.decrypt(o,e.options.password):o;e._callback(t)}catch(r){e.log("Error handling coordinator data:",r)}})),i.on("close",(function(){e.log("Coordinator disconnected"),e.peers.delete(e.coordinatorPeerId),e.knownPeers.delete(e.coordinatorPeerId),e.handleCoordinatorDisconnect()})),r()}})),i.on("error",(function(r){n||(n=!0,clearTimeout(t),e.log("❌ Failed to connect to coordinator:",r.message),o(r))}))}catch(r){n||(n=!0,clearTimeout(t),e.log("⚠️ Error connecting to coordinator:",r),o(r))}}))]}}))}))()}},{key:"becomeCoordinator",value:function(){var e=this;this.isCoordinator=!0,this.roomPeers.add(this.peerId),this.log("👑 I am now the coordinator. Room peers:",Array.from(this.roomPeers)),setInterval((function(){if(e.isCoordinator){var r=Array.from(e.roomPeers).sort();r.length>0&&r[0]!==e.peerId&&(e.log("⚠️ I am no longer the lowest ID peer, stepping down as coordinator"),e.isCoordinator=!1)}}),1e4)}},{key:"handleCoordinatorMessage",value:function(e){switch(e.type){case"peer-list":var r=!0,o=!1,n=void 0;try{for(var t,i=e.peers[Symbol.iterator]();!(r=(t=i.next()).done);r=!0){var a=t.value;a===this.peerId||this.peers.has(a)||(this.knownPeers.add(a),this.connectToPeer(a))}}catch(e){o=!0,n=e}finally{try{r||null==i.return||i.return()}finally{if(o)throw n}}break;case"peer-joined":e.peerId===this.peerId||this.peers.has(e.peerId)||(this.knownPeers.add(e.peerId),this.connectToPeer(e.peerId));break;case"peer-left":this.knownPeers.delete(e.peerId),this.removePeer(e.peerId);break;case"coordinator-change":this.coordinatorPeerId=e.coordinatorId;break;case"coordinator-leaving":this.log("Coordinator leaving, re-election starting"),this.handleCoordinatorDisconnect()}}},{key:"handleCoordinatorDisconnect",value:function(){var e=this;if(this.reElectionInProgress)this.log("⏭️ Re-election already in progress, skipping");else if("undefined"==typeof navigator||navigator.onLine){this.log("🗳️ Coordinator disconnected, starting re-election"),this.reElectionInProgress=!0,this.coordinatorConn=void 0;var r=[this.peerId].concat((0,l.default)(Array.from(this.knownPeers)),(0,l.default)(Array.from(this.peers.keys()))).filter((function(r){return r!==e.coordinatorPeerId}));r.sort();var o=r[0];this.log("🗳️ Coordinator election: Lowest peer ID is",o),o===this.peerId?(this.log("👑 I have the lowest ID, attempting to claim coordinator role"),this.transitionToCoordinator()):(this.log("⏳ Waiting for new coordinator:",o),setTimeout((function(){e.attemptCoordinatorConnection()}),2e3))}else{this.log("📴 Offline – deferring re-election until network returns");window.addEventListener("online",(function(){e.log("🌐 Network restored – resuming re-election"),e.handleCoordinatorDisconnect()}),{once:!0})}}},{key:"attemptCoordinatorConnection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=this;if(e>=5)return this.log("❌ Failed to connect to coordinator after",5,"attempts"),this.log("🔄 Attempting to become coordinator as fallback"),void this.transitionToCoordinator();this.log("🔌 Attempting to connect to coordinator (attempt ".concat(e+1,"/").concat(5,")")),this.setupCrossBrowserDiscovery().then((function(){r.log("✅ Successfully connected to new coordinator"),r.reElectionInProgress=!1})).catch((function(o){r.log("⚠️ Failed to connect to coordinator (attempt ".concat(e+1,"):"),o);var n=1e3*Math.pow(1.5,e);setTimeout((function(){r.attemptCoordinatorConnection(e+1)}),n)}))}},{key:"transitionToCoordinator",value:function(){var e=this;return(0,t.default)((function(){var r,o,n;return(0,d.__generator)(this,(function(t){switch(t.label){case 0:e.log("🔄 Transitioning to coordinator role..."),r=Array.from(e.peers.entries()),o=e._callback,e._room,e.peer&&e.peer.destroy(),e.peers.clear(),e._connected=!1,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise((function(n,t){var i=new e.options.peer(e.coordinatorPeerId,(0,s.default)({debug:e.options.debug?3:0},e.options.peerOptions)),a=setTimeout((function(){e.log("❌ Timeout claiming coordinator ID"),i.destroy(),t(new Error("Timeout claiming coordinator ID"))}),5e3);i.on("open",(function(t){if(clearTimeout(a),t===e.coordinatorPeerId){e.log("✅ Successfully claimed coordinator ID:",t),e.peer=i,e.peerId=t,e.isCoordinator=!0,e.roomPeers.clear(),e.roomPeers.add(e.peerId),e._connected=!0,e._callback=o,e.reElectionInProgress=!1,e.setupPeerDiscovery(),e.peer.on("connection",(function(r){e.handleIncomingConnection(r)})),e.log("🔗 Re-establishing connections with",r.length,"known peers");var s=!0,l=!1,d=void 0;try{for(var u,p=r[Symbol.iterator]();!(s=(u=p.next()).done);s=!0){var h=(0,c.default)(u.value,2),f=h[0];h[1];f!==e.coordinatorPeerId&&(e.knownPeers.add(f),e.roomPeers.add(f))}}catch(e){l=!0,d=e}finally{try{s||null==p.return||p.return()}finally{if(l)throw d}}n()}})),i.on("error",(function(r){clearTimeout(a),e.log("❌ Error claiming coordinator ID:",r),i.destroy(),t(r)}))}))];case 2:return t.sent(),[3,4];case 3:return n=t.sent(),e.log("❌ Failed to transition to coordinator:",n),e.reElectionInProgress=!1,e.log("🔄 Falling back to regular peer"),e.reestablishAsRegularPeer(),[3,4];case 4:return[2]}}))}))()}},{key:"reestablishAsRegularPeer",value:function(){var e=this,r=Math.random().toString(36).substring(7);this.peerId="yjs-".concat(this._room,"-").concat(r),this.isCoordinator=!1,this.peer=new this.options.peer(this.peerId,(0,s.default)({debug:this.options.debug?3:0},this.options.peerOptions)),this.peer.on("open",(function(r){e.peerId=r,e._connected=!0,e.log("✅ Reestablished as regular peer:",r),e.setupPeerDiscovery(),e.peer.on("connection",(function(r){e.handleIncomingConnection(r)})),e.peer.on("disconnected",(function(){e.log("Peer disconnected, attempting reconnect...")})),e.attemptCoordinatorConnection()})),this.peer.on("error",(function(r){e.log("❌ Error reestablishing as regular peer:",r);try{var o;null===(o=e.peer)||void 0===o||o.destroy()}catch(e){}e.peer=null,e._connected=!1;var n=function(){e.log("🌐 Network restored – retrying reestablish as regular peer"),e.reestablishAsRegularPeer()};"undefined"==typeof navigator||navigator.onLine?setTimeout(n,3e3):window.addEventListener("online",n,{once:!0})}))}},{key:"connectToPeer",value:function(e){if(e!==this.peerId&&!this.peers.has(e)&&!(this.peers.size>=this.options.maxConns||this.peerId&&this.peerId>e))try{var r=this.peer.connect(e,{reliable:!0,serialization:"binary"});if(!r)return void this.log("Failed to create connection object for:",e);this.setupConnection(r,e)}catch(r){this.log("Error connecting to peer:",e,r)}}},{key:"handleIncomingConnection",value:function(e){var r=this,o=e.peer;if(this.peers.has(o))e.close();else{if(this.peers.size>=this.options.maxConns)return this.log("Max connections reached, rejecting peer:",o),void e.close();this.isCoordinator&&(this.roomPeers.add(o),e.on("close",(function(){r.roomPeers.delete(o);var e=!0,n=!1,t=void 0;try{for(var i,a=r.roomPeers[Symbol.iterator]();!(e=(i=a.next()).done);e=!0){var s=i.value;if(s!==r.peerId){var c=r.peers.get(s);if(c&&c.connected)try{r.sendCoordinationMessage(c.conn,{type:"peer-left",peerId:o})}catch(e){r.log("⚠️ Failed to notify peer of departure:",s)}}}}catch(e){n=!0,t=e}finally{try{e||null==a.return||a.return()}finally{if(n)throw t}}}))),this.setupConnection(e,o)}}},{key:"setupConnection",value:function(e,r){var o=this,n={conn:e,connected:!1,peerId:r};this.peers.set(r,n),e.on("open",(function(){var e,t;n.connected=!0,o.knownPeers.add(r),null===(t=(e=o)._peerConnectCallback)||void 0===t||t.call(e,r)})),e.on("data",(function(n){var t=n instanceof Uint8Array?n:new Uint8Array(n),i=o.tryDecodeCoordinationMessage(t);if(i){if("coordinator-change"===i.type||"coordinator-leaving"===i.type||"peer-joined"===i.type||"peer-left"===i.type||"peer-list"===i.type)return void o.handleCoordinatorMessage(i);if("join"===i.type&&o.isCoordinator){var a=Array.from(o.roomPeers).filter((function(e){return e!==o.peerId&&e!==r}));o.sendCoordinationMessage(e,{type:"peer-list",peers:a});var s=!0,c=!1,l=void 0;try{for(var d,u=o.roomPeers[Symbol.iterator]();!(s=(d=u.next()).done);s=!0){var p=d.value;if(p!==o.peerId&&p!==r){var h=o.peers.get(p);if(h&&h.connected)try{o.sendCoordinationMessage(h.conn,{type:"peer-joined",peerId:r})}catch(e){o.log("⚠️ Failed to notify peer of new joiner:",p)}}}}catch(e){c=!0,l=e}finally{try{s||null==u.return||u.return()}finally{if(c)throw l}}return}}if(o._callback)try{var f=o.options.password?o.decrypt(t,o.options.password):t;o._callback(f)}catch(e){o.log("Error handling peer data:",e)}})),e.on("close",(function(){o.removePeer(r)})),e.on("error",(function(e){o.log("⚠️ Connection error:",r,e),o.removePeer(r)})),setTimeout((function(){}),1e3)}},{key:"removePeer",value:function(e){var r=this.peers.get(e);if(r){try{r.conn.close()}catch(e){}this.peers.delete(e)}}},{key:"sendCoordinationMessage",value:function(e,r){try{var o=JSON.stringify(r),n=(new TextEncoder).encode(o);e.send(n)}catch(e){this.log("Error encoding coordination message:",e)}}},{key:"tryDecodeCoordinationMessage",value:function(e){try{var r=(new TextDecoder).decode(e),o=JSON.parse(r);return o&&"object"==typeof o&&o.type&&"string"==typeof o.type?o:null}catch(e){return null}}},{key:"encrypt",value:function(e,r){for(var o=this.hashPassword(r),n=new Uint8Array(e.length),t=0;t<e.length;t++)n[t]=e[t]^o[t%o.length];return n}},{key:"decrypt",value:function(e,r){return this.encrypt(e,r)}},{key:"hashPassword",value:function(e){return(new TextEncoder).encode(e)}},{key:"log",value:function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var n;this.options.debug&&(n=console).log.apply(n,["[PeerJSTransport]"].concat((0,l.default)(r)))}}]),e}()})),r.register("84cK9",(function(e,r){var o,n,t=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(o===setTimeout)return setTimeout(e,0);if((o===i||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch(r){try{return o.call(null,e,0)}catch(r){return o.call(this,e,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:i}catch(e){o=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,l=[],d=!1,u=-1;function p(){d&&c&&(d=!1,c.length?l=c.concat(l):u=-1,l.length&&h())}function h(){if(!d){var e=s(p);d=!0;for(var r=l.length;r;){for(c=l,l=[];++u<r;)c&&c[u].run();u=-1,r=l.length}c=null,d=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{return n(e)}catch(r){try{return n.call(null,e)}catch(r){return n.call(this,e)}}}(e)}}function f(e,r){this.fun=e,this.array=r}function v(){}t.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)r[o-1]=arguments[o];l.push(new f(e,r)),1!==l.length||d||s(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={},t.on=v,t.addListener=v,t.once=v,t.off=v,t.removeListener=v,t.removeAllListeners=v,t.emit=v,t.prependListener=v,t.prependOnceListener=v,t.listeners=function(e){return[]},t.binding=function(e){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(e){throw new Error("process.chdir is not supported")},t.umask=function(){return 0}}))}();