47 skills found · Page 1 of 2
hiram3512 / HiSocketLightweight client socket solution, you can used it in C# project or Unity3d
brocaar / LorawanPackage lorawan provides structures and tools to read and write LoraWAN messages from and to a slice of bytes.
chrisneagu / FTC Skystone Dark Angels Romania 2020NOTICE This repository contains the public FTC SDK for the SKYSTONE (2019-2020) competition season. If you are looking for the current season's FTC SDK software, please visit the new and permanent home of the public FTC SDK: FtcRobotController repository Welcome! This GitHub repository contains the source code that is used to build an Android app to control a FIRST Tech Challenge competition robot. To use this SDK, download/clone the entire project to your local computer. Getting Started If you are new to robotics or new to the FIRST Tech Challenge, then you should consider reviewing the FTC Blocks Tutorial to get familiar with how to use the control system: FTC Blocks Online Tutorial Even if you are an advanced Java programmer, it is helpful to start with the FTC Blocks tutorial, and then migrate to the OnBot Java Tool or to Android Studio afterwards. Downloading the Project If you are an Android Studio programmer, there are several ways to download this repo. Note that if you use the Blocks or OnBot Java Tool to program your robot, then you do not need to download this repository. If you are a git user, you can clone the most current version of the repository: git clone https://github.com/FIRST-Tech-Challenge/SKYSTONE.git Or, if you prefer, you can use the "Download Zip" button available through the main repository page. Downloading the project as a .ZIP file will keep the size of the download manageable. You can also download the project folder (as a .zip or .tar.gz archive file) from the Downloads subsection of the Releases page for this repository. Once you have downloaded and uncompressed (if needed) your folder, you can use Android Studio to import the folder ("Import project (Eclipse ADT, Gradle, etc.)"). Getting Help User Documentation and Tutorials FIRST maintains online documentation with information and tutorials on how to use the FIRST Tech Challenge software and robot control system. You can access this documentation using the following link: SKYSTONE Online Documentation Note that the online documentation is an "evergreen" document that is constantly being updated and edited. It contains the most current information about the FIRST Tech Challenge software and control system. Javadoc Reference Material The Javadoc reference documentation for the FTC SDK is now available online. Click on the following link to view the FTC SDK Javadoc documentation as a live website: FTC Javadoc Documentation Documentation for the FTC SDK is also included with this repository. There is a subfolder called "doc" which contains several subfolders: The folder "apk" contains the .apk files for the FTC Driver Station and FTC Robot Controller apps. The folder "javadoc" contains the JavaDoc user documentation for the FTC SDK. Online User Forum For technical questions regarding the Control System or the FTC SDK, please visit the FTC Technology forum: FTC Technology Forum Release Information Version 5.5 (20200824-090813) Version 5.5 requires Android Studio 4.0 or later. New features Adds support for calling custom Java classes from Blocks OpModes (fixes SkyStone issue #161). Classes must be in the org.firstinspires.ftc.teamcode package. Methods must be public static and have no more than 21 parameters. Parameters declared as OpMode, LinearOpMode, Telemetry, and HardwareMap are supported and the argument is provided automatically, regardless of the order of the parameters. On the block, the sockets for those parameters are automatically filled in. Parameters declared as char or java.lang.Character will accept any block that returns text and will only use the first character in the text. Parameters declared as boolean or java.lang.Boolean will accept any block that returns boolean. Parameters declared as byte, java.lang.Byte, short, java.lang.Short, int, java.lang.Integer, long, or java.lang.Long, will accept any block that returns a number and will round that value to the nearest whole number. Parameters declared as float, java.lang.Float, double, java.lang.Double will accept any block that returns a number. Adds telemetry API method for setting display format Classic Monospace HTML (certain tags only) Adds blocks support for switching cameras. Adds Blocks support for TensorFlow Object Detection with a custom model. Adds support for uploading a custom TensorFlow Object Detection model in the Manage page, which is especially useful for Blocks and OnBotJava users. Shows new Control Hub blink codes when the WiFi band is switched using the Control Hub's button (only possible on Control Hub OS 1.1.2) Adds new warnings which can be disabled in the Advanced RC Settings Mismatched app versions warning Unnecessary 2.4 GHz WiFi usage warning REV Hub is running outdated firmware (older than version 1.8.2) Adds support for Sony PS4 gamepad, and reworks how gamepads work on the Driver Station Removes preference which sets gamepad type based on driver position. Replaced with menu which allows specifying type for gamepads with unknown VID and PID Attempts to auto-detect gamepad type based on USB VID and PID If gamepad VID and PID is not known, use type specified by user for that VID and PID If gamepad VID and PID is not known AND the user has not specified a type for that VID and PID, an educated guess is made about how to map the gamepad Driver Station will now attempt to automatically recover from a gamepad disconnecting, and re-assign it to the position it was assigned to when it dropped If only one gamepad is assigned and it drops: it can be recovered If two gamepads are assigned, and have different VID/PID signatures, and only one drops: it will be recovered If two gamepads are assigned, and have different VID/PID signatures, and BOTH drop: both will be recovered If two gamepads are assigned, and have the same VID/PID signatures, and only one drops: it will be recovered If two gamepads are assigned, and have the same VID/PID signatures, and BOTH drop: neither will be recovered, because of the ambiguity of the gamepads when they re-appear on the USB bus. There is currently one known edge case: if there are two gamepads with the same VID/PID signature plugged in, but only one is assigned, and they BOTH drop, it's a 50-50 chance of which one will be chosen for automatic recovery to the assigned position: it is determined by whichever one is re-enumerated first by the USB bus controller. Adds landscape user interface to Driver Station New feature: practice timer with audio cues New feature (Control Hub only): wireless network connection strength indicator (0-5 bars) New feature (Control Hub only): tapping on the ping/channel display will switch to an alternate display showing radio RX dBm and link speed (tap again to switch back) The layout will NOT autorotate. You can switch the layout from the Driver Station's settings menu. Breaking changes Removes support for Android versions 4.4 through 5.1 (KitKat and Lollipop). The minSdkVersion is now 23. Removes the deprecated LinearOpMode methods waitOneFullHardwareCycle() and waitForNextHardwareCycle() Enhancements Handles RS485 address of Control Hub automatically The Control Hub is automatically given a reserved address Existing configuration files will continue to work All addresses in the range of 1-10 are still available for Expansion Hubs The Control Hub light will now normally be solid green, without blinking to indicate the address The Control Hub will not be shown on the Expansion Hub Address Change settings page Improves REV Hub firmware updater The user can now choose between all available firmware update files Version 1.8.2 of the REV Hub firmware is bundled into the Robot Controller app. Text was added to clarify that Expansion Hubs can only be updated via USB. Firmware update speed was reduced to improve reliability Allows REV Hub firmware to be updated directly from the Manage webpage Improves log viewer on Robot Controller Horizontal scrolling support (no longer word wrapped) Supports pinch-to-zoom Uses a monospaced font Error messages are highlighted New color scheme Attempts to force-stop a runaway/stuck OpMode without restarting the entire app Not all types of runaway conditions are stoppable, but if the user code attempts to talk to hardware during the runaway, the system should be able to capture it. Makes various tweaks to the Self Inspect screen Renames "OS version" entry to "Android version" Renames "WiFi Direct Name" to "WiFi Name" Adds Control Hub OS version, when viewing the report of a Control Hub Hides the airplane mode entry, when viewing the report of a Control Hub Removes check for ZTE Speed Channel Changer Shows firmware version for all Expansion and Control Hubs Reworks network settings portion of Manage page All network settings are now applied with a single click The WiFi Direct channel of phone-based Robot Controllers can now be changed from the Manage page WiFi channels are filtered by band (2.4 vs 5 GHz) and whether they overlap with other channels The current WiFi channel is pre-selected on phone-based Robot Controllers, and Control Hubs running OS 1.1.2 or later. On Control Hubs running OS 1.1.2 or later, you can choose to have the system automatically select a channel on the 5 GHz band Improves OnBotJava New light and dark themes replace the old themes (chaos, github, chrome,...) the new default theme is light and will be used when you first update to this version OnBotJava now has a tabbed editor Read-only offline mode Improves function of "exit" menu item on Robot Controller and Driver Station Now guaranteed to be fully stopped and unloaded from memory Shows a warning message if a LinearOpMode exists prematurely due to failure to monitor for the start condition Improves error message shown when the Driver Station and Robot Controller are incompatible with each other Driver Station OpMode Control Panel now disabled while a Restart Robot is in progress Disables advanced settings related to WiFi direct when the Robot Controller is a Control Hub. Tint phone battery icons on Driver Station when low/critical. Uses names "Control Hub Portal" and "Control Hub" (when appropriate) in new configuration files Improve I2C read performance Very large improvement on Control Hub; up to ~2x faster with small (e.g. 6 byte) reads Not as apparent on Expansion Hubs connected to a phone Update/refresh build infrastructure Update to 'androidx' support library from 'com.android.support:appcompat', which is end-of-life Update targetSdkVersion and compileSdkVersion to 28 Update Android Studio's Android plugin to latest Fix reported build timestamp in 'About' screen Add sample illustrating manual webcam use: ConceptWebcam Bug fixes Fixes SkyStone issue #248 Fixes SkyStone issue #232 and modifies bulk caching semantics to allow for cache-preserving MANUAL/AUTO transitions. Improves performance when REV 2M distance sensor is unplugged Improves readability of Toast messages on certain devices Allows a Driver Station to connect to a Robot Controller after another has disconnected Improves generation of fake serial numbers for UVC cameras which do not provide a real serial number Previously some devices would assign such cameras a serial of 0:0 and fail to open and start streaming Fixes ftc_app issue #638. Fixes a slew of bugs with the Vuforia camera monitor including: Fixes bug where preview could be displayed with a wonky aspect ratio Fixes bug where preview could be cut off in landscape Fixes bug where preview got totally messed up when rotating phone Fixes bug where crosshair could drift off target when using webcams Fixes issue in UVC driver on some devices (ftc_app 681) if streaming was started/stopped multiple times in a row Issue manifested as kernel panic on devices which do not have this kernel patch. On affected devices which do have the patch, the issue was manifest as simply a failure to start streaming. The Tech Team believes that the root cause of the issue is a bug in the Linux kernel XHCI driver. A workaround was implemented in the SDK UVC driver. Fixes bug in UVC driver where often half the frames from the camera would be dropped (e.g. only 15FPS delivered during a streaming session configured for 30FPS). Fixes issue where TensorFlow Object Detection would show results whose confidence was lower than the minimum confidence parameter. Fixes a potential exploitation issue of CVE-2019-11358 in OnBotJava Fixes changing the address of an Expansion Hub with additional Expansion Hubs connected to it Preserves the Control Hub's network connection when "Restart Robot" is selected Fixes issue where device scans would fail while the Robot was restarting Fix RenderScript usage Use androidx.renderscript variant: increased compatibility Use RenderScript in Java mode, not native: simplifies build Fixes webcam-frame-to-bitmap conversion problem: alpha channel wasn't being initialized, only R, G, & B Fixes possible arithmetic overflow in Deadline Fixes deadlock in Vuforia webcam support which could cause 5-second delays when stopping OpMode Version 5.4 (20200108-101156) Fixes SkyStone issue #88 Adds an inspection item that notes when a robot controller (Control Hub) is using the factory default password. Fixes SkyStone issue #61 Fixes SkyStone issue #142 Fixes ftc_app issue #417 by adding more current and voltage monitoring capabilities for REV Hubs. Fixes a crash sometimes caused by OnBotJava activity Improves OnBotJava autosave functionality ftc_app #738 Fixes system responsiveness issue when an Expansion Hub is disconnected Fixes issue where IMU initialization could prevent Op Modes from stopping Fixes issue where AndroidTextToSpeech.speak() would fail if it was called too early Adds telemetry.speak() methods and blocks, which cause the Driver Station (if also updated) to speak text Adds and improves Expansion Hub-related warnings Improves Expansion Hub low battery warning Displays the warning immediately after the hub reports it Specifies whether the condition is current or occurred temporarily during an OpMode run Displays which hubs reported low battery Displays warning when hub loses and regains power during an OpMode run Fixes the hub's LED pattern after this condition Displays warning when Expansion Hub is not responding to commands Specifies whether the condition is current or occurred temporarily during an OpMode run Clarifies warning when Expansion Hub is not present at startup Specifies that this condition requires a Robot Restart before the hub can be used. The hub light will now accurately reflect this state Improves logging and reduces log spam during these conditions Syncs the Control Hub time and timezone to a connected web browser programming the robot, if a Driver Station is not available. Adds bulk read functionality for REV Hubs A bulk caching mode must be set at the Hub level with LynxModule#setBulkCachingMode(). This applies to all relevant SDK hardware classes that reference that Hub. The following following Hub bulk caching modes are available: BulkCachingMode.OFF (default): All hardware calls operate as usual. Bulk data can read through LynxModule#getBulkData() and processed manually. BulkCachingMode.AUTO: Applicable hardware calls are served from a bulk read cache that is cleared/refreshed automatically to ensure identical commands don't hit the same cache. The cache can also be cleared manually with LynxModule#clearBulkCache(), although this is not recommended. (advanced users) BulkCachingMode.MANUAL: Same as BulkCachingMode.AUTO except the cache is never cleared automatically. To avoid getting stale data, the cache must be manually cleared at the beginning of each loop body or as the user deems appropriate. Removes PIDF Annotation values added in Rev 5.3 (to AndyMark, goBILDA and TETRIX motor configurations). The new motor types will still be available but their Default control behavior will revert back to Rev 5.2 Adds new ConceptMotorBulkRead sample Opmode to demonstrate and compare Motor Bulk-Read modes for reducing I/O latencies. Version 5.3 (20191004-112306) Fixes external USB/UVC webcam support Makes various bugfixes and improvements to Blocks page, including but not limited to: Many visual tweaks Browser zoom and window resize behave better Resizing the Java preview pane works better and more consistently across browsers The Java preview pane consistently gets scrollbars when needed The Java preview pane is hidden by default on phones Internet Explorer 11 should work Large dropdown lists display properly on lower res screens Disabled buttons are now visually identifiable as disabled A warning is shown if a user selects a TFOD sample, but their device is not compatible Warning messages in a Blocks op mode are now visible by default. Adds goBILDA 5201 and 5202 motors to Robot Configurator Adds PIDF Annotation values to AndyMark, goBILDA and TETRIX motor configurations. This has the effect of causing the RUN_USING_ENCODERS and RUN_TO_POSITION modes to use PIDF vs PID closed loop control on these motors. This should provide more responsive, yet stable, speed control. PIDF adds Feedforward control to the basic PID control loop. Feedforward is useful when controlling a motor's speed because it "anticipates" how much the control voltage must change to achieve a new speed set-point, rather than requiring the integrated error to change sufficiently. The PIDF values were chosen to provide responsive, yet stable, speed control on a lightly loaded motor. The more heavily a motor is loaded (drag or friction), the more noticable the PIDF improvement will be. Fixes startup crash on Android 10 Fixes ftc_app issue #712 (thanks to FROGbots-4634) Fixes ftc_app issue #542 Allows "A" and lowercase letters when naming device through RC and DS apps. Version 5.2 (20190905-083277) Fixes extra-wide margins on settings activities, and placement of the new configuration button Adds Skystone Vuforia image target data. Includes sample Skystone Vuforia Navigation op modes (Java). Includes sample Skystone Vuforia Navigation op modes (Blocks). Adds TensorFlow inference model (.tflite) for Skystone game elements. Includes sample Skystone TensorFlow op modes (Java). Includes sample Skystone TensorFlow op modes (Blocks). Removes older (season-specific) sample op modes. Includes 64-bit support (to comply with Google Play requirements). Protects against Stuck OpModes when a Restart Robot is requested. (Thanks to FROGbots-4634) (ftc_app issue #709) Blocks related changes: Fixes bug with blocks generated code when hardware device name is a java or javascript reserved word. Shows generated java code for blocks, even when hardware items are missing from the active configuration. Displays warning icon when outdated Vuforia and TensorFlow blocks are used (SkyStone issue #27) Version 5.1 (20190820-222104) Defines default PIDF parameters for the following motors: REV Core Hex Motor REV 20:1 HD Hex Motor REV 40:1 HD Hex Motor Adds back button when running on a device without a system back button (such as a Control Hub) Allows a REV Control Hub to update the firmware on a REV Expansion Hub via USB Fixes SkyStone issue #9 Fixes ftc_app issue #715 Prevents extra DS User clicks by filtering based on current state. Prevents incorrect DS UI state changes when receiving new OpMode list from RC Adds support for REV Color Sensor V3 Adds a manual-refresh DS Camera Stream for remotely viewing RC camera frames. To show the stream on the DS, initialize but do not run a stream-enabled opmode, select the Camera Stream option in the DS menu, and tap the image to refresh. This feature is automatically enabled when using Vuforia or TFOD—no additional RC configuration is required for typical use cases. To hide the stream, select the same menu item again. Note that gamepads are disabled and the selected opmode cannot be started while the stream is open as a safety precaution. To use custom streams, consult the API docs for CameraStreamServer#setSource and CameraStreamSource. Adds many Star Wars sounds to RobotController resources. Added SKYSTONE Sounds Chooser Sample Program. Switches out startup, connect chimes, and error/warning sounds for Star Wars sounds Updates OnBot Java to use a WebSocket for communication with the robot The OnBot Java page no longer has to do a full refresh when a user switches from editing one file to another Known issues: Camera Stream The Vuforia camera stream inherits the issues present in the phone preview (namely ftc_app issue #574). This problem does not affect the TFOD camera stream even though it receives frames from Vuforia. The orientation of the stream frames may not always match the phone preview. For now, these frames may be rotated manually via a custom CameraStreamSource if desired. OnBotJava Browser back button may not always work correctly It's possible for a build to be queued, but not started. The OnBot Java build console will display a warning if this occurs. A user might not realize they are editing a different file if the user inadvertently switches from one file to another since this switch is now seamless. The name of the currently open file is displayed in the browser tab. Version 5.0 (built on 19.06.14) Support for the REV Robotics Control Hub. Adds a Java preview pane to the Blocks editor. Adds a new offline export feature to the Blocks editor. Display wifi channel in Network circle on Driver Station. Adds calibration for Logitech C270 Updates build tooling and target SDK. Compliance with Google's permissions infrastructure (Required after build tooling update). Keep Alives to mitigate the Motorola wifi scanning problem. Telemetry substitute no longer necessary. Improves Vuforia error reporting. Fixes ftctechnh/ftc_app issues 621, 713. Miscellaneous bug fixes and improvements. Version 4.3 (built on 18.10.31) Includes missing TensorFlow-related libraries and files. Version 4.2 (built on 18.10.30) Includes fix to avoid deadlock situation with WatchdogMonitor which could result in USB communication errors. Comm error appeared to require that user disconnect USB cable and restart the Robot Controller app to recover. robotControllerLog.txt would have error messages that included the words "E RobotCore: lynx xmit lock: #### abandoning lock:" Includes fix to correctly list the parent module address for a REV Robotics Expansion Hub in a configuration (.xml) file. Bug in versions 4.0 and 4.1 would incorrect list the address module for a parent REV Robotics device as "1". If the parent module had a higher address value than the daisy-chained module, then this bug would prevent the Robot Controller from communicating with the downstream Expansion Hub. Added requirement for ACCESS_COARSE_LOCATION to allow a Driver Station running Android Oreo to scan for Wi-Fi Direct devices. Added google() repo to build.gradle because aapt2 must be downloaded from the google() repository beginning with version 3.2 of the Android Gradle Plugin. Important Note: Android Studio users will need to be connected to the Internet the first time build the ftc_app project. Internet connectivity is required for the first build so the appropriate files can be downloaded from the Google repository. Users should not need to be connected to the Internet for subsequent builds. This should also fix buid issue where Android Studio would complain that it "Could not find com.android.tools.lint:lint-gradle:26.1.4" (or similar). Added support for REV Spark Mini motor controller as part of the configuration menu for a servo/PWM port on the REV Expansion Hub. Provide examples for playing audio files in an Op Mode. Block Development Tool Changes Includes a fix for a problem with the Velocity blocks that were reported in the FTC Technology forum (Blocks Programming subforum). Change the "Save completed successfully." message to a white color so it will contrast with a green background. Fixed the "Download image" feature so it will work if there are text blocks in the op mode. Introduce support for Google's TensorFlow Lite technology for object detetion for 2018-2019 game. TensorFlow lite can recognize Gold Mineral and Silver Mineral from 2018-2019 game. Example Java and Block op modes are included to show how to determine the relative position of the gold block (left, center, right). Version 4.1 (released on 18.09.24) Changes include: Fix to prevent crash when deprecated configuration annotations are used. Change to allow FTC Robot Controller APK to be auto-updated using FIRST Global Control Hub update scripts. Removed samples for non supported / non legal hardware. Improvements to Telemetry.addData block with "text" socket. Updated Blocks sample op mode list to include Rover Ruckus Vuforia example. Update SDK library version number. Version 4.0 (released on 18.09.12) Changes include: Initial support for UVC compatible cameras If UVC camera has a unique serial number, RC will detect and enumerate by serial number. If UVC camera lacks a unique serial number, RC will only support one camera of that type connected. Calibration settings for a few cameras are included (see TeamCode/src/main/res/xml/teamwebcamcalibrations.xml for details). User can upload calibration files from Program and Manage web interface. UVC cameras seem to draw a fair amount of electrical current from the USB bus. This does not appear to present any problems for the REV Robotics Control Hub. This does seem to create stability problems when using some cameras with an Android phone-based Robot Controller. FTC Tech Team is investigating options to mitigate this issue with the phone-based Robot Controllers. Updated sample Vuforia Navigation and VuMark Op Modes to demonstrate how to use an internal phone-based camera and an external UVC webcam. Support for improved motor control. REV Robotics Expansion Hub firmware 1.8 and greater will support a feed forward mechanism for closed loop motor control. FTC SDK has been modified to support PIDF coefficients (proportional, integral, derivative, and feed forward). FTC Blocks development tool modified to include PIDF programming blocks. Deprecated older PID-related methods and variables. REV's 1.8.x PIDF-related changes provide a more linear and accurate way to control a motor. Wireless Added 5GHz support for wireless channel changing for those devices that support it. Tested with Moto G5 and E4 phones. Also tested with other (currently non-approved) phones such as Samsung Galaxy S8. Improved Expansion Hub firmware update support in Robot Controller app Changes to make the system more robust during the firmware update process (when performed through Robot Controller app). User no longer has to disconnect a downstream daisy-chained Expansion Hub when updating an Expansion Hub's firmware. If user is updating an Expansion Hub's firmware through a USB connection, he/she does not have to disconnect RS485 connection to other Expansion Hubs. The user still must use a USB connection to update an Expansion Hub's firmware. The user cannot update the Expansion Hub firmware for a downstream device that is daisy chained through an RS485 connection. If an Expansion Hub accidentally gets "bricked" the Robot Controller app is now more likely to recognize the Hub when it scans the USB bus. Robot Controller app should be able to detect an Expansion Hub, even if it accidentally was bricked in a previous update attempt. Robot Controller app should be able to install the firmware onto the Hub, even if if accidentally was bricked in a previous update attempt. Resiliency FTC software can detect and enable an FTDI reset feature that is available with REV Robotics v1.8 Expansion Hub firmware and greater. When enabled, the Expansion Hub can detect if it hasn't communicated with the Robot Controller over the FTDI (USB) connection. If the Hub hasn't heard from the Robot Controller in a while, it will reset the FTDI connection. This action helps system recover from some ESD-induced disruptions. Various fixes to improve reliability of FTC software. Blocks Fixed errors with string and list indices in blocks export to java. Support for USB connected UVC webcams. Refactored optimized Blocks Vuforia code to support Rover Ruckus image targets. Added programming blocks to support PIDF (proportional, integral, derivative and feed forward) motor control. Added formatting options (under Telemetry and Miscellaneous categories) so user can set how many decimal places to display a numerical value. Support to play audio files (which are uploaded through Blocks web interface) on Driver Station in addition to the Robot Controller. Fixed bug with Download Image of Blocks feature. Support for REV Robotics Blinkin LED Controller. Support for REV Robotics 2m Distance Sensor. Added support for a REV Touch Sensor (no longer have to configure as a generic digital device). Added blocks for DcMotorEx methods. These are enhanced methods that you can use when supported by the motor controller hardware. The REV Robotics Expansion Hub supports these enhanced methods. Enhanced methods include methods to get/set motor velocity (in encoder pulses per second), get/set PIDF coefficients, etc.. Modest Improvements in Logging Decrease frequency of battery checker voltage statements. Removed non-FTC related log statements (wherever possible). Introduced a "Match Logging" feature. Under "Settings" a user can enable/disable this feature (it's disabled by default). If enabled, user provides a "Match Number" through the Driver Station user interface (top of the screen). The Match Number is used to create a log file specifically with log statements from that particular Op Mode run. Match log files are stored in /sdcard/FIRST/matlogs on the Robot Controller. Once an op mode run is complete, the Match Number is cleared. This is a convenient way to create a separate match log with statements only related to a specific op mode run. New Devices Support for REV Robotics Blinkin LED Controller. Support for REV Robotics 2m Distance Sensor. Added configuration option for REV 20:1 HD Hex Motor. Added support for a REV Touch Sensor (no longer have to configure as a generic digital device). Miscellaneous Fixed some errors in the definitions for acceleration and velocity in our javadoc documentation. Added ability to play audio files on Driver Station When user is configuring an Expansion Hub, the LED on the Expansion Hub will change blink pattern (purple-cyan) to indicate which Hub is currently being configured. Renamed I2cSensorType to I2cDeviceType. Added an external sample Op Mode that demonstrates localization using 2018-2019 (Rover Ruckus presented by QualComm) Vuforia targets. Added an external sample Op Mode that demonstrates how to use the REV Robotics 2m Laser Distance Sensor. Added an external sample Op Mode that demonstrates how to use the REV Robotics Blinkin LED Controller. Re-categorized external Java sample Op Modes to "TeleOp" instead of "Autonomous". Known issues: Initial support for UVC compatible cameras UVC cameras seem to draw significant amount of current from the USB bus. This does not appear to present any problems for the REV Robotics Control Hub. This does seem to create stability problems when using some cameras with an Android phone-based Robot Controller. FTC Tech Team is investigating options to mitigate this issue with the phone-based Robot Controllers. There might be a possible deadlock which causes the RC to become unresponsive when using a UVC webcam with a Nougat Android Robot Controller. Wireless When user selects a wireless channel, this channel does not necessarily persist if the phone is power cycled. Tech Team is hoping to eventually address this issue in a future release. Issue has been present since apps were introduced (i.e., it is not new with the v4.0 release). Wireless channel is not currently displayed for WiFi Direct connections. Miscellaneous The blink indication feature that shows which Expansion Hub is currently being configured does not work for a newly created configuration file. User has to first save a newly created configuration file and then close and re-edit the file in order for blink indicator to work. Version 3.6 (built on 17.12.18) Changes include: Blocks Changes Uses updated Google Blockly software to allow users to edit their op modes on Apple iOS devices (including iPad and iPhone). Improvement in Blocks tool to handle corrupt op mode files. Autonomous op modes should no longer get switched back to tele-op after re-opening them to be edited. The system can now detect type mismatches during runtime and alert the user with a message on the Driver Station. Updated javadoc documentation for setPower() method to reflect correct range of values (-1 to +1). Modified VuforiaLocalizerImpl to allow for user rendering of frames Added a user-overrideable onRenderFrame() method which gets called by the class's renderFrame() method. Version 3.5 (built on 17.10.30) Changes with version 3.5 include: Introduced a fix to prevent random op mode stops, which can occur after the Robot Controller app has been paused and then resumed (for example, when a user temporarily turns off the display of the Robot Controller phone, and then turns the screen back on). Introduced a fix to prevent random op mode stops, which were previously caused by random peer disconnect events on the Driver Station. Fixes issue where log files would be closed on pause of the RC or DS, but not re-opened upon resume. Fixes issue with battery handler (voltage) start/stop race. Fixes issue where Android Studio generated op modes would disappear from available list in certain situations. Fixes problem where OnBot Java would not build on REV Robotics Control Hub. Fixes problem where OnBot Java would not build if the date and time on the Robot Controller device was "rewound" (set to an earlier date/time). Improved error message on OnBot Java that occurs when renaming a file fails. Removed unneeded resources from android.jar binaries used by OnBot Java to reduce final size of Robot Controller app. Added MR_ANALOG_TOUCH_SENSOR block to Blocks Programming Tool. Version 3.4 (built on 17.09.06) Changes with version 3.4 include: Added telemetry.update() statement for BlankLinearOpMode template. Renamed sample Block op modes to be more consistent with Java samples. Added some additional sample Block op modes. Reworded OnBot Java readme slightly. Version 3.3 (built on 17.09.04) This version of the software includes improves for the FTC Blocks Programming Tool and the OnBot Java Programming Tool. Changes with verion 3.3 include: Android Studio ftc_app project has been updated to use Gradle Plugin 2.3.3. Android Studio ftc_app project is already using gradle 3.5 distribution. Robot Controller log has been renamed to /sdcard/RobotControllerLog.txt (note that this change was actually introduced w/ v3.2). Improvements in I2C reliability. Optimized I2C read for REV Expansion Hub, with v1.7 firmware or greater. Updated all external/samples (available through OnBot and in Android project folder). Vuforia Added support for VuMarks that will be used for the 2017-2018 season game. Blocks Update to latest Google Blockly release. Sample op modes can be selected as a template when creating new op mode. Fixed bug where the blocks would disappear temporarily when mouse button is held down. Added blocks for Range.clip and Range.scale. User can now disable/enable Block op modes. Fix to prevent occasional Blocks deadlock. OnBot Java Significant improvements with autocomplete function for OnBot Java editor. Sample op modes can be selected as a template when creating new op mode. Fixes and changes to complete hardware setup feature. Updated (and more useful) onBot welcome message. Known issues: Android Studio After updating to the new v3.3 Android Studio project folder, if you get error messages indicating "InvalidVirtualFileAccessException" then you might need to do a File->Invalidate Caches / Restart to clear the error. OnBot Java Sometimes when you push the build button to build all op modes, the RC returns an error message that the build failed. If you press the build button a second time, the build typically suceeds. Version 3.2 (built on 17.08.02) This version of the software introduces the "OnBot Java" Development Tool. Similar to the FTC Blocks Development Tool, the FTC OnBot Java Development Tool allows a user to create, edit and build op modes dynamically using only a Javascript-enabled web browser. The OnBot Java Development Tool is an integrated development environment (IDE) that is served up by the Robot Controller. Op modes are created and edited using a Javascript-enabled browser (Google Chromse is recommended). Op modes are saved on the Robot Controller Android device directly. The OnBot Java Development Tool provides a Java programming environment that does NOT need Android Studio. Changes with version 3.2 include: Enhanced web-based development tools Introduction of OnBot Java Development Tool. Web-based programming and management features are "always on" (user no longer needs to put Robot Controller into programming mode). Web-based management interface (where user can change Robot Controller name and also easily download Robot Controller log file). OnBot Java, Blocks and Management features available from web based interface. Blocks Programming Development Tool: Changed "LynxI2cColorRangeSensor" block to "REV Color/range sensor" block. Fixed tooltip for ColorSensor.isLightOn block. Added blocks for ColorSensor.getNormalizedColors and LynxI2cColorRangeSensor.getNormalizedColors. Added example op modes for digital touch sensor and REV Robotics Color Distance sensor. User selectable color themes. Includes many minor enhancements and fixes (too numerous to list). Known issues: Auto complete function is incomplete and does not support the following (for now): Access via this keyword Access via super keyword Members of the super cloass, not overridden by the class Any methods provided in the current class Inner classes Can't handle casted objects Any objects coming from an parenthetically enclosed expression Version 3.10 (built on 17.05.09) This version of the software provides support for the REV Robotics Expansion Hub. This version also includes improvements in the USB communication layer in an effort to enhance system resiliency. If you were using a 2.x version of the software previously, updating to version 3.1 requires that you also update your Driver Station software in addition to updating the Robot Controller software. Also note that in version 3.10 software, the setMaxSpeed and getMaxSpeed methods are no longer available (not deprecated, they have been removed from the SDK). Also note that the the new 3.x software incorporates motor profiles that a user can select as he/she configures the robot. Changes include: Blocks changes Added VuforiaTrackableDefaultListener.getPose and Vuforia.trackPose blocks. Added optimized blocks support for Vuforia extended tracking. Added atan2 block to the math category. Added useCompetitionFieldTargetLocations parameter to Vuforia.initialize block. If set to false, the target locations are placed at (0,0,0) with target orientation as specified in https://github.com/gearsincorg/FTCVuforiaDemo/blob/master/Robot_Navigation.java tutorial op mode. Incorporates additional improvements to USB comm layer to improve system resiliency (to recover from a greater number of communication disruptions). Additional Notes Regarding Version 3.00 (built on 17.04.13) In addition to the release changes listed below (see section labeled "Version 3.00 (built on 17.04.013)"), version 3.00 has the following important changes: Version 3.00 software uses a new version of the FTC Robocol (robot protocol). If you upgrade to v3.0 on the Robot Controller and/or Android Studio side, you must also upgrade the Driver Station software to match the new Robocol. Version 3.00 software removes the setMaxSpeed and getMaxSpeed methods from the DcMotor class. If you have an op mode that formerly used these methods, you will need to remove the references/calls to these methods. Instead, v3.0 provides the max speed information through the use of motor profiles that are selected by the user during robot configuration. Version 3.00 software currently does not have a mechanism to disable extra i2c sensors. We hope to re-introduce this function with a release in the near future. Version 3.00 (built on 17.04.13) *** Use this version of the software at YOUR OWN RISK!!! *** This software is being released as an "alpha" version. Use this version at your own risk! This pre-release software contains SIGNIFICANT changes, including changes to the Wi-Fi Direct pairing mechanism, rewrites of the I2C sensor classes, changes to the USB/FTDI layer, and the introduction of support for the REV Robotics Expansion Hub and the REV Robotics color-range-light sensor. These changes were implemented to improve the reliability and resiliency of the FTC control system. Please note, however, that version 3.00 is considered "alpha" code. This code is being released so that the FIRST community will have an opportunity to test the new REV Expansion Hub electronics module when it becomes available in May. The developers do not recommend using this code for critical applications (i.e., competition use). *** Use this version of the software at YOUR OWN RISK!!! *** Changes include: Major rework of sensor-related infrastructure. Includes rewriting sensor classes to implement synchronous I2C communication. Fix to reset Autonomous timer back to 30 seconds. Implementation of specific motor profiles for approved 12V motors (includes Tetrix, AndyMark, Matrix and REV models). Modest improvements to enhance Wi-Fi P2P pairing. Fixes telemetry log addition race. Publishes all the sources (not just a select few). Includes Block programming improvements Addition of optimized Vuforia blocks. Auto scrollbar to projects and sounds pages. Fixed blocks paste bug. Blocks execute after while-opModeIsActive loop (to allow for cleanup before exiting op mode). Added gyro integratedZValue block. Fixes bug with projects page for Firefox browser. Added IsSpeaking block to AndroidTextToSpeech. Implements support for the REV Robotics Expansion Hub Implements support for integral REV IMU (physically installed on I2C bus 0, uses same Bosch BNO055 9 axis absolute orientation sensor as Adafruit 9DOF abs orientation sensor). - Implements support for REV color/range/light sensor. Provides support to update Expansion Hub firmware through FTC SDK. Detects REV firmware version and records in log file. Includes support for REV Control Hub (note that the REV Control Hub is not yet approved for FTC use). Implements FTC Blocks programming support for REV Expansion Hub and sensor hardware. Detects and alerts when I2C device disconnect. Version 2.62 (built on 17.01.07) Added null pointer check before calling modeToByte() in finishModeSwitchIfNecessary method for ModernRoboticsUsbDcMotorController class. Changes to enhance Modern Robotics USB protocol robustness. Version 2.61 (released on 16.12.19) Blocks Programming mode changes: Fix to correct issue when an exception was thrown because an OpticalDistanceSensor object appears twice in the hardware map (the second time as a LightSensor). Version 2.6 (released on 16.12.16) Fixes for Gyro class: Improve (decrease) sensor refresh latency. fix isCalibrating issues. Blocks Programming mode changes: Blocks now ignores a device in the configuration xml if the name is empty. Other devices work in configuration work fine. Version 2.5 (internal release on released on 16.12.13) Blocks Programming mode changes: Added blocks support for AdafruitBNO055IMU. Added Download Op Mode button to FtcBocks.html. Added support for copying blocks in one OpMode and pasting them in an other OpMode. The clipboard content is stored on the phone, so the programming mode server must be running. Modified Utilities section of the toolbox. In Programming Mode, display information about the active connections. Fixed paste location when workspace has been scrolled. Added blocks support for the android Accelerometer. Fixed issue where Blocks Upload Op Mode truncated name at first dot. Added blocks support for Android SoundPool. Added type safety to blocks for Acceleration. Added type safety to blocks for AdafruitBNO055IMU.Parameters. Added type safety to blocks for AnalogInput. Added type safety to blocks for AngularVelocity. Added type safety to blocks for Color. Added type safety to blocks for ColorSensor. Added type safety to blocks for CompassSensor. Added type safety to blocks for CRServo. Added type safety to blocks for DigitalChannel. Added type safety to blocks for ElapsedTime. Added type safety to blocks for Gamepad. Added type safety to blocks for GyroSensor. Added type safety to blocks for IrSeekerSensor. Added type safety to blocks for LED. Added type safety to blocks for LightSensor. Added type safety to blocks for LinearOpMode. Added type safety to blocks for MagneticFlux. Added type safety to blocks for MatrixF. Added type safety to blocks for MrI2cCompassSensor. Added type safety to blocks for MrI2cRangeSensor. Added type safety to blocks for OpticalDistanceSensor. Added type safety to blocks for Orientation. Added type safety to blocks for Position. Added type safety to blocks for Quaternion. Added type safety to blocks for Servo. Added type safety to blocks for ServoController. Added type safety to blocks for Telemetry. Added type safety to blocks for Temperature. Added type safety to blocks for TouchSensor. Added type safety to blocks for UltrasonicSensor. Added type safety to blocks for VectorF. Added type safety to blocks for Velocity. Added type safety to blocks for VoltageSensor. Added type safety to blocks for VuforiaLocalizer.Parameters. Added type safety to blocks for VuforiaTrackable. Added type safety to blocks for VuforiaTrackables. Added type safety to blocks for enums in AdafruitBNO055IMU.Parameters. Added type safety to blocks for AndroidAccelerometer, AndroidGyroscope, AndroidOrientation, and AndroidTextToSpeech. Version 2.4 (released on 16.11.13) Fix to avoid crashing for nonexistent resources. Blocks Programming mode changes: Added blocks to support OpenGLMatrix, MatrixF, and VectorF. Added blocks to support AngleUnit, AxesOrder, AxesReference, CameraDirection, CameraMonitorFeedback, DistanceUnit, and TempUnit. Added blocks to support Acceleration. Added blocks to support LinearOpMode.getRuntime. Added blocks to support MagneticFlux and Position. Fixed typos. Made blocks for ElapsedTime more consistent with other objects. Added blocks to support Quaternion, Velocity, Orientation, AngularVelocity. Added blocks to support VuforiaTrackables, VuforiaTrackable, VuforiaLocalizer, VuforiaTrackableDefaultListener. Fixed a few blocks. Added type checking to new blocks. Updated to latest blockly. Added default variable blocks to navigation and matrix blocks. Fixed toolbox entry for openGLMatrix_rotation_withAxesArgs. When user downloads Blocks-generated op mode, only the .blk file is downloaded. When user uploads Blocks-generated op mode (.blk file), Javascript code is auto generated. Added DbgLog support. Added logging when a blocks file is read/written. Fixed bug to properly render blocks even if missing devices from configuration file. Added support for additional characters (not just alphanumeric) for the block file names (for download and upload). Added support for OpMode flavor (“Autonomous” or “TeleOp”) and group. Changes to Samples to prevent tutorial issues. Incorporated suggested changes from public pull 216 (“Replace .. paths”). Remove Servo Glitches when robot stopped. if user hits “Cancels” when editing a configuration file, clears the unsaved changes and reverts to original unmodified configuration. Added log info to help diagnose why the Robot Controller app was terminated (for example, by watch dog function). Added ability to transfer log from the controller. Fixed inconsistency for AngularVelocity Limit unbounded growth of data for telemetry. If user does not call telemetry.update() for LinearOpMode in a timely manner, data added for telemetry might get lost if size limit is exceeded. Version 2.35 (released on 16.10.06) Blockly programming mode - Removed unnecesary idle() call from blocks for new project. Version 2.30 (released on 16.10.05) Blockly programming mode: Mechanism added to save Blockly op modes from Programming Mode Server onto local device To avoid clutter, blocks are displayed in categorized folders Added support for DigitalChannel Added support for ModernRoboticsI2cCompassSensor Added support for ModernRoboticsI2cRangeSensor Added support for VoltageSensor Added support for AnalogInput Added support for AnalogOutput Fix for CompassSensor setMode block Vuforia Fix deadlock / make camera data available while Vuforia is running. Update to Vuforia 6.0.117 (recommended by Vuforia and Google to close security loophole). Fix for autonomous 30 second timer bug (where timer was in effect, even though it appeared to have timed out). opModeIsActive changes to allow cleanup after op mode is stopped (with enforced 2 second safety timeout). Fix to avoid reading i2c twice. Updated sample Op Modes. Improved logging and fixed intermittent freezing. Added digital I/O sample. Cleaned up device names in sample op modes to be consistent with Pushbot guide. Fix to allow use of IrSeekerSensorV3. Version 2.20 (released on 16.09.08) Support for Modern Robotics Compass Sensor. Support for Modern Robotics Range Sensor. Revise device names for Pushbot templates to match the names used in Pushbot guide. Fixed bug so that IrSeekerSensorV3 device is accessible as IrSeekerSensor in hardwareMap. Modified computer vision code to require an individual Vuforia license (per legal requirement from PTC). Minor fixes. Blockly enhancements: Support for Voltage Sensor. Support for Analog Input. Support for Analog Output. Support for Light Sensor. Support for Servo Controller. Version 2.10 (released on 16.09.03) Support for Adafruit IMU. Improvements to ModernRoboticsI2cGyro class Block on reset of z axis. isCalibrating() returns true while gyro is calibration. Updated sample gyro program. Blockly enhancements support for android.graphics.Color. added support for ElapsedTime. improved look and legibility of blocks. support for compass sensor. support for ultrasonic sensor. support for IrSeeker. support for LED. support for color sensor. support for CRServo prompt user to configure robot before using programming mode. Provides ability to disable audio cues. various bug fixes and improvements. Version 2.00 (released on 16.08.19) This is the new release for the upcoming 2016-2017 FIRST Tech Challenge Season. Channel change is enabled in the FTC Robot Controller app for Moto G 2nd and 3rd Gen phones. Users can now use annotations to register/disable their Op Modes. Changes in the Android SDK, JDK and build tool requirements (minsdk=19, java 1.7, build tools 23.0.3). Standardized units in analog input. Cleaned up code for existing analog sensor classes. setChannelMode and getChannelMode were REMOVED from the DcMotorController class. This is important - we no longer set the motor modes through the motor controller. setMode and getMode were added to the DcMotor class. ContinuousRotationServo class has been added to the FTC SDK. Range.clip() method has been overloaded so it can support this operation for int, short and byte integers. Some changes have been made (new methods added) on how a user can access items from the hardware map. Users can now set the zero power behavior for a DC motor so that the motor will brake or float when power is zero. Prototype Blockly Programming Mode has been added to FTC Robot Controller. Users can place the Robot Controller into this mode, and then use a device (such as a laptop) that has a Javascript enabled browser to write Blockly-based Op Modes directly onto the Robot Controller. Users can now configure the robot remotely through the FTC Driver Station app. Android Studio project supports Android Studio 2.1.x and compile SDK Version 23 (Marshmallow). Vuforia Computer Vision SDK integrated into FTC SDK. Users can use sample vision targets to get localization information on a standard FTC field. Project structure has been reorganized so that there is now a TeamCode package that users can use to place their local/custom Op Modes into this package. Inspection function has been integrated into the FTC Robot Controller and Driver Station Apps (Thanks Team HazMat… 9277 & 10650!). Audio cues have been incorporated into FTC SDK. Swap mechanism added to FTC Robot Controller configuration activity. For example, if you have two motor controllers on a robot, and you misidentified them in your configuration file, you can use the Swap button to swap the devices within the configuration file (so you do not have to manually re-enter in the configuration info for the two devices). Fix mechanism added to all user to replace an electronic module easily. For example, suppose a servo controller dies on your robot. You replace the broken module with a new module, which has a different serial number from the original servo controller. You can use the Fix button to automatically reconfigure your configuration file to use the serial number of the new module. Improvements made to fix resiliency and responsiveness of the system. For LinearOpMode the user now must for a telemetry.update() to update the telemetry data on the driver station. This update() mechanism ensures that the driver station gets the updated data properly and at the same time. The Auto Configure function of the Robot Controller is now template based. If there is a commonly used robot configuration, a template can be created so that the Auto Configure mechanism can be used to quickly configure a robot of this type. The logic to detect a runaway op mode (both in the LinearOpMode and OpMode types) and to abort the run, then auto recover has been improved/implemented. Fix has been incorporated so that Logitech F310 gamepad mappings will be correct for Marshmallow users. Release 16.07.08 For the ftc_app project, the gradle files have been modified to support Android Studio 2.1.x. Release 16.03.30 For the MIT App Inventor, the design blocks have new icons that better represent the function of each design component. Some changes were made to the shutdown logic to ensure the robust shutdown of some of our USB services. A change was made to LinearOpMode so as to allow a given instance to be executed more than once, which is required for the App Inventor. Javadoc improved/updated. Release 16.03.09 Changes made to make the FTC SDK synchronous (significant change!) waitOneFullHardwareCycle() and waitForNextHardwareCycle() are no longer needed and have been deprecated. runOpMode() (for a LinearOpMode) is now decoupled from the system's hardware read/write thread. loop() (for an OpMode) is now decoupled from the system's hardware read/write thread. Methods are synchronous. For example, if you call setMode(DcMotorController.RunMode.RESET_ENCODERS) for a motor, the encoder is guaranteed to be reset when the method call is complete. For legacy module (NXT compatible), user no longer has to toggle between read and write modes when reading from or writing to a legacy device. Changes made to enhance reliability/robustness during ESD event. Changes made to make code thread safe. Debug keystore added so that user-generated robot controller APKs will all use the same signed key (to avoid conflicts if a team has multiple developer laptops for example). Firmware version information for Modern Robotics modules are now logged. Changes made to improve USB comm reliability and robustness. Added support for voltage indicator for legacy (NXT-compatible) motor controllers. Changes made to provide auto stop capabilities for op modes. A LinearOpMode class will stop when the statements in runOpMode() are complete. User does not have to push the stop button on the driver station. If an op mode is stopped by the driver station, but there is a run away/uninterruptible thread persisting, the app will log an error message then force itself to crash to stop the runaway thread. Driver Station UI modified to display lowest measured voltage below current voltage (12V battery). Driver Station UI modified to have color background for current voltage (green=good, yellow=caution, red=danger, extremely low voltage). javadoc improved (edits and additional classes). Added app build time to About activity for driver station and robot controller apps. Display local IP addresses on Driver Station About activity. Added I2cDeviceSynchImpl. Added I2cDeviceSync interface. Added seconds() and milliseconds() to ElapsedTime for clarity. Added getCallbackCount() to I2cDevice. Added missing clearI2cPortActionFlag. Added code to create log messages while waiting for LinearOpMode shutdown. Fix so Wifi Direct Config activity will no longer launch multiple times. Added the ability to specify an alternate i2c address in software for the Modern Robotics gyro. Release 16.02.09 Improved battery checker feature so that voltage values get refreshed regularly (every 250 msec) on Driver Station (DS) user interface. Improved software so that Robot Controller (RC) is much more resilient and “self-healing” to USB disconnects: If user attempts to start/restart RC with one or more module missing, it will display a warning but still start up. When running an op mode, if one or more modules gets disconnected, the RC & DS will display warnings,and robot will keep on working in spite of the missing module(s). If a disconnected module gets physically reconnected the RC will auto detect the module and the user will regain control of the recently connected module. Warning messages are more helpful (identifies the type of module that’s missing plus its USB serial number). Code changes to fix the null gamepad reference when users try to reference the gamepads in the init() portion of their op mode. NXT light sensor output is now properly scaled. Note that teams might have to readjust their light threshold values in their op modes. On DS user interface, gamepad icon for a driver will disappear if the matching gamepad is disconnected or if that gamepad gets designated as a different driver. Robot Protocol (ROBOCOL) version number info is displayed in About screen on RC and DS apps. Incorporated a display filter on pairing screen to filter out devices that don’t use the “-“ format. This filter can be turned off to show all WiFi Direct devices. Updated text in License file. Fixed formatting error in OpticalDistanceSensor.toString(). Fixed issue on with a blank (“”) device name that would disrupt WiFi Direct Pairing. Made a change so that the WiFi info and battery info can be displayed more quickly on the DS upon connecting to RC. Improved javadoc generation. Modified code to make it easier to support language localization in the future. Release 16.01.04 Updated compileSdkVersion for apps Prevent Wifi from entering power saving mode removed unused import from driver station Corrrected "Dead zone" joystick code. LED.getDeviceName and .getConnectionInfo() return null apps check for ROBOCOL_VERSION mismatch Fix for Telemetry also has off-by-one errors in its data string sizing / short size limitations error User telemetry output is sorted. added formatting variants to DbgLog and RobotLog APIs code modified to allow for a long list of op mode names. changes to improve thread safety of RobocolDatagramSocket Fix for "missing hardware leaves robot controller disconnected from driver station" error fix for "fast tapping of Init/Start causes problems" (toast is now only instantiated on UI thread). added some log statements for thread life cycle. moved gamepad reset logic inside of initActiveOpMode() for robustness changes made to mitigate risk of race conditions on public methods. changes to try and flag when WiFi Direct name contains non-printable characters. fix to correct race condition between .run() and .close() in ReadWriteRunnableStandard. updated FTDI driver made ReadWriteRunnableStanard interface public. fixed off-by-one errors in Command constructor moved specific hardware implmentations into their own package. moved specific gamepad implemnatations to the hardware library. changed LICENSE file to new BSD version. fixed race condition when shutting down Modern Robotics USB devices. methods in the ColorSensor classes have been synchronized. corrected isBusy() status to reflect end of motion. corrected "back" button keycode. the notSupported() method of the GyroSensor class was changed to protected (it should not be public). Release 15.11.04.001 Added Support for Modern Robotics Gyro. The GyroSensor class now supports the MR Gyro Sensor. Users can access heading data (about Z axis) Users can also access raw gyro data (X, Y, & Z axes). Example MRGyroTest.java op mode included. Improved error messages More descriptive error messages for exceptions in user code. Updated DcMotor API Enable read mode on new address in setI2cAddress Fix so that driver station app resets the gamepads when switching op modes. USB-related code changes to make USB comm more responsive and to display more explicit error messages. Fix so that USB will recover properly if the USB bus returns garbage data. Fix USB initializtion race condition. Better error reporting during FTDI open. More explicit messages during USB failures. Fixed bug so that USB device is closed if event loop teardown method was not called. Fixed timer UI issue Fixed duplicate name UI bug (Legacy Module configuration). Fixed race condition in EventLoopManager. Fix to keep references stable when updating gamepad. For legacy Matrix motor/servo controllers removed necessity of appending "Motor" and "Servo" to controller names. Updated HT color sensor driver to use constants from ModernRoboticsUsbLegacyModule class. Updated MR color sensor driver to use constants from ModernRoboticsUsbDeviceInterfaceModule class. Correctly handle I2C Address change in all color sensors Updated/cleaned up op modes. Updated comments in LinearI2cAddressChange.java example op mode. Replaced the calls to "setChannelMode" with "setMode" (to match the new of the DcMotor method). Removed K9AutoTime.java op mode. Added MRGyroTest.java op mode (demonstrates how to use MR Gyro Sensor). Added MRRGBExample.java op mode (demonstrates how to use MR Color Sensor). Added HTRGBExample.java op mode (demonstrates how to use HT legacy color sensor). Added MatrixControllerDemo.java (demonstrates how to use legacy Matrix controller). Updated javadoc documentation. Updated release .apk files for Robot Controller and Driver Station apps. Release 15.10.06.002 Added support for Legacy Matrix 9.6V motor/servo controller. Cleaned up build.gradle file. Minor UI and bug fixes for driver station and robot controller apps. Throws error if Ultrasonic sensor (NXT) is not configured for legacy module port 4 or 5. Release 15.08.03.001 New user interfaces for FTC Driver Station and FTC Robot Controller apps. An init() method is added to the OpMode class. For this release, init() is triggered right before the start() method. Eventually, the init() method will be triggered when the user presses an "INIT" button on driver station. The init() and loop() methods are now required (i.e., need to be overridden in the user's op mode). The start() and stop() methods are optional. A new LinearOpMode class is introduced. Teams can use the LinearOpMode mode to create a linear (not event driven) program model. Teams can use blocking statements like Thread.sleep() within a linear op mode. The API for the Legacy Module and Core Device Interface Module have been updated. Support for encoders with the Legacy Module is now working. The hardware loop has been updated for better performance.
aicodix / RattlegramTransceive UTF-8 text messages with up to 170 bytes over audio in about a second!
bivas / Protobuf Java FormatProvide serialization and de-serialization of different formats based on Google’s protobuf Message. Enables overriding the default (byte array) output to text based formats such as XML, JSON and HTML.
Masudbro94 / Python Hacked Mobile Phone Open in app Get started ITNEXT Published in ITNEXT You have 2 free member-only stories left this month. Sign up for Medium and get an extra one Kush Kush Follow Apr 15, 2021 · 7 min read · Listen Save How you can Control your Android Device with Python Photo by Caspar Camille Rubin on Unsplash Photo by Caspar Camille Rubin on Unsplash Introduction A while back I was thinking of ways in which I could annoy my friends by spamming them with messages for a few minutes, and while doing some research I came across the Android Debug Bridge. In this quick guide I will show you how you can interface with it using Python and how to create 2 quick scripts. The ADB (Android Debug Bridge) is a command line tool (CLI) which can be used to control and communicate with an Android device. You can do many things such as install apps, debug apps, find hidden features and use a shell to interface with the device directly. To enable the ADB, your device must firstly have Developer Options unlocked and USB debugging enabled. To unlock developer options, you can go to your devices settings and scroll down to the about section and find the build number of the current software which is on the device. Click the build number 7 times and Developer Options will be enabled. Then you can go to the Developer Options panel in the settings and enable USB debugging from there. Now the only other thing you need is a USB cable to connect your device to your computer. Here is what todays journey will look like: Installing the requirements Getting started The basics of writing scripts Creating a selfie timer Creating a definition searcher Installing the requirements The first of the 2 things we need to install, is the ADB tool on our computer. This comes automatically bundled with Android Studio, so if you already have that then do not worry. Otherwise, you can head over to the official docs and at the top of the page there should be instructions on how to install it. Once you have installed the ADB tool, you need to get the python library which we will use to interface with the ADB and our device. You can install the pure-python-adb library using pip install pure-python-adb. Optional: To make things easier for us while developing our scripts, we can install an open-source program called scrcpy which allows us to display and control our android device with our computer using a mouse and keyboard. To install it, you can head over to the Github repo and download the correct version for your operating system (Windows, macOS or Linux). If you are on Windows, then extract the zip file into a directory and add this directory to your path. This is so we can access the program from anywhere on our system just by typing in scrcpy into our terminal window. Getting started Now that all the dependencies are installed, we can start up our ADB and connect our device. Firstly, connect your device to your PC with the USB cable, if USB debugging is enabled then a message should pop up asking if it is okay for your PC to control the device, simply answer yes. Then on your PC, open up a terminal window and start the ADB server by typing in adb start-server. This should print out the following messages: * daemon not running; starting now at tcp:5037 * daemon started successfully If you also installed scrcpy, then you can start that by just typing scrcpy into the terminal. However, this will only work if you added it to your path, otherwise you can open the executable by changing your terminal directory to the directory of where you installed scrcpy and typing scrcpy.exe. Hopefully if everything works out, you should be able to see your device on your PC and be able to control it using your mouse and keyboard. Now we can create a new python file and check if we can find our connected device using the library: Here we import the AdbClient class and create a client object using it. Then we can get a list of devices connected. Lastly, we get the first device out of our list (it is generally the only one there if there is only one device connected). The basics of writing scripts The main way we are going to interface with our device is using the shell, through this we can send commands to simulate a touch at a specific location or to swipe from A to B. To simulate screen touches (taps) we first need to work out how the screen coordinates work. To help with these we can activate the pointer location setting in the developer options. Once activated, wherever you touch on the screen, you can see that the coordinates for that point appear at the top. The coordinate system works like this: A diagram to show how the coordinate system works A diagram to show how the coordinate system works The top left corner of the display has the x and y coordinates (0, 0) respectively, and the bottom right corners’ coordinates are the largest possible values of x and y. Now that we know how the coordinate system works, we need to check out the different commands we can run. I have made a list of commands and how to use them below for quick reference: Input tap x y Input text “hello world!” Input keyevent eventID Here is a list of some common eventID’s: 3: home button 4: back button 5: call 6: end call 24: volume up 25: volume down 26: turn device on or off 27: open camera 64: open browser 66: enter 67: backspace 207: contacts 220: brightness down 221: brightness up 277: cut 278: copy 279: paste If you wanted to find more, here is a long list of them here. Creating a selfie timer Now we know what we can do, let’s start doing it. In this first example I will show you how to create a quick selfie timer. To get started we need to import our libraries and create a connect function to connect to our device: You can see that the connect function is identical to the previous example of how to connect to your device, except here we return the device and client objects for later use. In our main code, we can call the connect function to retrieve the device and client objects. From there we can open up the camera app, wait 5 seconds and take a photo. It’s really that simple! As I said before, this is simply replicating what you would usually do, so thinking about how to do things is best if you do them yourself manually first and write down the steps. Creating a definition searcher We can do something a bit more complex now, and that is to ask the browser to find the definition of a particular word and take a screenshot to save it on our computer. The basic flow of this program will be as such: 1. Open the browser 2. Click the search bar 3. Enter the search query 4. Wait a few seconds 5. Take a screenshot and save it But, before we get started, you need to find the coordinates of your search bar in your default browser, you can use the method I suggested earlier to find them easily. For me they were (440, 200). To start, we will have to import the same libraries as before, and we will also have our same connect method. In our main function we can call the connect function, as well as assign a variable to the x and y coordinates of our search bar. Notice how this is a string and not a list or tuple, this is so we can easily incorporate the coordinates into our shell command. We can also take an input from the user to see what word they want to get the definition for: We will add that query to a full sentence which will then be searched, this is so that we can always get the definition. After that we can open the browser and input our search query into the search bar as such: Here we use the eventID 66 to simulate the press of the enter key to execute our search. If you wanted to, you could change the wait timings per your needs. Lastly, we will take a screenshot using the screencap method on our device object, and we can save that as a .png file: Here we must open the file in the write bytes mode because the screencap method returns bytes representing the image. If all went according to plan, you should have a quick script which searches for a specific word. Here it is working on my phone: A GIF to show how the definition searcher example works on my phone A GIF to show how the definition searcher example works on my phone Final thoughts Hopefully you have learned something new today, personally I never even knew this was a thing before I did some research into it. The cool thing is, that you can do anything you normal would be able to do, and more since it just simulates your own touches and actions! I hope you enjoyed the article and thank you for reading! 💖 468 9 468 9 More from ITNEXT Follow ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies. Sabrina Amrouche Sabrina Amrouche ·Apr 15, 2021 Using the Spotify Algorithm to Find High Energy Physics Particles Python 5 min read Using the Spotify Algorithm to Find High Energy Physics Particles Wenkai Fan Wenkai Fan ·Apr 14, 2021 Responsive design at different levels in Flutter Flutter 3 min read Responsive design at different levels in Flutter Abhishek Gupta Abhishek Gupta ·Apr 14, 2021 Getting started with Kafka and Rust: Part 2 Kafka 9 min read Getting started with Kafka and Rust: Part 2 Adriano Raiano Adriano Raiano ·Apr 14, 2021 How to properly internationalize a React application using i18next React 17 min read How to properly internationalize a React application using i18next Gary A. Stafford Gary A. Stafford ·Apr 14, 2021 AWS IoT Core for LoRaWAN, AWS IoT Analytics, and Amazon QuickSight Lora 11 min read AWS IoT Core for LoRaWAN, Amazon IoT Analytics, and Amazon QuickSight Read more from ITNEXT Recommended from Medium Morpheus Morpheus Morpheus Swap — Resurrection Ashutosh Kumar Ashutosh Kumar GIT Branching strategies and GitFlow Balachandar Paulraj Balachandar Paulraj Delta Lake Clones: Systematic Approach for Testing, Sharing data Jason Porter Jason Porter Week 3 -Yieldly No-Loss Lottery Results Casino slot machines Mikolaj Szabó Mikolaj Szabó in HackerNoon.com Why functional programming matters Tt Tt Set Up LaTeX on Mac OS X Sierra Goutham Pratapa Goutham Pratapa Upgrade mongo to the latest build Julia Says Julia Says in Top Software Developers in the World How to Choose a Software Vendor AboutHelpTermsPrivacy Get the Medium app A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ayaka14732 / TinyPE On Win10Smallest (268 bytes) 64-bit Portable Executable (PE) file that displays a message box on Windows 10
dh-orko / Help Me Get Rid Of Unhumans/* JS */ gapi.loaded_0(function(_){var window=this; var ha,ia,ja,ma,sa,na,ta,ya,Ja;_.ea=function(a){return function(){return _.da[a].apply(this,arguments)}};_._DumpException=function(a){throw a;};_.da=[];ha="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};ia="undefined"!=typeof window&&window===this?this:"undefined"!=typeof window.global&&null!=window.global?window.global:this;ja=function(){ja=function(){};ia.Symbol||(ia.Symbol=ma)}; ma=function(){var a=0;return function(b){return"jscomp_symbol_"+(b||"")+a++}}();sa=function(){ja();var a=ia.Symbol.iterator;a||(a=ia.Symbol.iterator=ia.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&ha(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return na(this)}});sa=function(){}};na=function(a){var b=0;return ta(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})};ta=function(a){sa();a={next:a};a[ia.Symbol.iterator]=function(){return this};return a}; _.wa=function(a){sa();var b=a[window.Symbol.iterator];return b?b.call(a):na(a)};_.xa="function"==typeof Object.create?Object.create:function(a){var b=function(){};b.prototype=a;return new b};if("function"==typeof Object.setPrototypeOf)ya=Object.setPrototypeOf;else{var Ba;a:{var Ca={a:!0},Da={};try{Da.__proto__=Ca;Ba=Da.a;break a}catch(a){}Ba=!1}ya=Ba?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null}_.Fa=ya; Ja=function(a,b){if(b){var c=ia;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&ha(c,a,{configurable:!0,writable:!0,value:b})}};Ja("Array.prototype.find",function(a){return a?a:function(a,c){a:{var b=this;b instanceof String&&(b=String(b));for(var e=b.length,f=0;f<e;f++){var h=b[f];if(a.call(c,h,f,b)){a=h;break a}}a=void 0}return a}});var Ka=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)}; Ja("WeakMap",function(a){function b(a){Ka(a,d)||ha(a,d,{value:{}})}function c(a){var c=Object[a];c&&(Object[a]=function(a){b(a);return c(a)})}if(function(){if(!a||!Object.seal)return!1;try{var b=Object.seal({}),c=Object.seal({}),d=new a([[b,2],[c,3]]);if(2!=d.get(b)||3!=d.get(c))return!1;d["delete"](b);d.set(c,4);return!d.has(b)&&4==d.get(c)}catch(n){return!1}}())return a;var d="$jscomp_hidden_"+Math.random();c("freeze");c("preventExtensions");c("seal");var e=0,f=function(a){this.Aa=(e+=Math.random()+ 1).toString();if(a){ja();sa();a=_.wa(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}};f.prototype.set=function(a,c){b(a);if(!Ka(a,d))throw Error("a`"+a);a[d][this.Aa]=c;return this};f.prototype.get=function(a){return Ka(a,d)?a[d][this.Aa]:void 0};f.prototype.has=function(a){return Ka(a,d)&&Ka(a[d],this.Aa)};f.prototype["delete"]=function(a){return Ka(a,d)&&Ka(a[d],this.Aa)?delete a[d][this.Aa]:!1};return f}); Ja("Map",function(a){if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var b=Object.seal({x:4}),c=new a(_.wa([[b,"s"]]));if("s"!=c.get(b)||1!=c.size||c.get({x:4})||c.set({x:4},"t")!=c||2!=c.size)return!1;var d=c.entries(),e=d.next();if(e.done||e.value[0]!=b||"s"!=e.value[1])return!1;e=d.next();return e.done||4!=e.value[0].x||"t"!=e.value[1]||!d.next().done?!1:!0}catch(q){return!1}}())return a;ja();sa();var b=new window.WeakMap,c=function(a){this.lf= {};this.Pe=f();this.size=0;if(a){a=_.wa(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}};c.prototype.set=function(a,b){var c=d(this,a);c.list||(c.list=this.lf[c.id]=[]);c.ke?c.ke.value=b:(c.ke={next:this.Pe,Pi:this.Pe.Pi,head:this.Pe,key:a,value:b},c.list.push(c.ke),this.Pe.Pi.next=c.ke,this.Pe.Pi=c.ke,this.size++);return this};c.prototype["delete"]=function(a){a=d(this,a);return a.ke&&a.list?(a.list.splice(a.index,1),a.list.length||delete this.lf[a.id],a.ke.Pi.next=a.ke.next,a.ke.next.Pi= a.ke.Pi,a.ke.head=null,this.size--,!0):!1};c.prototype.clear=function(){this.lf={};this.Pe=this.Pe.Pi=f();this.size=0};c.prototype.has=function(a){return!!d(this,a).ke};c.prototype.get=function(a){return(a=d(this,a).ke)&&a.value};c.prototype.entries=function(){return e(this,function(a){return[a.key,a.value]})};c.prototype.keys=function(){return e(this,function(a){return a.key})};c.prototype.values=function(){return e(this,function(a){return a.value})};c.prototype.forEach=function(a,b){for(var c=this.entries(), d;!(d=c.next()).done;)d=d.value,a.call(b,d[1],d[0],this)};c.prototype[window.Symbol.iterator]=c.prototype.entries;var d=function(a,c){var d=c&&typeof c;"object"==d||"function"==d?b.has(c)?d=b.get(c):(d=""+ ++h,b.set(c,d)):d="p_"+c;var e=a.lf[d];if(e&&Ka(a.lf,d))for(a=0;a<e.length;a++){var f=e[a];if(c!==c&&f.key!==f.key||c===f.key)return{id:d,list:e,index:a,ke:f}}return{id:d,list:e,index:-1,ke:void 0}},e=function(a,b){var c=a.Pe;return ta(function(){if(c){for(;c.head!=a.Pe;)c=c.Pi;for(;c.next!=c.head;)return c= c.next,{done:!1,value:b(c)};c=null}return{done:!0,value:void 0}})},f=function(){var a={};return a.Pi=a.next=a.head=a},h=0;return c}); Ja("Set",function(a){if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var b=Object.seal({x:4}),d=new a(_.wa([b]));if(!d.has(b)||1!=d.size||d.add(b)!=d||1!=d.size||d.add({x:4})!=d||2!=d.size)return!1;var e=d.entries(),f=e.next();if(f.done||f.value[0]!=b||f.value[1]!=b)return!1;f=e.next();return f.done||f.value[0]==b||4!=f.value[0].x||f.value[1]!=f.value[0]?!1:e.next().done}catch(h){return!1}}())return a;ja();sa();var b=function(a){this.V= new window.Map;if(a){a=_.wa(a);for(var b;!(b=a.next()).done;)this.add(b.value)}this.size=this.V.size};b.prototype.add=function(a){this.V.set(a,a);this.size=this.V.size;return this};b.prototype["delete"]=function(a){a=this.V["delete"](a);this.size=this.V.size;return a};b.prototype.clear=function(){this.V.clear();this.size=0};b.prototype.has=function(a){return this.V.has(a)};b.prototype.entries=function(){return this.V.entries()};b.prototype.values=function(){return this.V.values()};b.prototype.keys= b.prototype.values;b.prototype[window.Symbol.iterator]=b.prototype.values;b.prototype.forEach=function(a,b){var c=this;this.V.forEach(function(d){return a.call(b,d,d,c)})};return b});_.La=_.La||{};_.m=this;_.r=function(a){return void 0!==a};_.u=function(a){return"string"==typeof a}; _.Ma=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; else if("function"==b&&"undefined"==typeof a.call)return"object";return b};_.Oa=function(a){return"array"==_.Ma(a)};_.Pa="closure_uid_"+(1E9*Math.random()>>>0);_.Qa=Date.now||function(){return+new Date};_.w=function(a,b){a=a.split(".");var c=_.m;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&_.r(b)?c[d]=b:c=c[d]&&c[d]!==Object.prototype[d]?c[d]:c[d]={}}; _.z=function(a,b){function c(){}c.prototype=b.prototype;a.H=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.ep=function(a,c,f){for(var d=Array(arguments.length-2),e=2;e<arguments.length;e++)d[e-2]=arguments[e];return b.prototype[c].apply(a,d)}}; _.Ta=window.osapi=window.osapi||{}; window.___jsl=window.___jsl||{}; (window.___jsl.cd=window.___jsl.cd||[]).push({gwidget:{parsetags:"explicit"},appsapi:{plus_one_service:"/plus/v1"},csi:{rate:.01},poshare:{hangoutContactPickerServer:"https://plus.google.com"},gappsutil:{required_scopes:["https://www.googleapis.com/auth/plus.me","https://www.googleapis.com/auth/plus.people.recommended"],display_on_page_ready:!1},appsutil:{required_scopes:["https://www.googleapis.com/auth/plus.me","https://www.googleapis.com/auth/plus.people.recommended"],display_on_page_ready:!1}, "oauth-flow":{authUrl:"https://accounts.google.com/o/oauth2/auth",proxyUrl:"https://accounts.google.com/o/oauth2/postmessageRelay",redirectUri:"postmessage",loggingUrl:"https://accounts.google.com/o/oauth2/client_log"},iframes:{sharebox:{params:{json:"&"},url:":socialhost:/:session_prefix:_/sharebox/dialog"},plus:{url:":socialhost:/:session_prefix:_/widget/render/badge?usegapi=1"},":socialhost:":"https://apis.google.com",":im_socialhost:":"https://plus.googleapis.com",domains_suggest:{url:"https://domains.google.com/suggest/flow"}, card:{params:{s:"#",userid:"&"},url:":socialhost:/:session_prefix:_/hovercard/internalcard"},":signuphost:":"https://plus.google.com",":gplus_url:":"https://plus.google.com",plusone:{url:":socialhost:/:session_prefix:_/+1/fastbutton?usegapi=1"},plus_share:{url:":socialhost:/:session_prefix:_/+1/sharebutton?plusShare=true&usegapi=1"},plus_circle:{url:":socialhost:/:session_prefix:_/widget/plus/circle?usegapi=1"},plus_followers:{url:":socialhost:/_/im/_/widget/render/plus/followers?usegapi=1"},configurator:{url:":socialhost:/:session_prefix:_/plusbuttonconfigurator?usegapi=1"}, appcirclepicker:{url:":socialhost:/:session_prefix:_/widget/render/appcirclepicker"},page:{url:":socialhost:/:session_prefix:_/widget/render/page?usegapi=1"},person:{url:":socialhost:/:session_prefix:_/widget/render/person?usegapi=1"},community:{url:":ctx_socialhost:/:session_prefix::im_prefix:_/widget/render/community?usegapi=1"},follow:{url:":socialhost:/:session_prefix:_/widget/render/follow?usegapi=1"},commentcount:{url:":socialhost:/:session_prefix:_/widget/render/commentcount?usegapi=1"},comments:{url:":socialhost:/:session_prefix:_/widget/render/comments?usegapi=1"}, youtube:{url:":socialhost:/:session_prefix:_/widget/render/youtube?usegapi=1"},reportabuse:{url:":socialhost:/:session_prefix:_/widget/render/reportabuse?usegapi=1"},additnow:{url:":socialhost:/additnow/additnow.html"},udc_webconsentflow:{url:"https://myaccount.google.com/webconsent?usegapi=1"},appfinder:{url:"https://gsuite.google.com/:session_prefix:marketplace/appfinder?usegapi=1"},":source:":"1p"},poclient:{update_session:"google.updateSessionCallback"},"googleapis.config":{methods:{"pos.plusones.list":!0, "pos.plusones.get":!0,"pos.plusones.insert":!0,"pos.plusones.delete":!0,"pos.plusones.getSignupState":!0},versions:{pos:"v1"},rpc:"/rpc",root:"https://content.googleapis.com","root-1p":"https://clients6.google.com",useGapiForXd3:!0,xd3:"/static/proxy.html",developerKey:"AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ",auth:{useInterimAuth:!1}},report:{apis:["iframes\\..*","gadgets\\..*","gapi\\.appcirclepicker\\..*","gapi\\.client\\..*"],rate:1E-4},client:{perApiBatch:!0}}); var Za,eb,fb;_.Ua=function(a){return"number"==typeof a};_.Va=function(){};_.Wa=function(a){var b=_.Ma(a);return"array"==b||"object"==b&&"number"==typeof a.length};_.Xa=function(a){return"function"==_.Ma(a)};_.Ya=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b};Za=0;_.bb=function(a){return a[_.Pa]||(a[_.Pa]=++Za)};eb=function(a,b,c){return a.call.apply(a.bind,arguments)}; fb=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}};_.A=function(a,b,c){_.A=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?eb:fb;return _.A.apply(null,arguments)}; _.ib=Array.prototype.indexOf?function(a,b){return Array.prototype.indexOf.call(a,b,void 0)}:function(a,b){if(_.u(a))return _.u(b)&&1==b.length?a.indexOf(b,0):-1;for(var c=0;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1};_.jb=Array.prototype.lastIndexOf?function(a,b){return Array.prototype.lastIndexOf.call(a,b,a.length-1)}:function(a,b){var c=a.length-1;0>c&&(c=Math.max(0,a.length+c));if(_.u(a))return _.u(b)&&1==b.length?a.lastIndexOf(b,c):-1;for(;0<=c;c--)if(c in a&&a[c]===b)return c;return-1}; _.lb=Array.prototype.forEach?function(a,b,c){Array.prototype.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=_.u(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)};_.mb=Array.prototype.filter?function(a,b){return Array.prototype.filter.call(a,b,void 0)}:function(a,b){for(var c=a.length,d=[],e=0,f=_.u(a)?a.split(""):a,h=0;h<c;h++)if(h in f){var k=f[h];b.call(void 0,k,h,a)&&(d[e++]=k)}return d}; _.nb=Array.prototype.map?function(a,b){return Array.prototype.map.call(a,b,void 0)}:function(a,b){for(var c=a.length,d=Array(c),e=_.u(a)?a.split(""):a,f=0;f<c;f++)f in e&&(d[f]=b.call(void 0,e[f],f,a));return d};_.ob=Array.prototype.some?function(a,b,c){return Array.prototype.some.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=_.u(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return!0;return!1}; _.qb=Array.prototype.every?function(a,b,c){return Array.prototype.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=_.u(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0};_.rb=function(a,b){return 0<=(0,_.ib)(a,b)}; var vb;_.sb=function(a){return/^[\s\xa0]*$/.test(a)};_.tb=String.prototype.trim?function(a){return a.trim()}:function(a){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(a)[1]};_.ub=String.prototype.repeat?function(a,b){return a.repeat(b)}:function(a,b){return Array(b+1).join(a)}; _.xb=function(a,b){var c=0;a=(0,_.tb)(String(a)).split(".");b=(0,_.tb)(String(b)).split(".");for(var d=Math.max(a.length,b.length),e=0;0==c&&e<d;e++){var f=a[e]||"",h=b[e]||"";do{f=/(\d*)(\D*)(.*)/.exec(f)||["","","",""];h=/(\d*)(\D*)(.*)/.exec(h)||["","","",""];if(0==f[0].length&&0==h[0].length)break;c=vb(0==f[1].length?0:(0,window.parseInt)(f[1],10),0==h[1].length?0:(0,window.parseInt)(h[1],10))||vb(0==f[2].length,0==h[2].length)||vb(f[2],h[2]);f=f[3];h=h[3]}while(0==c)}return c}; vb=function(a,b){return a<b?-1:a>b?1:0};_.yb=2147483648*Math.random()|0; a:{var Bb=_.m.navigator;if(Bb){var Cb=Bb.userAgent;if(Cb){_.Ab=Cb;break a}}_.Ab=""}_.Db=function(a){return-1!=_.Ab.indexOf(a)};var Fb;_.Eb=function(a,b,c){for(var d in a)b.call(c,a[d],d,a)};Fb="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");_.Gb=function(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<Fb.length;f++)c=Fb[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}}; _.Hb=function(){return _.Db("Opera")};_.Ib=function(){return _.Db("Trident")||_.Db("MSIE")};_.Lb=function(){return _.Db("iPhone")&&!_.Db("iPod")&&!_.Db("iPad")};_.Mb=function(){return _.Lb()||_.Db("iPad")||_.Db("iPod")};var Nb=function(a){Nb[" "](a);return a},Sb;Nb[" "]=_.Va;_.Qb=function(a,b){try{return Nb(a[b]),!0}catch(c){}return!1};Sb=function(a,b){var c=Rb;return Object.prototype.hasOwnProperty.call(c,a)?c[a]:c[a]=b(a)};var gc,hc,Rb,pc;_.Tb=_.Hb();_.C=_.Ib();_.Ub=_.Db("Edge");_.Vb=_.Ub||_.C;_.Wb=_.Db("Gecko")&&!(-1!=_.Ab.toLowerCase().indexOf("webkit")&&!_.Db("Edge"))&&!(_.Db("Trident")||_.Db("MSIE"))&&!_.Db("Edge");_.Xb=-1!=_.Ab.toLowerCase().indexOf("webkit")&&!_.Db("Edge");_.Yb=_.Xb&&_.Db("Mobile");_.Zb=_.Db("Macintosh");_.$b=_.Db("Windows");_.ac=_.Db("Linux")||_.Db("CrOS");_.bc=_.Db("Android");_.cc=_.Lb();_.dc=_.Db("iPad");_.ec=_.Db("iPod");_.fc=_.Mb(); gc=function(){var a=_.m.document;return a?a.documentMode:void 0};a:{var ic="",jc=function(){var a=_.Ab;if(_.Wb)return/rv:([^\);]+)(\)|;)/.exec(a);if(_.Ub)return/Edge\/([\d\.]+)/.exec(a);if(_.C)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(_.Xb)return/WebKit\/(\S+)/.exec(a);if(_.Tb)return/(?:Version)[ \/]?(\S+)/.exec(a)}();jc&&(ic=jc?jc[1]:"");if(_.C){var kc=gc();if(null!=kc&&kc>(0,window.parseFloat)(ic)){hc=String(kc);break a}}hc=ic}_.lc=hc;Rb={}; _.mc=function(a){return Sb(a,function(){return 0<=_.xb(_.lc,a)})};_.oc=function(a){return Number(_.nc)>=a};var qc=_.m.document;pc=qc&&_.C?gc()||("CSS1Compat"==qc.compatMode?(0,window.parseInt)(_.lc,10):5):void 0;_.nc=pc; var sc,wc,xc,yc,zc,Ac,Bc,Cc;_.rc=function(a,b){return _.da[a]=b};_.tc=function(a){return Array.prototype.concat.apply([],arguments)};_.uc=function(a){var b=a.length;if(0<b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c}return[]};_.vc=function(a,b){return 0==a.lastIndexOf(b,0)};wc=/&/g;xc=/</g;yc=/>/g;zc=/"/g;Ac=/'/g;Bc=/\x00/g;Cc=/[\x00&<>"']/; _.Dc=function(a){if(!Cc.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(wc,"&"));-1!=a.indexOf("<")&&(a=a.replace(xc,"<"));-1!=a.indexOf(">")&&(a=a.replace(yc,">"));-1!=a.indexOf('"')&&(a=a.replace(zc,"""));-1!=a.indexOf("'")&&(a=a.replace(Ac,"'"));-1!=a.indexOf("\x00")&&(a=a.replace(Bc,"�"));return a};_.Fc=function(a){return String(a).replace(/\-([a-z])/g,function(a,c){return c.toUpperCase()})};_.Gc=function(a,b){for(var c in a)if(a[c]==b)return!0;return!1}; var Hc,Ic;Hc=!_.C||_.oc(9);Ic=!_.Wb&&!_.C||_.C&&_.oc(9)||_.Wb&&_.mc("1.9.1");_.Jc=_.C&&!_.mc("9");_.Kc=_.C||_.Tb||_.Xb;_.Lc=_.C&&!_.oc(9);var Mc;_.Nc=function(){this.uw="";this.bP=Mc};_.Nc.prototype.Ch=!0;_.Nc.prototype.dg=function(){return this.uw};_.Nc.prototype.toString=function(){return"Const{"+this.uw+"}"};_.Oc=function(a){return a instanceof _.Nc&&a.constructor===_.Nc&&a.bP===Mc?a.uw:"type_error:Const"};Mc={};_.Pc=function(a){var b=new _.Nc;b.uw=a;return b};_.Pc(""); var Qc;_.Rc=function(){this.bC="";this.lP=Qc};_.Rc.prototype.Ch=!0;_.Rc.prototype.dg=function(){return this.bC};_.Rc.prototype.GA=!0;_.Rc.prototype.kl=function(){return 1};_.Sc=function(a){if(a instanceof _.Rc&&a.constructor===_.Rc&&a.lP===Qc)return a.bC;_.Ma(a);return"type_error:TrustedResourceUrl"};_.Uc=function(a){return _.Tc(_.Oc(a))};Qc={};_.Tc=function(a){var b=new _.Rc;b.bC=a;return b}; var Yc,Vc,Zc;_.Wc=function(){this.Zl="";this.VO=Vc};_.Wc.prototype.Ch=!0;_.Wc.prototype.dg=function(){return this.Zl};_.Wc.prototype.GA=!0;_.Wc.prototype.kl=function(){return 1};_.Xc=function(a){if(a instanceof _.Wc&&a.constructor===_.Wc&&a.VO===Vc)return a.Zl;_.Ma(a);return"type_error:SafeUrl"};Yc=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;_.$c=function(a){if(a instanceof _.Wc)return a;a=a.Ch?a.dg():String(a);Yc.test(a)||(a="about:invalid#zClosurez");return Zc(a)}; _.ad=function(a){if(a instanceof _.Wc)return a;a=a.Ch?a.dg():String(a);Yc.test(a)||(a="about:invalid#zClosurez");return Zc(a)};Vc={};Zc=function(a){var b=new _.Wc;b.Zl=a;return b};Zc("about:blank"); _.dd=function(){this.aC="";this.UO=_.bd};_.dd.prototype.Ch=!0;_.bd={};_.dd.prototype.dg=function(){return this.aC};_.dd.prototype.Bi=function(a){this.aC=a;return this};_.ed=(new _.dd).Bi("");_.gd=function(){this.$B="";this.TO=_.fd};_.gd.prototype.Ch=!0;_.fd={};_.id=function(a){a=_.Oc(a);return 0===a.length?hd:(new _.gd).Bi(a)};_.gd.prototype.dg=function(){return this.$B};_.gd.prototype.Bi=function(a){this.$B=a;return this};var hd=(new _.gd).Bi(""); var jd;_.kd=function(){this.Zl="";this.SO=jd;this.qG=null};_.kd.prototype.GA=!0;_.kd.prototype.kl=function(){return this.qG};_.kd.prototype.Ch=!0;_.kd.prototype.dg=function(){return this.Zl};_.ld=function(a){if(a instanceof _.kd&&a.constructor===_.kd&&a.SO===jd)return a.Zl;_.Ma(a);return"type_error:SafeHtml"};jd={};_.nd=function(a,b){return(new _.kd).Bi(a,b)};_.kd.prototype.Bi=function(a,b){this.Zl=a;this.qG=b;return this};_.nd("<!DOCTYPE html>",0);_.od=_.nd("",0);_.pd=_.nd("<br>",0); _.qd=function(a,b){b=b instanceof _.Wc?b:_.ad(b);a.href=_.Xc(b)};var wd,yd,Ad;_.td=function(a){return a?new _.rd(_.sd(a)):sc||(sc=new _.rd)};_.ud=function(a,b){return _.u(b)?a.getElementById(b):b}; _.vd=function(a,b,c,d){a=d||a;b=b&&"*"!=b?String(b).toUpperCase():"";if(a.querySelectorAll&&a.querySelector&&(b||c))return a.querySelectorAll(b+(c?"."+c:""));if(c&&a.getElementsByClassName){a=a.getElementsByClassName(c);if(b){d={};for(var e=0,f=0,h;h=a[f];f++)b==h.nodeName&&(d[e++]=h);d.length=e;return d}return a}a=a.getElementsByTagName(b||"*");if(c){d={};for(f=e=0;h=a[f];f++)b=h.className,"function"==typeof b.split&&_.rb(b.split(/\s+/),c)&&(d[e++]=h);d.length=e;return d}return a}; _.xd=function(a,b){_.Eb(b,function(b,d){b&&b.Ch&&(b=b.dg());"style"==d?a.style.cssText=b:"class"==d?a.className=b:"for"==d?a.htmlFor=b:wd.hasOwnProperty(d)?a.setAttribute(wd[d],b):_.vc(d,"aria-")||_.vc(d,"data-")?a.setAttribute(d,b):a[d]=b})};wd={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"}; _.zd=function(a,b){var c=String(b[0]),d=b[1];if(!Hc&&d&&(d.name||d.type)){c=["<",c];d.name&&c.push(' name="',_.Dc(d.name),'"');if(d.type){c.push(' type="',_.Dc(d.type),'"');var e={};_.Gb(e,d);delete e.type;d=e}c.push(">");c=c.join("")}c=a.createElement(c);d&&(_.u(d)?c.className=d:_.Oa(d)?c.className=d.join(" "):_.xd(c,d));2<b.length&&yd(a,c,b,2);return c}; yd=function(a,b,c,d){function e(c){c&&b.appendChild(_.u(c)?a.createTextNode(c):c)}for(;d<c.length;d++){var f=c[d];!_.Wa(f)||_.Ya(f)&&0<f.nodeType?e(f):(0,_.lb)(Ad(f)?_.uc(f):f,e)}};_.Bd=function(a){return window.document.createElement(String(a))};_.Dd=function(a){if(1!=a.nodeType)return!1;switch(a.tagName){case "APPLET":case "AREA":case "BASE":case "BR":case "COL":case "COMMAND":case "EMBED":case "FRAME":case "HR":case "IMG":case "INPUT":case "IFRAME":case "ISINDEX":case "KEYGEN":case "LINK":case "NOFRAMES":case "NOSCRIPT":case "META":case "OBJECT":case "PARAM":case "SCRIPT":case "SOURCE":case "STYLE":case "TRACK":case "WBR":return!1}return!0}; _.Ed=function(a,b){yd(_.sd(a),a,arguments,1)};_.Fd=function(a){for(var b;b=a.firstChild;)a.removeChild(b)};_.Gd=function(a,b){b.parentNode&&b.parentNode.insertBefore(a,b)};_.Hd=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):null};_.Id=function(a){var b,c=a.parentNode;if(c&&11!=c.nodeType){if(a.removeNode)return a.removeNode(!1);for(;b=a.firstChild;)c.insertBefore(b,a);return _.Hd(a)}}; _.Jd=function(a){return Ic&&void 0!=a.children?a.children:(0,_.mb)(a.childNodes,function(a){return 1==a.nodeType})};_.Kd=function(a){return _.Ya(a)&&1==a.nodeType};_.Ld=function(a,b){if(!a||!b)return!1;if(a.contains&&1==b.nodeType)return a==b||a.contains(b);if("undefined"!=typeof a.compareDocumentPosition)return a==b||!!(a.compareDocumentPosition(b)&16);for(;b&&a!=b;)b=b.parentNode;return b==a};_.sd=function(a){return 9==a.nodeType?a:a.ownerDocument||a.document}; _.Md=function(a,b){if("textContent"in a)a.textContent=b;else if(3==a.nodeType)a.data=String(b);else if(a.firstChild&&3==a.firstChild.nodeType){for(;a.lastChild!=a.firstChild;)a.removeChild(a.lastChild);a.firstChild.data=String(b)}else _.Fd(a),a.appendChild(_.sd(a).createTextNode(String(b)))};Ad=function(a){if(a&&"number"==typeof a.length){if(_.Ya(a))return"function"==typeof a.item||"string"==typeof a.item;if(_.Xa(a))return"function"==typeof a.item}return!1}; _.rd=function(a){this.Va=a||_.m.document||window.document};_.g=_.rd.prototype;_.g.Ea=_.td;_.g.RC=_.ea(0);_.g.mb=function(){return this.Va};_.g.S=function(a){return _.ud(this.Va,a)};_.g.getElementsByTagName=function(a,b){return(b||this.Va).getElementsByTagName(String(a))};_.g.ma=function(a,b,c){return _.zd(this.Va,arguments)};_.g.createElement=function(a){return this.Va.createElement(String(a))};_.g.createTextNode=function(a){return this.Va.createTextNode(String(a))}; _.g.vb=function(){var a=this.Va;return a.parentWindow||a.defaultView};_.g.appendChild=function(a,b){a.appendChild(b)};_.g.append=_.Ed;_.g.canHaveChildren=_.Dd;_.g.xe=_.Fd;_.g.GI=_.Gd;_.g.removeNode=_.Hd;_.g.qR=_.Id;_.g.xz=_.Jd;_.g.isElement=_.Kd;_.g.contains=_.Ld;_.g.Eh=_.ea(1); /* gapi.loader.OBJECT_CREATE_TEST_OVERRIDE &&*/ _.Nd=window;_.Qd=window.document;_.Rd=_.Nd.location;_.Sd=/\[native code\]/;_.Td=function(a,b,c){return a[b]=a[b]||c};_.D=function(){var a;if((a=Object.create)&&_.Sd.test(a))a=a(null);else{a={};for(var b in a)a[b]=void 0}return a};_.Ud=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};_.Vd=function(a,b){a=a||{};for(var c in a)_.Ud(a,c)&&(b[c]=a[c])};_.Wd=_.Td(_.Nd,"gapi",{}); _.Xd=function(a,b,c){var d=new RegExp("([#].*&|[#])"+b+"=([^&#]*)","g");b=new RegExp("([?#].*&|[?#])"+b+"=([^&#]*)","g");if(a=a&&(d.exec(a)||b.exec(a)))try{c=(0,window.decodeURIComponent)(a[2])}catch(e){}return c};_.Yd=new RegExp(/^/.source+/([a-zA-Z][-+.a-zA-Z0-9]*:)?/.source+/(\/\/[^\/?#]*)?/.source+/([^?#]*)?/.source+/(\?([^#]*))?/.source+/(#((#|[^#])*))?/.source+/$/.source); _.Zd=new RegExp(/(%([^0-9a-fA-F%]|[0-9a-fA-F]([^0-9a-fA-F%])?)?)*/.source+/%($|[^0-9a-fA-F]|[0-9a-fA-F]($|[^0-9a-fA-F]))/.source,"g");_.$d=new RegExp(/\/?\??#?/.source+"("+/[\/?#]/i.source+"|"+/[\uD800-\uDBFF]/i.source+"|"+/%[c-f][0-9a-f](%[89ab][0-9a-f]){0,2}(%[89ab]?)?/i.source+"|"+/%[0-9a-f]?/i.source+")$","i"); _.be=function(a,b,c){_.ae(a,b,c,"add","at")};_.ae=function(a,b,c,d,e){if(a[d+"EventListener"])a[d+"EventListener"](b,c,!1);else if(a[e+"tachEvent"])a[e+"tachEvent"]("on"+b,c)};_.ce=_.Td(_.Nd,"___jsl",_.D());_.Td(_.ce,"I",0);_.Td(_.ce,"hel",10);var ee,fe,ge,he,ie,je,ke;ee=function(a){var b=window.___jsl=window.___jsl||{};b[a]=b[a]||[];return b[a]};fe=function(a){var b=window.___jsl=window.___jsl||{};b.cfg=!a&&b.cfg||{};return b.cfg};ge=function(a){return"object"===typeof a&&/\[native code\]/.test(a.push)}; he=function(a,b,c){if(b&&"object"===typeof b)for(var d in b)!Object.prototype.hasOwnProperty.call(b,d)||c&&"___goc"===d&&"undefined"===typeof b[d]||(a[d]&&b[d]&&"object"===typeof a[d]&&"object"===typeof b[d]&&!ge(a[d])&&!ge(b[d])?he(a[d],b[d]):b[d]&&"object"===typeof b[d]?(a[d]=ge(b[d])?[]:{},he(a[d],b[d])):a[d]=b[d])}; ie=function(a){if(a&&!/^\s+$/.test(a)){for(;0==a.charCodeAt(a.length-1);)a=a.substring(0,a.length-1);try{var b=window.JSON.parse(a)}catch(c){}if("object"===typeof b)return b;try{b=(new Function("return ("+a+"\n)"))()}catch(c){}if("object"===typeof b)return b;try{b=(new Function("return ({"+a+"\n})"))()}catch(c){}return"object"===typeof b?b:{}}}; je=function(a,b){var c={___goc:void 0};a.length&&a[a.length-1]&&Object.hasOwnProperty.call(a[a.length-1],"___goc")&&"undefined"===typeof a[a.length-1].___goc&&(c=a.pop());he(c,b);a.push(c)}; ke=function(a){fe(!0);var b=window.___gcfg,c=ee("cu"),d=window.___gu;b&&b!==d&&(je(c,b),window.___gu=b);b=ee("cu");var e=window.document.scripts||window.document.getElementsByTagName("script")||[];d=[];var f=[];f.push.apply(f,ee("us"));for(var h=0;h<e.length;++h)for(var k=e[h],l=0;l<f.length;++l)k.src&&0==k.src.indexOf(f[l])&&d.push(k);0==d.length&&0<e.length&&e[e.length-1].src&&d.push(e[e.length-1]);for(e=0;e<d.length;++e)d[e].getAttribute("gapi_processed")||(d[e].setAttribute("gapi_processed",!0), (f=d[e])?(h=f.nodeType,f=3==h||4==h?f.nodeValue:f.textContent||f.innerText||f.innerHTML||""):f=void 0,(f=ie(f))&&b.push(f));a&&je(c,a);d=ee("cd");a=0;for(b=d.length;a<b;++a)he(fe(),d[a],!0);d=ee("ci");a=0;for(b=d.length;a<b;++a)he(fe(),d[a],!0);a=0;for(b=c.length;a<b;++a)he(fe(),c[a],!0)};_.H=function(a,b){var c=fe();if(!a)return c;a=a.split("/");for(var d=0,e=a.length;c&&"object"===typeof c&&d<e;++d)c=c[a[d]];return d===a.length&&void 0!==c?c:b}; _.le=function(a,b){var c;if("string"===typeof a){var d=c={};a=a.split("/");for(var e=0,f=a.length;e<f-1;++e){var h={};d=d[a[e]]=h}d[a[e]]=b}else c=a;ke(c)}; var me=function(){var a=window.__GOOGLEAPIS;a&&(a.googleapis&&!a["googleapis.config"]&&(a["googleapis.config"]=a.googleapis),_.Td(_.ce,"ci",[]).push(a),window.__GOOGLEAPIS=void 0)};me&&me();ke();_.w("gapi.config.get",_.H);_.w("gapi.config.update",_.le); _.ne=function(a,b){var c=b||window.document;if(c.getElementsByClassName)a=c.getElementsByClassName(a)[0];else{c=window.document;var d=b||c;a=d.querySelectorAll&&d.querySelector&&a?d.querySelector(a?"."+a:""):_.vd(c,"*",a,b)[0]||null}return a||null}; var xe,ye,ze,Ae,Be,Ce,De,Ee,Fe,Ge,He,Ie,Je,Ke,Le,Me,Ne,Oe,Pe,Qe,Re,Se,Te,Ue,Ve,We,Xe,Ze,$e,af,bf,ef,ff;ze=void 0;Ae=function(a){try{return _.m.JSON.parse.call(_.m.JSON,a)}catch(b){return!1}};Be=function(a){return Object.prototype.toString.call(a)};Ce=Be(0);De=Be(new Date(0));Ee=Be(!0);Fe=Be("");Ge=Be({});He=Be([]); Ie=function(a,b){if(b)for(var c=0,d=b.length;c<d;++c)if(a===b[c])throw new TypeError("Converting circular structure to JSON");d=typeof a;if("undefined"!==d){c=Array.prototype.slice.call(b||[],0);c[c.length]=a;b=[];var e=Be(a);if(null!=a&&"function"===typeof a.toJSON&&(Object.prototype.hasOwnProperty.call(a,"toJSON")||(e!==He||a.constructor!==Array&&a.constructor!==Object)&&(e!==Ge||a.constructor!==Array&&a.constructor!==Object)&&e!==Fe&&e!==Ce&&e!==Ee&&e!==De))return Ie(a.toJSON.call(a),c);if(null== a)b[b.length]="null";else if(e===Ce)a=Number(a),(0,window.isNaN)(a)||(0,window.isNaN)(a-a)?a="null":-0===a&&0>1/a&&(a="-0"),b[b.length]=String(a);else if(e===Ee)b[b.length]=String(!!Number(a));else{if(e===De)return Ie(a.toISOString.call(a),c);if(e===He&&Be(a.length)===Ce){b[b.length]="[";var f=0;for(d=Number(a.length)>>0;f<d;++f)f&&(b[b.length]=","),b[b.length]=Ie(a[f],c)||"null";b[b.length]="]"}else if(e==Fe&&Be(a.length)===Ce){b[b.length]='"';f=0;for(c=Number(a.length)>>0;f<c;++f)d=String.prototype.charAt.call(a, f),e=String.prototype.charCodeAt.call(a,f),b[b.length]="\b"===d?"\\b":"\f"===d?"\\f":"\n"===d?"\\n":"\r"===d?"\\r":"\t"===d?"\\t":"\\"===d||'"'===d?"\\"+d:31>=e?"\\u"+(e+65536).toString(16).substr(1):32<=e&&65535>=e?d:"\ufffd";b[b.length]='"'}else if("object"===d){b[b.length]="{";d=0;for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&(e=Ie(a[f],c),void 0!==e&&(d++&&(b[b.length]=","),b[b.length]=Ie(f),b[b.length]=":",b[b.length]=e));b[b.length]="}"}else return}return b.join("")}};Je=/[\0-\x07\x0b\x0e-\x1f]/; Ke=/^([^"]*"([^\\"]|\\.)*")*[^"]*"([^"\\]|\\.)*[\0-\x1f]/;Le=/^([^"]*"([^\\"]|\\.)*")*[^"]*"([^"\\]|\\.)*\\[^\\\/"bfnrtu]/;Me=/^([^"]*"([^\\"]|\\.)*")*[^"]*"([^"\\]|\\.)*\\u([0-9a-fA-F]{0,3}[^0-9a-fA-F])/;Ne=/"([^\0-\x1f\\"]|\\[\\\/"bfnrt]|\\u[0-9a-fA-F]{4})*"/g;Oe=/-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?/g;Pe=/[ \t\n\r]+/g;Qe=/[^"]:/;Re=/""/g;Se=/true|false|null/g;Te=/00/;Ue=/[\{]([^0\}]|0[^:])/;Ve=/(^|\[)[,:]|[,:](\]|\}|[,:]|$)/;We=/[^\[,:][\[\{]/;Xe=/^(\{|\}|\[|\]|,|:|0)+/;Ze=/\u2028/g; $e=/\u2029/g; af=function(a){a=String(a);if(Je.test(a)||Ke.test(a)||Le.test(a)||Me.test(a))return!1;var b=a.replace(Ne,'""');b=b.replace(Oe,"0");b=b.replace(Pe,"");if(Qe.test(b))return!1;b=b.replace(Re,"0");b=b.replace(Se,"0");if(Te.test(b)||Ue.test(b)||Ve.test(b)||We.test(b)||!b||(b=b.replace(Xe,"")))return!1;a=a.replace(Ze,"\\u2028").replace($e,"\\u2029");b=void 0;try{b=ze?[Ae(a)]:eval("(function (var_args) {\n return Array.prototype.slice.call(arguments, 0);\n})(\n"+a+"\n)")}catch(c){return!1}return b&&1=== b.length?b[0]:!1};bf=function(){var a=((_.m.document||{}).scripts||[]).length;if((void 0===xe||void 0===ze||ye!==a)&&-1!==ye){xe=ze=!1;ye=-1;try{try{ze=!!_.m.JSON&&'{"a":[3,true,"1970-01-01T00:00:00.000Z"]}'===_.m.JSON.stringify.call(_.m.JSON,{a:[3,!0,new Date(0)],c:function(){}})&&!0===Ae("true")&&3===Ae('[{"a":3}]')[0].a}catch(b){}xe=ze&&!Ae("[00]")&&!Ae('"\u0007"')&&!Ae('"\\0"')&&!Ae('"\\v"')}finally{ye=a}}};_.cf=function(a){if(-1===ye)return!1;bf();return(xe?Ae:af)(a)}; _.df=function(a){if(-1!==ye)return bf(),ze?_.m.JSON.stringify.call(_.m.JSON,a):Ie(a)};ef=!Date.prototype.toISOString||"function"!==typeof Date.prototype.toISOString||"1970-01-01T00:00:00.000Z"!==(new Date(0)).toISOString(); ff=function(){var a=Date.prototype.getUTCFullYear.call(this);return[0>a?"-"+String(1E6-a).substr(1):9999>=a?String(1E4+a).substr(1):"+"+String(1E6+a).substr(1),"-",String(101+Date.prototype.getUTCMonth.call(this)).substr(1),"-",String(100+Date.prototype.getUTCDate.call(this)).substr(1),"T",String(100+Date.prototype.getUTCHours.call(this)).substr(1),":",String(100+Date.prototype.getUTCMinutes.call(this)).substr(1),":",String(100+Date.prototype.getUTCSeconds.call(this)).substr(1),".",String(1E3+Date.prototype.getUTCMilliseconds.call(this)).substr(1), "Z"].join("")};Date.prototype.toISOString=ef?ff:Date.prototype.toISOString; _.w("gadgets.json.stringify",_.df);_.w("gadgets.json.parse",_.cf); _.Xj=window.gapi&&window.gapi.util||{}; _.Zj=function(a){if(!a)return"";a=a.split("#")[0].split("?")[0];a=a.toLowerCase();0==a.indexOf("//")&&(a=window.location.protocol+a);/^[\w\-]*:\/\//.test(a)||(a=window.location.href);var b=a.substring(a.indexOf("://")+3),c=b.indexOf("/");-1!=c&&(b=b.substring(0,c));a=a.substring(0,a.indexOf("://"));if("http"!==a&&"https"!==a&&"chrome-extension"!==a&&"file"!==a&&"android-app"!==a&&"chrome-search"!==a&&"app"!==a)throw Error("L`"+a);c="";var d=b.indexOf(":");if(-1!=d){var e=b.substring(d+1);b=b.substring(0, d);if("http"===a&&"80"!==e||"https"===a&&"443"!==e)c=":"+e}return a+"://"+b+c}; _.Xj.Qa=function(a){return _.Zj(a)}; _.qe=window.console;_.ue=function(a){_.qe&&_.qe.log&&_.qe.log(a)};_.ve=function(){}; _.I=_.I||{}; _.I=_.I||{}; (function(){var a=null;_.I.xc=function(b){var c="undefined"===typeof b;if(null!==a&&c)return a;var d={};b=b||window.location.href;var e=b.indexOf("?"),f=b.indexOf("#");b=(-1===f?b.substr(e+1):[b.substr(e+1,f-e-1),"&",b.substr(f+1)].join("")).split("&");e=window.decodeURIComponent?window.decodeURIComponent:window.unescape;f=0;for(var h=b.length;f<h;++f){var k=b[f].indexOf("=");if(-1!==k){var l=b[f].substring(0,k);k=b[f].substring(k+1);k=k.replace(/\+/g," ");try{d[l]=e(k)}catch(n){}}}c&&(a=d);return d}; _.I.xc()})(); _.w("gadgets.util.getUrlParameters",_.I.xc); _.Xd(_.Nd.location.href,"rpctoken")&&_.be(_.Qd,"unload",function(){}); var dm=function(){this.$r={tK:Xl?"../"+Xl:null,NQ:Yl,GH:Zl,C9:$l,eu:am,l$:bm};this.Ee=_.Nd;this.gK=this.JQ;this.tR=/MSIE\s*[0-8](\D|$)/.test(window.navigator.userAgent);if(this.$r.tK){this.Ee=this.$r.GH(this.Ee,this.$r.tK);var a=this.Ee.document,b=a.createElement("script");b.setAttribute("type","text/javascript");b.text="window.doPostMsg=function(w,s,o) {window.setTimeout(function(){w.postMessage(s,o);},0);};";a.body.appendChild(b);this.gK=this.Ee.doPostMsg}this.kD={};this.FD={};a=(0,_.A)(this.hA, this);_.be(this.Ee,"message",a);_.Td(_.ce,"RPMQ",[]).push(a);this.Ee!=this.Ee.parent&&cm(this,this.Ee.parent,'{"h":"'+(0,window.escape)(this.Ee.name)+'"}',"*")},em=function(a){var b=null;0===a.indexOf('{"h":"')&&a.indexOf('"}')===a.length-2&&(b=(0,window.unescape)(a.substring(6,a.length-2)));return b},fm=function(a){if(!/^\s*{/.test(a))return!1;a=_.cf(a);return null!==a&&"object"===typeof a&&!!a.g}; dm.prototype.hA=function(a){var b=String(a.data);(0,_.ve)("gapi.rpc.receive("+$l+"): "+(!b||512>=b.length?b:b.substr(0,512)+"... ("+b.length+" bytes)"));var c=0!==b.indexOf("!_");c||(b=b.substring(2));var d=fm(b);if(!c&&!d){if(!d&&(c=em(b))){if(this.kD[c])this.kD[c]();else this.FD[c]=1;return}var e=a.origin,f=this.$r.NQ;this.tR?_.Nd.setTimeout(function(){f(b,e)},0):f(b,e)}};dm.prototype.Dc=function(a,b){".."===a||this.FD[a]?(b(),delete this.FD[a]):this.kD[a]=b}; var cm=function(a,b,c,d){var e=fm(c)?"":"!_";(0,_.ve)("gapi.rpc.send("+$l+"): "+(!c||512>=c.length?c:c.substr(0,512)+"... ("+c.length+" bytes)"));a.gK(b,e+c,d)};dm.prototype.JQ=function(a,b,c){a.postMessage(b,c)};dm.prototype.send=function(a,b,c){(a=this.$r.GH(this.Ee,a))&&!a.closed&&cm(this,a,b,c)}; var gm,hm,im,jm,km,lm,mm,nm,Xl,$l,om,pm,qm,rm,Zl,am,sm,tm,ym,zm,Bm,bm,Dm,Cm,um,vm,Em,Yl,Fm,Gm;gm=0;hm=[];im={};jm={};km=_.I.xc;lm=km();mm=lm.rpctoken;nm=lm.parent||_.Qd.referrer;Xl=lm.rly;$l=Xl||(_.Nd!==_.Nd.top||_.Nd.opener)&&_.Nd.name||"..";om=null;pm={};qm=function(){};rm={send:qm,Dc:qm}; Zl=function(a,b){"/"==b.charAt(0)&&(b=b.substring(1),a=_.Nd.top);for(b=b.split("/");b.length;){var c=b.shift();"{"==c.charAt(0)&&"}"==c.charAt(c.length-1)&&(c=c.substring(1,c.length-1));if(".."===c)a=a==a.parent?a.opener:a.parent;else if(".."!==c&&a.frames[c]){if(a=a.frames[c],!("postMessage"in a))throw"Not a window";}else return null}return a};am=function(a){return(a=im[a])&&a.zk}; sm=function(a){if(a.f in{})return!1;var b=a.t,c=im[a.r];a=a.origin;return c&&(c.zk===b||!c.zk&&!b)&&(a===c.origin||"*"===c.origin)};tm=function(a){var b=a.id.split("/"),c=b[b.length-1],d=a.origin;return function(a){var b=a.origin;return a.f==c&&(d==b||"*"==d)}};_.wm=function(a,b,c){a=um(a);jm[a.name]={Lg:b,Nq:a.Nq,zo:c||sm};vm()};_.xm=function(a){delete jm[um(a).name]};ym={};zm=function(a,b){(a=ym["_"+a])&&a[1](this)&&a[0].call(this,b)}; Bm=function(a){var b=a.c;if(!b)return qm;var c=a.r,d=a.g?"legacy__":"";return function(){var a=[].slice.call(arguments,0);a.unshift(c,d+"__cb",null,b);_.Am.apply(null,a)}};bm=function(a){om=a};Dm=function(a){pm[a]||(pm[a]=_.Nd.setTimeout(function(){pm[a]=!1;Cm(a)},0))};Cm=function(a){var b=im[a];if(b&&b.ready){var c=b.dC;for(b.dC=[];c.length;)rm.send(a,_.df(c.shift()),b.origin)}};um=function(a){return 0===a.indexOf("legacy__")?{name:a.substring(8),Nq:!0}:{name:a,Nq:!1}}; vm=function(){for(var a=_.H("rpc/residenceSec")||60,b=(new Date).getTime()/1E3,c=0,d;d=hm[c];++c){var e=d.hm;if(!e||0<a&&b-d.timestamp>a)hm.splice(c,1),--c;else{var f=e.s,h=jm[f]||jm["*"];if(h)if(hm.splice(c,1),--c,e.origin=d.origin,d=Bm(e),e.callback=d,h.zo(e)){if("__cb"!==f&&!!h.Nq!=!!e.g)break;e=h.Lg.apply(e,e.a);void 0!==e&&d(e)}else(0,_.ve)("gapi.rpc.rejected("+$l+"): "+f)}}};Em=function(a,b,c){hm.push({hm:a,origin:b,timestamp:(new Date).getTime()/1E3});c||vm()}; Yl=function(a,b){a=_.cf(a);Em(a,b,!1)};Fm=function(a){for(;a.length;)Em(a.shift(),this.origin,!0);vm()};Gm=function(a){var b=!1;a=a.split("|");var c=a[0];0<=c.indexOf("/")&&(b=!0);return{id:c,origin:a[1]||"*",QA:b}}; _.Hm=function(a,b,c,d){var e=Gm(a);d&&(_.Nd.frames[e.id]=_.Nd.frames[e.id]||d);a=e.id;if(!im.hasOwnProperty(a)){c=c||null;d=e.origin;if(".."===a)d=_.Xj.Qa(nm),c=c||mm;else if(!e.QA){var f=_.Qd.getElementById(a);f&&(f=f.src,d=_.Xj.Qa(f),c=c||km(f).rpctoken)}"*"===e.origin&&d||(d=e.origin);im[a]={zk:c,dC:[],origin:d,xY:b,mK:function(){var b=a;im[b].ready=1;Cm(b)}};rm.Dc(a,im[a].mK)}return im[a].mK}; _.Am=function(a,b,c,d){a=a||"..";_.Hm(a);a=a.split("|",1)[0];var e=b,f=[].slice.call(arguments,3),h=c,k=$l,l=mm,n=im[a],p=k,q=Gm(a);if(n&&".."!==a){if(q.QA){if(!(l=im[a].xY)){l=om?om.substring(1).split("/"):[$l];p=l.length-1;for(var t=_.Nd.parent;t!==_.Nd.top;){var x=t.parent;if(!p--){for(var v=null,y=x.frames.length,F=0;F<y;++F)x.frames[F]==t&&(v=F);l.unshift("{"+v+"}")}t=x}l="/"+l.join("/")}p=l}else p=k="..";l=n.zk}h&&q?(n=sm,q.QA&&(n=tm(q)),ym["_"+ ++gm]=[h,n],h=gm):h=null;f={s:e,f:k,r:p,t:l,c:h, a:f};e=um(e);f.s=e.name;f.g=e.Nq;im[a].dC.push(f);Dm(a)};if("function"===typeof _.Nd.postMessage||"object"===typeof _.Nd.postMessage)rm=new dm,_.wm("__cb",zm,function(){return!0}),_.wm("_processBatch",Fm,function(){return!0}),_.Hm(".."); _.Of=function(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=c.slice();b.push.apply(b,arguments);return a.apply(this,b)}};_.Pf=function(a,b){a:{for(var c=a.length,d=_.u(a)?a.split(""):a,e=0;e<c;e++)if(e in d&&b.call(void 0,d[e],e,a)){b=e;break a}b=-1}return 0>b?null:_.u(a)?a.charAt(b):a[b]};_.Qf=[];_.Rf=[];_.Sf=!1;_.Tf=function(a){_.Qf[_.Qf.length]=a;if(_.Sf)for(var b=0;b<_.Rf.length;b++)a((0,_.A)(_.Rf[b].wrap,_.Rf[b]))}; _.Hg=function(a){return function(){return a}}(!0); var Ng;_.Ig=function(a){if(Error.captureStackTrace)Error.captureStackTrace(this,_.Ig);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))};_.z(_.Ig,Error);_.Ig.prototype.name="CustomError";_.Jg=function(a,b){for(var c in a)if(!(c in b)||a[c]!==b[c])return!1;for(c in b)if(!(c in a))return!1;return!0};_.Kg=function(a){var b={},c;for(c in a)b[c]=a[c];return b};_.Lg=function(a,b){a.src=_.Sc(b)};_.Mg=function(a){return a};Ng=function(a,b){this.FQ=a;this.lY=b;this.mv=0;this.Pe=null}; Ng.prototype.get=function(){if(0<this.mv){this.mv--;var a=this.Pe;this.Pe=a.next;a.next=null}else a=this.FQ();return a};Ng.prototype.put=function(a){this.lY(a);100>this.mv&&(this.mv++,a.next=this.Pe,this.Pe=a)}; var Og,Qg,Rg,Pg;Og=function(a){_.m.setTimeout(function(){throw a;},0)};_.Sg=function(a){a=Pg(a);!_.Xa(_.m.setImmediate)||_.m.Window&&_.m.Window.prototype&&!_.Db("Edge")&&_.m.Window.prototype.setImmediate==_.m.setImmediate?(Qg||(Qg=Rg()),Qg(a)):_.m.setImmediate(a)}; Rg=function(){var a=_.m.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!_.Db("Presto")&&(a=function(){var a=window.document.createElement("IFRAME");a.style.display="none";a.src="";window.document.documentElement.appendChild(a);var b=a.contentWindow;a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host;a=(0,_.A)(function(a){if(("*"== d||a.origin==d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&!_.Ib()){var b=new a,c={},d=c;b.port1.onmessage=function(){if(_.r(c.next)){c=c.next;var a=c.cb;c.cb=null;a()}};return function(a){d.next={cb:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof window.document&&"onreadystatechange"in window.document.createElement("SCRIPT")?function(a){var b=window.document.createElement("SCRIPT"); b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};window.document.documentElement.appendChild(b)}:function(a){_.m.setTimeout(a,0)}};Pg=_.Mg;_.Tf(function(a){Pg=a}); var Tg=function(){this.Ow=this.Co=null},Vg=new Ng(function(){return new Ug},function(a){a.reset()});Tg.prototype.add=function(a,b){var c=Vg.get();c.set(a,b);this.Ow?this.Ow.next=c:this.Co=c;this.Ow=c};Tg.prototype.remove=function(){var a=null;this.Co&&(a=this.Co,this.Co=this.Co.next,this.Co||(this.Ow=null),a.next=null);return a};var Ug=function(){this.next=this.scope=this.Lg=null};Ug.prototype.set=function(a,b){this.Lg=a;this.scope=b;this.next=null}; Ug.prototype.reset=function(){this.next=this.scope=this.Lg=null}; var Wg,Xg,Yg,Zg,ah;_.$g=function(a,b){Wg||Xg();Yg||(Wg(),Yg=!0);Zg.add(a,b)};Xg=function(){if(-1!=String(_.m.Promise).indexOf("[native code]")){var a=_.m.Promise.resolve(void 0);Wg=function(){a.then(ah)}}else Wg=function(){_.Sg(ah)}};Yg=!1;Zg=new Tg;ah=function(){for(var a;a=Zg.remove();){try{a.Lg.call(a.scope)}catch(b){Og(b)}Vg.put(a)}Yg=!1}; _.bh=function(a){a.prototype.then=a.prototype.then;a.prototype.$goog_Thenable=!0};_.ch=function(a){if(!a)return!1;try{return!!a.$goog_Thenable}catch(b){return!1}};var eh,fh,ph,nh;_.dh=function(a,b){this.Da=0;this.Si=void 0;this.Tm=this.yj=this.hb=null;this.iu=this.bz=!1;if(a!=_.Va)try{var c=this;a.call(b,function(a){c.Xg(2,a)},function(a){c.Xg(3,a)})}catch(d){this.Xg(3,d)}};eh=function(){this.next=this.context=this.On=this.Yq=this.Ok=null;this.Wo=!1};eh.prototype.reset=function(){this.context=this.On=this.Yq=this.Ok=null;this.Wo=!1};fh=new Ng(function(){return new eh},function(a){a.reset()});_.gh=function(a,b,c){var d=fh.get();d.Yq=a;d.On=b;d.context=c;return d}; _.hh=function(a){if(a instanceof _.dh)return a;var b=new _.dh(_.Va);b.Xg(2,a);return b};_.ih=function(a){return new _.dh(function(b,c){c(a)})};_.kh=function(a,b,c){jh(a,b,c,null)||_.$g(_.Of(b,a))};_.mh=function(){var a,b,c=new _.dh(function(c,e){a=c;b=e});return new lh(c,a,b)};_.dh.prototype.then=function(a,b,c){return nh(this,_.Xa(a)?a:null,_.Xa(b)?b:null,c)};_.bh(_.dh);_.dh.prototype.Aw=function(a,b){return nh(this,null,a,b)}; _.dh.prototype.cancel=function(a){0==this.Da&&_.$g(function(){var b=new oh(a);ph(this,b)},this)};ph=function(a,b){if(0==a.Da)if(a.hb){var c=a.hb;if(c.yj){for(var d=0,e=null,f=null,h=c.yj;h&&(h.Wo||(d++,h.Ok==a&&(e=h),!(e&&1<d)));h=h.next)e||(f=h);e&&(0==c.Da&&1==d?ph(c,b):(f?(d=f,d.next==c.Tm&&(c.Tm=d),d.next=d.next.next):qh(c),rh(c,e,3,b)))}a.hb=null}else a.Xg(3,b)};_.th=function(a,b){a.yj||2!=a.Da&&3!=a.Da||sh(a);a.Tm?a.Tm.next=b:a.yj=b;a.Tm=b}; nh=function(a,b,c,d){var e=_.gh(null,null,null);e.Ok=new _.dh(function(a,h){e.Yq=b?function(c){try{var e=b.call(d,c);a(e)}catch(n){h(n)}}:a;e.On=c?function(b){try{var e=c.call(d,b);!_.r(e)&&b instanceof oh?h(b):a(e)}catch(n){h(n)}}:h});e.Ok.hb=a;_.th(a,e);return e.Ok};_.dh.prototype.z_=function(a){this.Da=0;this.Xg(2,a)};_.dh.prototype.A_=function(a){this.Da=0;this.Xg(3,a)}; _.dh.prototype.Xg=function(a,b){0==this.Da&&(this===b&&(a=3,b=new TypeError("Promise cannot resolve to itself")),this.Da=1,jh(b,this.z_,this.A_,this)||(this.Si=b,this.Da=a,this.hb=null,sh(this),3!=a||b instanceof oh||uh(this,b)))}; var jh=function(a,b,c,d){if(a instanceof _.dh)return _.th(a,_.gh(b||_.Va,c||null,d)),!0;if(_.ch(a))return a.then(b,c,d),!0;if(_.Ya(a))try{var e=a.then;if(_.Xa(e))return vh(a,e,b,c,d),!0}catch(f){return c.call(d,f),!0}return!1},vh=function(a,b,c,d,e){var f=!1,h=function(a){f||(f=!0,c.call(e,a))},k=function(a){f||(f=!0,d.call(e,a))};try{b.call(a,h,k)}catch(l){k(l)}},sh=function(a){a.bz||(a.bz=!0,_.$g(a.eR,a))},qh=function(a){var b=null;a.yj&&(b=a.yj,a.yj=b.next,b.next=null);a.yj||(a.Tm=null);return b}; _.dh.prototype.eR=function(){for(var a;a=qh(this);)rh(this,a,this.Da,this.Si);this.bz=!1};var rh=function(a,b,c,d){if(3==c&&b.On&&!b.Wo)for(;a&&a.iu;a=a.hb)a.iu=!1;if(b.Ok)b.Ok.hb=null,wh(b,c,d);else try{b.Wo?b.Yq.call(b.context):wh(b,c,d)}catch(e){xh.call(null,e)}fh.put(b)},wh=function(a,b,c){2==b?a.Yq.call(a.context,c):a.On&&a.On.call(a.context,c)},uh=function(a,b){a.iu=!0;_.$g(function(){a.iu&&xh.call(null,b)})},xh=Og,oh=function(a){_.Ig.call(this,a)};_.z(oh,_.Ig);oh.prototype.name="cancel"; var lh=function(a,b,c){this.promise=a;this.resolve=b;this.reject=c}; _.Im=function(a){return new _.dh(a)}; _.Jm=_.Jm||{};_.Jm.oT=function(){var a=0,b=0;window.self.innerHeight?(a=window.self.innerWidth,b=window.self.innerHeight):window.document.documentElement&&window.document.documentElement.clientHeight?(a=window.document.documentElement.clientWidth,b=window.document.documentElement.clientHeight):window.document.body&&(a=window.document.body.clientWidth,b=window.document.body.clientHeight);return{width:a,height:b}}; _.Jm=_.Jm||{}; (function(){function a(a,c){window.getComputedStyle(a,"").getPropertyValue(c).match(/^([0-9]+)/);return(0,window.parseInt)(RegExp.$1,10)}_.Jm.Xc=function(){var b=_.Jm.oT().height,c=window.document.body,d=window.document.documentElement;if("CSS1Compat"===window.document.compatMode&&d.scrollHeight)return d.scrollHeight!==b?d.scrollHeight:d.offsetHeight;if(0<=window.navigator.userAgent.indexOf("AppleWebKit")){b=0;for(c=[window.document.body];0<c.length;){var e=c.shift();d=e.childNodes;if("undefined"!== typeof e.style){var f=e.style.overflowY;f||(f=(f=window.document.defaultView.getComputedStyle(e,null))?f.overflowY:null);if("visible"!=f&&"inherit"!=f&&(f=e.style.height,f||(f=(f=window.document.defaultView.getComputedStyle(e,null))?f.height:""),0<f.length&&"auto"!=f))continue}for(e=0;e<d.length;e++){f=d[e];if("undefined"!==typeof f.offsetTop&&"undefined"!==typeof f.offsetHeight){var h=f.offsetTop+f.offsetHeight+a(f,"margin-bottom");b=Math.max(b,h)}c.push(f)}}return b+a(window.document.body,"border-bottom")+ a(window.document.body,"margin-bottom")+a(window.document.body,"padding-bottom")}if(c&&d)return e=d.scrollHeight,f=d.offsetHeight,d.clientHeight!==f&&(e=c.scrollHeight,f=c.offsetHeight),e>b?e>f?e:f:e<f?e:f}})(); var fl;fl=/^https?:\/\/(?:\w|[\-\.])+\.google\.(?:\w|[\-:\.])+(?:\/[^\?#]*)?\/u\/(\d)\//; _.gl=function(a){var b=_.H("googleapis.config/sessionIndex");"string"===typeof b&&254<b.length&&(b=null);null==b&&(b=window.__X_GOOG_AUTHUSER);"string"===typeof b&&254<b.length&&(b=null);if(null==b){var c=window.google;c&&(b=c.authuser)}"string"===typeof b&&254<b.length&&(b=null);null==b&&(a=a||window.location.href,b=_.Xd(a,"authuser")||null,null==b&&(b=(b=a.match(fl))?b[1]:null));if(null==b)return null;b=String(b);254<b.length&&(b=null);return b}; var ll=function(){this.wj=-1};_.ml=function(){this.wj=64;this.Fc=[];this.Rx=[];this.rP=[];this.zv=[];this.zv[0]=128;for(var a=1;a<this.wj;++a)this.zv[a]=0;this.Dw=this.An=0;this.reset()};_.z(_.ml,ll);_.ml.prototype.reset=function(){this.Fc[0]=1732584193;this.Fc[1]=4023233417;this.Fc[2]=2562383102;this.Fc[3]=271733878;this.Fc[4]=3285377520;this.Dw=this.An=0}; var nl=function(a,b,c){c||(c=0);var d=a.rP;if(_.u(b))for(var e=0;16>e;e++)d[e]=b.charCodeAt(c)<<24|b.charCodeAt(c+1)<<16|b.charCodeAt(c+2)<<8|b.charCodeAt(c+3),c+=4;else for(e=0;16>e;e++)d[e]=b[c]<<24|b[c+1]<<16|b[c+2]<<8|b[c+3],c+=4;for(e=16;80>e;e++){var f=d[e-3]^d[e-8]^d[e-14]^d[e-16];d[e]=(f<<1|f>>>31)&4294967295}b=a.Fc[0];c=a.Fc[1];var h=a.Fc[2],k=a.Fc[3],l=a.Fc[4];for(e=0;80>e;e++){if(40>e)if(20>e){f=k^c&(h^k);var n=1518500249}else f=c^h^k,n=1859775393;else 60>e?(f=c&h|k&(c|h),n=2400959708): (f=c^h^k,n=3395469782);f=(b<<5|b>>>27)+f+l+n+d[e]&4294967295;l=k;k=h;h=(c<<30|c>>>2)&4294967295;c=b;b=f}a.Fc[0]=a.Fc[0]+b&4294967295;a.Fc[1]=a.Fc[1]+c&4294967295;a.Fc[2]=a.Fc[2]+h&4294967295;a.Fc[3]=a.Fc[3]+k&4294967295;a.Fc[4]=a.Fc[4]+l&4294967295}; _.ml.prototype.update=function(a,b){if(null!=a){_.r(b)||(b=a.length);for(var c=b-this.wj,d=0,e=this.Rx,f=this.An;d<b;){if(0==f)for(;d<=c;)nl(this,a,d),d+=this.wj;if(_.u(a))for(;d<b;){if(e[f]=a.charCodeAt(d),++f,++d,f==this.wj){nl(this,e);f=0;break}}else for(;d<b;)if(e[f]=a[d],++f,++d,f==this.wj){nl(this,e);f=0;break}}this.An=f;this.Dw+=b}}; _.ml.prototype.digest=function(){var a=[],b=8*this.Dw;56>this.An?this.update(this.zv,56-this.An):this.update(this.zv,this.wj-(this.An-56));for(var c=this.wj-1;56<=c;c--)this.Rx[c]=b&255,b/=256;nl(this,this.Rx);for(c=b=0;5>c;c++)for(var d=24;0<=d;d-=8)a[b]=this.Fc[c]>>d&255,++b;return a}; _.ol=function(){this.jD=new _.ml};_.g=_.ol.prototype;_.g.reset=function(){this.jD.reset()};_.g.qM=function(a){this.jD.update(a)};_.g.pG=function(){return this.jD.digest()};_.g.HD=function(a){a=(0,window.unescape)((0,window.encodeURIComponent)(a));for(var b=[],c=0,d=a.length;c<d;++c)b.push(a.charCodeAt(c));this.qM(b)};_.g.Ig=function(){for(var a=this.pG(),b="",c=0;c<a.length;c++)b+="0123456789ABCDEF".charAt(Math.floor(a[c]/16))+"0123456789ABCDEF".charAt(a[c]%16);return b}; var Lm,Km,Rm,Sm,Mm,Pm,Nm,Tm,Om;_.Qm=function(){if(Km){var a=new _.Nd.Uint32Array(1);Lm.getRandomValues(a);a=Number("0."+a[0])}else a=Mm,a+=(0,window.parseInt)(Nm.substr(0,20),16),Nm=Om(Nm),a/=Pm+Math.pow(16,20);return a};Lm=_.Nd.crypto;Km=!1;Rm=0;Sm=0;Mm=1;Pm=0;Nm="";Tm=function(a){a=a||_.Nd.event;var b=a.screenX+a.clientX<<16;b+=a.screenY+a.clientY;b*=(new Date).getTime()%1E6;Mm=Mm*b%Pm;0<Rm&&++Sm==Rm&&_.ae(_.Nd,"mousemove",Tm,"remove","de")};Om=function(a){var b=new _.ol;b.HD(a);return b.Ig()}; Km=!!Lm&&"function"==typeof Lm.getRandomValues;Km||(Pm=1E6*(window.screen.width*window.screen.width+window.screen.height),Nm=Om(_.Qd.cookie+"|"+_.Qd.location+"|"+(new Date).getTime()+"|"+Math.random()),Rm=_.H("random/maxObserveMousemove")||0,0!=Rm&&_.be(_.Nd,"mousemove",Tm)); var Vm,Zm,$m,an,bn,cn,dn,en,fn,gn,hn,jn,kn,on,qn,rn,sn,tn,un,vn;_.Um=function(a,b){b=b instanceof _.Wc?b:_.ad(b);a.href=_.Xc(b)};_.Wm=function(a){return!!a&&"object"===typeof a&&_.Sd.test(a.push)};_.Xm=function(a){for(var b=0;b<this.length;b++)if(this[b]===a)return b;return-1};_.Ym=function(a,b){if(!a)throw Error(b||"");};Zm=/&/g;$m=/</g;an=/>/g;bn=/"/g;cn=/'/g;dn=function(a){return String(a).replace(Zm,"&").replace($m,"<").replace(an,">").replace(bn,""").replace(cn,"'")};en=/[\ud800-\udbff][\udc00-\udfff]|[^!-~]/g; fn=/%([a-f]|[0-9a-fA-F][a-f])/g;gn=/^(https?|ftp|file|chrome-extension):$/i; hn=function(a){a=String(a);a=a.replace(en,function(a){try{return(0,window.encodeURIComponent)(a)}catch(f){return(0,window.encodeURIComponent)(a.replace(/^[^%]+$/g,"\ufffd"))}}).replace(_.Zd,function(a){return a.replace(/%/g,"%25")}).replace(fn,function(a){return a.toUpperCase()});a=a.match(_.Yd)||[];var b=_.D(),c=function(a){return a.replace(/\\/g,"%5C").replace(/\^/g,"%5E").replace(/`/g,"%60").replace(/\{/g,"%7B").replace(/\|/g,"%7C").replace(/\}/g,"%7D")},d=!!(a[1]||"").match(gn);b.ep=c((a[1]|| "")+(a[2]||"")+(a[3]||(a[2]&&d?"/":"")));d=function(a){return c(a.replace(/\?/g,"%3F").replace(/#/g,"%23"))};b.query=a[5]?[d(a[5])]:[];b.rh=a[7]?[d(a[7])]:[];return b};jn=function(a){return a.ep+(0<a.query.length?"?"+a.query.join("&"):"")+(0<a.rh.length?"#"+a.rh.join("&"):"")};kn=function(a,b){var c=[];if(a)for(var d in a)if(_.Ud(a,d)&&null!=a[d]){var e=b?b(a[d]):a[d];c.push((0,window.encodeURIComponent)(d)+"="+(0,window.encodeURIComponent)(e))}return c}; _.ln=function(a,b,c,d){a=hn(a);a.query.push.apply(a.query,kn(b,d));a.rh.push.apply(a.rh,kn(c,d));return jn(a)}; _.mn=function(a,b){var c=hn(b);b=c.ep;c.query.length&&(b+="?"+c.query.join(""));c.rh.length&&(b+="#"+c.rh.join(""));var d="";2E3<b.length&&(c=b,b=b.substr(0,2E3),b=b.replace(_.$d,""),d=c.substr(b.length));var e=a.createElement("div");a=a.createElement("a");c=hn(b);b=c.ep;c.query.length&&(b+="?"+c.query.join(""));c.rh.length&&(b+="#"+c.rh.join(""));a.href=b;e.appendChild(a);e.innerHTML=e.innerHTML;b=String(e.firstChild.href);e.parentNode&&e.parentNode.removeChild(e);c=hn(b+d);b=c.ep;c.query.length&& (b+="?"+c.query.join(""));c.rh.length&&(b+="#"+c.rh.join(""));return b};_.nn=/^https?:\/\/[^\/%\\?#\s]+\/[^\s]*$/i;on=function(a){for(;a.firstChild;)a.removeChild(a.firstChild)};_.pn=function(a,b){var c=_.Td(_.ce,"watt",_.D());_.Td(c,a,b)};qn=/^https?:\/\/(?:\w|[\-\.])+\.google\.(?:\w|[\-:\.])+(?:\/[^\?#]*)?\/b\/(\d{10,21})\//; rn=function(a){var b=_.H("googleapis.config/sessionDelegate");"string"===typeof b&&21<b.length&&(b=null);null==b&&(b=(a=(a||window.location.href).match(qn))?a[1]:null);if(null==b)return null;b=String(b);21<b.length&&(b=null);return b};sn=function(){var a=_.ce.onl;if(!a){a=_.D();_.ce.onl=a;var b=_.D();a.e=function(a){var c=b[a];c&&(delete b[a],c())};a.a=function(a,d){b[a]=d};a.r=function(a){delete b[a]}}return a};tn=function(a,b){b=b.onload;return"function"===typeof b?(sn().a(a,b),b):null}; un=function(a){_.Ym(/^\w+$/.test(a),"Unsupported id - "+a);sn();return'onload="window.___jsl.onl.e("'+a+'")"'};vn=function(a){sn().r(a)}; var xn,yn,Cn;_.wn={allowtransparency:"true",frameborder:"0",hspace:"0",marginheight:"0",marginwidth:"0",scrolling:"no",style:"",tabindex:"0",vspace:"0",width:"100%"};xn={allowtransparency:!0,onload:!0};yn=0;_.zn=function(a,b){var c=0;do var d=b.id||["I",yn++,"_",(new Date).getTime()].join("");while(a.getElementById(d)&&5>++c);_.Ym(5>c,"Error creating iframe id");return d};_.An=function(a,b){return a?b+"/"+a:""}; _.Bn=function(a,b,c,d){var e={},f={};a.documentMode&&9>a.documentMode&&(e.hostiemode=a.documentMode);_.Vd(d.queryParams||{},e);_.Vd(d.fragmentParams||{},f);var h=d.pfname;var k=_.D();_.H("iframes/dropLegacyIdParam")||(k.id=c);k._gfid=c;k.parent=a.location.protocol+"//"+a.location.host;c=_.Xd(a.location.href,"parent");h=h||"";!h&&c&&(h=_.Xd(a.location.href,"_gfid","")||_.Xd(a.location.href,"id",""),h=_.An(h,_.Xd(a.location.href,"pfname","")));h||(c=_.cf(_.Xd(a.location.href,"jcp","")))&&"object"== typeof c&&(h=_.An(c.id,c.pfname));k.pfname=h;d.connectWithJsonParam&&(h={},h.jcp=_.df(k),k=h);h=_.Xd(b,"rpctoken")||e.rpctoken||f.rpctoken;h||(h=d.rpctoken||String(Math.round(1E8*_.Qm())),k.rpctoken=h);d.rpctoken=h;_.Vd(k,d.connectWithQueryParams?e:f);k=a.location.href;a=_.D();(h=_.Xd(k,"_bsh",_.ce.bsh))&&(a._bsh=h);(k=_.ce.dpo?_.ce.h:_.Xd(k,"jsh",_.ce.h))&&(a.jsh=k);d.hintInFragment?_.Vd(a,f):_.Vd(a,e);return _.ln(b,e,f,d.paramsSerializer)}; Cn=function(a){_.Ym(!a||_.nn.test(a),"Illegal url for new iframe - "+a)}; _.Dn=function(a,b,c,d,e){Cn(c.src);var f,h=tn(d,c),k=h?un(d):"";try{window.document.all&&(f=a.createElement('<iframe frameborder="'+dn(String(c.frameborder))+'" scrolling="'+dn(String(c.scrolling))+'" '+k+' name="'+dn(String(c.name))+'"/>'))}catch(n){}finally{f||(f=a.createElement("iframe"),h&&(f.onload=function(){f.onload=null;h.call(this)},vn(d)))}f.setAttribute("ng-non-bindable","");for(var l in c)a=c[l],"style"===l&&"object"===typeof a?_.Vd(a,f.style):xn[l]||f.setAttribute(l,String(a));(l=e&& e.beforeNode||null)||e&&e.dontclear||on(b);b.insertBefore(f,l);f=l?l.previousSibling:b.lastChild;c.allowtransparency&&(f.allowTransparency=!0);return f}; var En,Hn;En=/^:[\w]+$/;_.Fn=/:([a-zA-Z_]+):/g;_.Gn=function(){var a=_.gl()||"0",b=rn();var c=_.gl(void 0)||a;var d=rn(void 0),e="";c&&(e+="u/"+(0,window.encodeURIComponent)(String(c))+"/");d&&(e+="b/"+(0,window.encodeURIComponent)(String(d))+"/");c=e||null;(e=(d=!1===_.H("isLoggedIn"))?"_/im/":"")&&(c="");var f=_.H("iframes/:socialhost:"),h=_.H("iframes/:im_socialhost:");return Vm={socialhost:f,ctx_socialhost:d?h:f,session_index:a,session_delegate:b,session_prefix:c,im_prefix:e}}; Hn=function(a,b){return _.Gn()[b]||""};_.In=function(a){return _.mn(_.Qd,a.replace(_.Fn,Hn))};_.Jn=function(a){var b=a;En.test(a)&&(b=_.H("iframes/"+b.substring(1)+"/url"),_.Ym(!!b,"Unknown iframe url config for - "+a));return _.In(b)}; _.Kn=function(a,b,c){var d=c||{};c=d.attributes||{};_.Ym(!(d.allowPost||d.forcePost)||!c.onload,"onload is not supported by post iframe (allowPost or forcePost)");a=_.Jn(a);c=b.ownerDocument||_.Qd;var e=_.zn(c,d);a=_.Bn(c,a,e,d);var f=_.D();_.Vd(_.wn,f);_.Vd(d.attributes,f);f.name=f.id=e;f.src=a;d.eurl=a;var h=d||{},k=!!h.allowPost;if(h.forcePost||k&&2E3<a.length){h=hn(a);f.src="";f["data-postorigin"]=a;a=_.Dn(c,b,f,e);if(-1!=window.navigator.userAgent.indexOf("WebKit")){var l=a.contentWindow.document; l.open();f=l.createElement("div");k={};var n=e+"_inner";k.name=n;k.src="";k.style="display:none";_.Dn(c,f,k,n,d)}f=(d=h.query[0])?d.split("&"):[];d=[];for(k=0;k<f.length;k++)n=f[k].split("=",2),d.push([(0,window.decodeURIComponent)(n[0]),(0,window.decodeURIComponent)(n[1])]);h.query=[];f=jn(h);_.Ym(_.nn.test(f),"Invalid URL: "+f);h=c.createElement("form");h.action=f;h.method="POST";h.target=e;h.style.display="none";for(e=0;e<d.length;e++)f=c.createElement("input"),f.type="hidden",f.name=d[e][0],f.value= d[e][1],h.appendChild(f);b.appendChild(h);h.submit();h.parentNode.removeChild(h);l&&l.close();b=a}else b=_.Dn(c,b,f,e,d);return b}; _.Ln=function(a){this.R=a};_.g=_.Ln.prototype;_.g.value=function(){return this.R};_.g.uk=function(a){this.R.width=a;return this};_.g.Ed=function(){return this.R.width};_.g.rk=function(a){this.R.height=a;return this};_.g.Xc=function(){return this.R.height};_.g.Jd=function(a){this.R.style=a;return this};_.g.zl=_.ea(9); var Mn=function(a){this.R=a};_.g=Mn.prototype;_.g.no=function(a){this.R.anchor=a;return this};_.g.vf=function(){return this.R.anchor};_.g.IC=function(a){this.R.anchorPosition=a;return this};_.g.rk=function(a){this.R.height=a;return this};_.g.Xc=function(){return this.R.height};_.g.uk=function(a){this.R.width=a;return this};_.g.Ed=function(){return this.R.width}; _.Nn=function(a){this.R=a||{}};_.g=_.Nn.prototype;_.g.value=function(){return this.R};_.g.setUrl=function(a){this.R.url=a;return this};_.g.getUrl=function(){return this.R.url};_.g.Jd=function(a){this.R.style=a;return this};_.g.zl=_.ea(8);_.g.Zi=function(a){this.R.id=a};_.g.ka=function(){return this.R.id};_.g.tk=_.ea(10);_.On=function(a,b){a.R.queryParams=b;return a};_.Pn=function(a,b){a.R.relayOpen=b;return a};_.Nn.prototype.oo=_.ea(11);_.Nn.prototype.getContext=function(){return this.R.context}; _.Nn.prototype.Qc=function(){return this.R.openerIframe};_.Qn=function(a){return new Mn(a.R)};_.Nn.prototype.hn=function(){this.R.attributes=this.R.attributes||{};return new _.Ln(this.R.attributes)};_.Rn=function(a){a.R.connectWithQueryParams=!0;return a}; var Sn,Yn,Zn,$n,go,fo;_.Ln.prototype.zl=_.rc(9,function(){return this.R.style});_.Nn.prototype.zl=_.rc(8,function(){return this.R.style});Sn=function(a,b){a.R.onload=b};_.Tn=function(a){a.R.closeClickDetection=!0};_.Un=function(a){return a.R.rpctoken};_.Vn=function(a,b){a.R.messageHandlers=b;return a};_.Wn=function(a,b){a.R.messageHandlersFilter=b;return a};_.Xn=function(a){a.R.waitForOnload=!0;return a};Yn=function(a){return(a=a.R.timeout)?a:null}; _.bo=function(a,b,c){if(a){_.Ym(_.Wm(a),"arrayForEach was called with a non array value");for(var d=0;d<a.length;d++)b.call(c,a[d],d)}};_.co=function(a,b,c){if(a)if(_.Wm(a))_.bo(a,b,c);else{_.Ym("object"===typeof a,"objectForEach was called with a non object value");c=c||a;for(var d in a)_.Ud(a,d)&&void 0!==a[d]&&b.call(c,a[d],d)}}; _.eo=function(a){return new _.dh(function(b,c){var d=a.length,e=[];if(d)for(var f=function(a,c){d--;e[a]=c;0==d&&b(e)},h=function(a){c(a)},k=0,l;k<a.length;k++)l=a[k],_.kh(l,_.Of(f,k),h);else b(e)})};go=function(a){this.resolve=this.reject=null;this.promise=_.Im((0,_.A)(function(a,c){this.resolve=a;this.reject=c},this));a&&(this.promise=fo(this.promise,a))};fo=function(a,b){return a.then(function(a){try{b(a)}catch(d){}return a})}; _.ho=function(a){this.R=a||{}};_.z(_.ho,_.Nn);_.io=function(a,b){a.R.frameName=b;return a};_.ho.prototype.Cd=function(){return this.R.frameName};_.jo=function(a,b){a.R.rpcAddr=b;return a};_.ho.prototype.xl=function(){return this.R.rpcAddr};_.ko=function(a,b){a.R.retAddr=b;return a};_.lo=function(a){return a.R.retAddr};_.ho.prototype.Nh=function(a){this.R.origin=a;return this};_.ho.prototype.Qa=function(){return this.R.origin};_.ho.prototype.$i=function(a){this.R.setRpcReady=a;return this};_.mo=function(a){return a.R.setRpcReady}; _.ho.prototype.qo=function(a){this.R.context=a};var no=function(a,b){a.R._rpcReadyFn=b};_.ho.prototype.Ha=function(){return this.R.iframeEl}; var oo,so,ro;oo=/^[\w\.\-]*$/;_.po=function(a){return a.wd===a.getContext().wd};_.M=function(){return!0};_.qo=function(a){for(var b=_.D(),c=0;c<a.length;c++)b[a[c]]=!0;return function(a){return!!b[a.wd]}};so=function(a,b,c){return function(d){if(!b.Fb){_.Ym(this.origin===b.wd,"Wrong origin "+this.origin+" != "+b.wd);var e=this.callback;d=ro(a,d,b);!c&&0<d.length&&_.eo(d).then(e)}}};ro=function(a,b,c){a=Zn[a];if(!a)return[];for(var d=[],e=0;e<a.length;e++)d.push(_.hh(a[e].call(c,b,c)));return d}; _.to=function(a,b,c){_.Ym("_default"!=a,"Cannot update default api");$n[a]={map:b,filter:c}};_.uo=function(a,b,c){_.Ym("_default"!=a,"Cannot update default api");_.Td($n,a,{map:{},filter:_.po}).map[b]=c};_.vo=function(a,b){_.Td($n,"_default",{map:{},filter:_.M}).map[a]=b;_.co(_.ao.Ge,function(c){c.register(a,b,_.M)})};_.wo=function(){return _.ao}; _.yo=function(a){a=a||{};this.Fb=!1;this.bK=_.D();this.Ge=_.D();this.Ee=a._window||_.Nd;this.yd=this.Ee.location.href;this.cK=(this.OB=xo(this.yd,"parent"))?xo(this.yd,"pfname"):"";this.Aa=this.OB?xo(this.yd,"_gfid")||xo(this.yd,"id"):"";this.uf=_.An(this.Aa,this.cK);this.wd=_.Xj.Qa(this.yd);if(this.Aa){var b=new _.ho;_.jo(b,a._parentRpcAddr||"..");_.ko(b,a._parentRetAddr||this.Aa);b.Nh(_.Xj.Qa(this.OB||this.yd));_.io(b,this.cK);this.hb=this.uj(b.value())}else this.hb=null};_.g=_.yo.prototype; _.g.Dn=_.ea(3);_.g.Ca=function(){if(!this.Fb){for(var a=0;a<this.Ge.length;a++)this.Ge[a].Ca();this.Fb=!0}};_.g.Cd=function(){return this.uf};_.g.vb=function(){return this.Ee};_.g.mb=function(){return this.Ee.document};_.g.gw=_.ea(12);_.g.Ez=function(a){return this.bK[a]}; _.g.uj=function(a){_.Ym(!this.Fb,"Cannot attach iframe in disposed context");a=new _.ho(a);a.xl()||_.jo(a,a.ka());_.lo(a)||_.ko(a,"..");a.Qa()||a.Nh(_.Xj.Qa(a.getUrl()));a.Cd()||_.io(a,_.An(a.ka(),this.uf));var b=a.Cd();if(this.Ge[b])return this.Ge[b];var c=a.xl(),d=c;a.Qa()&&(d=c+"|"+a.Qa());var e=_.lo(a),f=_.Un(a);f||(f=(f=a.Ha())&&(f.getAttribute("data-postorigin")||f.src)||a.getUrl(),f=_.Xd(f,"rpctoken"));no(a,_.Hm(d,e,f,a.R._popupWindow));d=((window.gadgets||{}).rpc||{}).setAuthToken;f&&d&&d(c, f);var h=new _.zo(this,c,b,a),k=a.R.messageHandlersFilter;_.co(a.R.messageHandlers,function(a,b){h.register(b,a,k)});_.mo(a)&&h.$i();_.Ao(h,"_g_rpcReady");return h};_.g.vC=function(a){_.io(a,null);var b=a.ka();!b||oo.test(b)&&!this.vb().document.getElementById(b)||(_.ue("Ignoring requested iframe ID - "+b),a.Zi(null))};var xo=function(a,b){var c=_.Xd(a,b);c||(c=_.cf(_.Xd(a,"jcp",""))[b]);return c||""}; _.yo.prototype.Tg=function(a){_.Ym(!this.Fb,"Cannot open iframe in disposed context");var b=new _.ho(a);Bo(this,b);var c=b.Cd();if(c&&this.Ge[c])return this.Ge[c];this.vC(b);c=b.getUrl();_.Ym(c,"No url for new iframe");var d=b.R.queryParams||{};d.usegapi="1";_.On(b,d);d=this.ZH&&this.ZH(c,b);d||(d=b.R.where,_.Ym(!!d,"No location for new iframe"),c=_.Kn(c,d,a),b.R.iframeEl=c,d=c.getAttribute("id"));_.jo(b,d).Zi(d);b.Nh(_.Xj.Qa(b.R.eurl||""));this.iJ&&this.iJ(b,b.Ha());c=this.uj(a);c.aD&&c.aD(c,a); (a=b.R.onCreate)&&a(c);b.R.disableRelayOpen||c.Yo("_open");return c}; var Co=function(a,b,c){var d=b.R.canvasUrl;if(!d)return c;_.Ym(!b.R.allowPost&&!b.R.forcePost,"Post is not supported when using canvas url");var e=b.getUrl();_.Ym(e&&_.Xj.Qa(e)===a.wd&&_.Xj.Qa(d)===a.wd,"Wrong origin for canvas or hidden url "+d);b.setUrl(d);_.Xn(b);b.R.canvasUrl=null;return function(a){var b=a.vb(),d=b.location.hash;d=_.Jn(e)+(/#/.test(e)?d.replace(/^#/,"&"):d);b.location.replace(d);c&&c(a)}},Eo=function(a,b,c){var d=b.R.relayOpen;if(d){var e=a.hb;d instanceof _.zo?(e=d,_.Pn(b,0)): 0<Number(d)&&_.Pn(b,Number(d)-1);if(e){_.Ym(!!e.VJ,"Relaying iframe open is disabled");if(d=b.zl())if(d=_.Do[d])b.qo(a),d(b.value()),b.qo(null);b.R.openerIframe=null;c.resolve(e.VJ(b));return!0}}return!1},Io=function(a,b,c){var d=b.zl();if(d)if(_.Ym(!!_.Fo,"Defer style is disabled, when requesting style "+d),_.Go[d])Bo(a,b);else return Ho(d,function(){_.Ym(!!_.Go[d],"Fail to load style - "+d);c.resolve(a.open(b.value()))}),!0;return!1}; _.yo.prototype.open=function(a,b){_.Ym(!this.Fb,"Cannot open iframe in disposed context");var c=new _.ho(a);b=Co(this,c,b);var d=new go(b);(b=c.getUrl())&&c.setUrl(_.Jn(b));if(Eo(this,c,d)||Io(this,c,d)||Eo(this,c,d))return d.promise;if(null!=Yn(c)){var e=(0,window.setTimeout)(function(){h.Ha().src="about:blank";d.reject({timeout:"Exceeded time limit of :"+Yn(c)+"milliseconds"})},Yn(c)),f=d.resolve;d.resolve=function(a){(0,window.clearTimeout)(e);f(a)}}c.R.waitForOnload&&Sn(c.hn(),function(){d.resolve(h)}); var h=this.Tg(a);c.R.waitForOnload||d.resolve(h);return d.promise};_.yo.prototype.pH=_.ea(13);_.zo=function(a,b,c,d){this.Fb=!1;this.Od=a;this.Ti=b;this.uf=c;this.ya=d;this.eo=_.lo(this.ya);this.wd=this.ya.Qa();this.jV=this.ya.Ha();this.OL=this.ya.R.where;this.Un=[];this.Yo("_default");a=this.ya.R.apis||[];for(b=0;b<a.length;b++)this.Yo(a[b]);this.Od.Ge[c]=this};_.g=_.zo.prototype;_.g.Dn=_.ea(2); _.g.Ca=function(){if(!this.Fb){for(var a=0;a<this.Un.length;a++)this.unregister(this.Un[a]);delete _.ao.Ge[this.Cd()];this.Fb=!0}};_.g.getContext=function(){return this.Od};_.g.xl=function(){return this.Ti};_.g.Cd=function(){return this.uf};_.g.Ha=function(){return this.jV};_.g.$a=function(){return this.OL};_.g.Ze=function(a){this.OL=a};_.g.$i=function(){(0,this.ya.R._rpcReadyFn)()};_.g.pL=function(a,b){this.ya.value()[a]=b};_.g.Mz=function(a){return this.ya.value()[a]};_.g.Ob=function(){return this.ya.value()}; _.g.ka=function(){return this.ya.ka()};_.g.Qa=function(){return this.wd};_.g.register=function(a,b,c){_.Ym(!this.Fb,"Cannot register handler on disposed iframe "+a);_.Ym((c||_.po)(this),"Rejecting untrusted message "+a);c=this.uf+":"+this.Od.uf+":"+a;1==_.Td(Zn,c,[]).push(b)&&(this.Un.push(a),_.wm(c,so(c,this,"_g_wasClosed"===a)))}; _.g.unregister=function(a,b){var c=this.uf+":"+this.Od.uf+":"+a,d=Zn[c];d&&(b?(b=_.Xm.call(d,b),0<=b&&d.splice(b,1)):d.splice(0,d.length),0==d.length&&(b=_.Xm.call(this.Un,a),0<=b&&this.Un.splice(b,1),_.xm(c)))};_.g.YS=function(){return this.Un};_.g.Yo=function(a){this.Dx=this.Dx||[];if(!(0<=_.Xm.call(this.Dx,a))){this.Dx.push(a);a=$n[a]||{map:{}};for(var b in a.map)_.Ud(a.map,b)&&this.register(b,a.map[b],a.filter)}}; _.g.send=function(a,b,c,d){_.Ym(!this.Fb,"Cannot send message to disposed iframe - "+a);_.Ym((d||_.po)(this),"Wrong target for message "+a);c=new go(c);_.Am(this.Ti,this.Od.uf+":"+this.uf+":"+a,c.resolve,b);return c.promise};_.Ao=function(a,b,c,d){return a.send(b,c,d,_.M)};_.zo.prototype.tX=function(a){return a};_.zo.prototype.ping=function(a,b){return _.Ao(this,"_g_ping",b,a)};Zn=_.D();$n=_.D();_.ao=new _.yo;_.vo("_g_rpcReady",_.zo.prototype.$i);_.vo("_g_discover",_.zo.prototype.YS); _.vo("_g_ping",_.zo.prototype.tX); var Ho,Bo;_.Go=_.D();_.Do=_.D();_.Fo=function(a){return _.Go[a]};Ho=function(a,b){_.Wd.load("gapi.iframes.style."+a,b)};Bo=function(a,b){var c=b.zl();if(c){b.Jd(null);var d=_.Go[c];_.Ym(d,"No such style: "+c);b.qo(a);d(b.value());b.qo(null)}};var Jo,Ko;Jo={height:!0,width:!0};Ko=/^(?!-*(?:expression|(?:moz-)?binding))(?:[.#]?-?(?:[_a-z0-9-]+)(?:-[_a-z0-9-]+)*-?|-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[a-z]{1,2}|%)?|!important|)$/i;_.Lo=function(a){"number"===typeof a&&(a=String(a)+"px");return a};_.zo.prototype.vb=function(){if(!_.po(this))return null;var a=this.ya.R._popupWindow;if(a)return a;var b=this.Ti.split("/");a=this.getContext().vb();for(var c=0;c<b.length&&a;c++){var d=b[c];a=".."===d?a==a.parent?a.opener:a.parent:a.frames[d]}return a}; var Mo=function(a,b){var c=a.hb,d=!0;b.filter&&(d=b.filter.call(b.yf,b.params));return _.hh(d).then(function(d){return d&&c?(b.aK&&b.aK.call(a,b.params),d=b.sender?b.sender(b.params):_.Ao(c,b.message,b.params),b.S_?d.then(function(){return!0}):!0):!1})}; _.yo.prototype.dy=function(a,b,c){a=Mo(this,{sender:function(a){var b=_.ao.hb;_.co(_.ao.Ge,function(c){c!==b&&_.Ao(c,"_g_wasClosed",a)});return _.Ao(b,"_g_closeMe",a)},message:"_g_closeMe",params:a,yf:c,filter:this.Ez("onCloseSelfFilter")});b=new go(b);b.resolve(a);return b.promise};_.yo.prototype.sC=function(a,b,c){a=a||{};b=new go(b);b.resolve(Mo(this,{message:"_g_restyleMe",params:a,yf:c,filter:this.Ez("onRestyleSelfFilter"),S_:!0,aK:this.pM}));return b.promise}; _.yo.prototype.pM=function(a){"auto"===a.height&&(a.height=_.Jm.Xc())};_.No=function(a){var b={};if(a)for(var c in a)_.Ud(a,c)&&_.Ud(Jo,c)&&Ko.test(a[c])&&(b[c]=a[c]);return b};_.g=_.zo.prototype;_.g.close=function(a,b){return _.Ao(this,"_g_close",a,b)};_.g.tr=function(a,b){return _.Ao(this,"_g_restyle",a,b)};_.g.bo=function(a,b){return _.Ao(this,"_g_restyleDone",a,b)};_.g.rQ=function(a){return this.getContext().dy(a,void 0,this)}; _.g.tY=function(a){if(a&&"object"===typeof a)return this.getContext().sC(a,void 0,this)};_.g.uY=function(a){var b=this.ya.R.onRestyle;b&&b.call(this,a,this);a=a&&"object"===typeof a?_.No(a):{};(b=this.Ha())&&a&&"object"===typeof a&&(_.Ud(a,"height")&&(a.height=_.Lo(a.height)),_.Ud(a,"width")&&(a.width=_.Lo(a.width)),_.Vd(a,b.style))}; _.g.sQ=function(a){var b=this.ya.R.onClose;b&&b.call(this,a,this);this.WF&&this.WF()||(b=this.Ha())&&b.parentNode&&b.parentNode.removeChild(b);if(b=this.ya.R.controller){var c={};c.frameName=this.Cd();_.Ao(b,"_g_disposeControl",c)}ro(this.uf+":"+this.Od.uf+":_g_wasClosed",a,this)};_.yo.prototype.bL=_.ea(14);_.yo.prototype.rL=_.ea(15);_.zo.prototype.sK=_.ea(16);_.zo.prototype.ik=function(a,b){this.register("_g_wasClosed",a,b)}; _.zo.prototype.V_=function(){delete this.getContext().Ge[this.Cd()];this.getContext().vb().setTimeout((0,_.A)(function(){this.Ca()},this),0)};_.vo("_g_close",_.zo.prototype.rQ);_.vo("_g_closeMe",_.zo.prototype.sQ);_.vo("_g_restyle",_.zo.prototype.tY);_.vo("_g_restyleMe",_.zo.prototype.uY);_.vo("_g_wasClosed",_.zo.prototype.V_); var Vo,Yo,Zo,$o;_.Nn.prototype.oo=_.rc(11,function(a){this.R.apis=a;return this});_.Nn.prototype.tk=_.rc(10,function(a){this.R.rpctoken=a;return this});_.Oo=function(a){a.R.show=!0;return a};_.Po=function(a,b){a.R.where=b;return a};_.Qo=function(a,b){a.R.onClose=b};_.Ro=function(a,b){a.rel="stylesheet";a.href=_.Sc(b)};_.So=function(a){this.R=a||{}};_.So.prototype.value=function(){return this.R};_.So.prototype.getIframe=function(){return this.R.iframe};_.To=function(a,b){a.R.role=b;return a}; _.So.prototype.$i=function(a){this.R.setRpcReady=a;return this};_.So.prototype.tk=function(a){this.R.rpctoken=a;return this};_.Uo=function(a){a.R.selfConnect=!0;return a};Vo=function(a){this.R=a||{}};Vo.prototype.value=function(){return this.R};var Wo=function(a){var b=new Vo;b.R.role=a;return b};Vo.prototype.xH=function(){return this.R.role};Vo.prototype.Xb=function(a){this.R.handler=a;return this};Vo.prototype.Bb=function(){return this.R.handler};var Xo=function(a,b){a.R.filter=b;return a}; Vo.prototype.oo=function(a){this.R.apis=a;return this};Yo=function(a){a.R.runOnce=!0;return a};Zo=/^https?:\/\/[^\/%\\?#\s]+$/i;$o={longdesc:!0,name:!0,src:!0,frameborder:!0,marginwidth:!0,marginheight:!0,scrolling:!0,align:!0,height:!0,width:!0,id:!0,"class":!0,title:!0,tabindex:!0,hspace:!0,vspace:!0,allowtransparency:!0};_.ap=function(a,b,c){var d=a.Ti,e=b.eo;_.ko(_.jo(c,a.eo+"/"+b.Ti),e+"/"+d);_.io(c,b.Cd()).Nh(b.wd)};_.yo.prototype.fy=_.ea(17);_.g=_.zo.prototype; _.g.vQ=function(a){var b=new _.ho(a);a=new _.So(b.value());if(a.R.selfConnect)var c=this;else(_.Ym(Zo.test(b.Qa()),"Illegal origin for connected iframe - "+b.Qa()),c=this.Od.Ge[b.Cd()],c)?_.mo(b)&&(c.$i(),_.Ao(c,"_g_rpcReady")):(b=_.io(_.ko(_.jo((new _.ho).tk(_.Un(b)),b.xl()),_.lo(b)).Nh(b.Qa()),b.Cd()).$i(_.mo(b)),c=this.Od.uj(b.value()));b=this.Od;var d=a.R.role;a=a.R.data;bp(b);d=d||"";_.Td(b.hy,d,[]).push({yf:c.Cd(),data:a});cp(c,a,b.wB[d])}; _.g.aD=function(a,b){(new _.ho(b)).R._relayedDepth||(b={},_.Uo(_.To(new _.So(b),"_opener")),_.Ao(a,"_g_connect",b))}; _.g.VJ=function(a){var b=this,c=a.R.messageHandlers,d=a.R.messageHandlersFilter,e=a.R.onClose;_.Qo(_.Wn(_.Vn(a,null),null),null);_.mh();return _.Ao(this,"_g_open",a.value()).then(function(f){var h=new _.ho(f[0]),k=h.Cd();f=new _.ho;var l=b.eo,n=_.lo(h);_.ko(_.jo(f,b.Ti+"/"+h.xl()),n+"/"+l);_.io(f,k);f.Nh(h.Qa());f.oo(h.R.apis);f.tk(_.Un(a));_.Vn(f,c);_.Wn(f,d);_.Qo(f,e);(h=b.Od.Ge[k])||(h=b.Od.uj(f.value()));return h})}; _.g.vC=function(a){var b=a.getUrl();_.Ym(!b||_.nn.test(b),"Illegal url for new iframe - "+b);var c=a.hn().value();b={};for(var d in c)_.Ud(c,d)&&_.Ud($o,d)&&(b[d]=c[d]);_.Ud(c,"style")&&(d=c.style,"object"===typeof d&&(b.style=_.No(d)));a.value().attributes=b}; _.g.gX=function(a){a=new _.ho(a);this.vC(a);var b=a.R._relayedDepth||0;a.R._relayedDepth=b+1;a.R.openerIframe=this;_.mh();var c=_.Un(a);a.tk(null);return this.Od.open(a.value()).then((0,_.A)(function(a){var d=(new _.ho(a.Ob())).R.apis,f=new _.ho;_.ap(a,this,f);0==b&&_.To(new _.So(f.value()),"_opener");f.$i(!0);f.tk(c);_.Ao(a,"_g_connect",f.value());f=new _.ho;_.io(_.ko(_.jo(f.oo(d),a.xl()),a.eo),a.Cd()).Nh(a.Qa());return f.value()},this))};var bp=function(a){a.hy||(a.hy=_.D(),a.wB=_.D())}; _.yo.prototype.xx=function(a,b,c,d){bp(this);"object"===typeof a?(b=new Vo(a),c=b.xH()||""):(b=Xo(Wo(a).Xb(b).oo(c),d),c=a);d=this.hy[c]||[];a=!1;for(var e=0;e<d.length&&!a;e++)cp(this.Ge[d[e].yf],d[e].data,[b]),a=b.R.runOnce;c=_.Td(this.wB,c,[]);a||b.R.dontWait||c.push(b)};_.yo.prototype.vK=_.ea(18); var cp=function(a,b,c){c=c||[];for(var d=0;d<c.length;d++){var e=c[d];if(e&&a){var f=e.R.filter||_.po;if(a&&f(a)){f=e.R.apis||[];for(var h=0;h<f.length;h++)a.Yo(f[h]);e.Bb()&&e.Bb()(a,b);e.R.runOnce&&(c.splice(d,1),--d)}}}};_.yo.prototype.sj=function(a,b,c){this.xx(Yo(Xo(Wo("_opener").Xb(a).oo(b),c)).value())};_.zo.prototype.sY=function(a){this.getContext().sj(function(b){b.send("_g_wasRestyled",a,void 0,_.M)},null,_.M)};var dp=_.ao.hb;dp&&dp.register("_g_restyleDone",_.zo.prototype.sY,_.M); _.vo("_g_connect",_.zo.prototype.vQ);var ep={};ep._g_open=_.zo.prototype.gX;_.to("_open",ep,_.M); _.w("gapi.iframes.create",_.Kn); _.zo.prototype.sK=_.rc(16,function(a,b){this.register("_g_wasRestyled",a,b)});_.g=_.yo.prototype;_.g.rL=_.rc(15,function(a){this.gw("onRestyleSelfFilter",a)});_.g.bL=_.rc(14,function(a){this.gw("onCloseSelfFilter",a)});_.g.pH=_.rc(13,function(){return this.hb});_.g.gw=_.rc(12,function(a,b){this.bK[a]=b});_.g.Dn=_.rc(3,function(){return this.Fb});_.zo.prototype.Dn=_.rc(2,function(){return this.Fb});_.w("gapi.iframes.registerStyle",function(a,b){_.Go[a]=b}); _.w("gapi.iframes.registerBeforeOpenStyle",function(a,b){_.Do[a]=b});_.w("gapi.iframes.getStyle",_.Fo);_.w("gapi.iframes.getBeforeOpenStyle",function(a){return _.Do[a]});_.w("gapi.iframes.registerIframesApi",_.to);_.w("gapi.iframes.registerIframesApiHandler",_.uo);_.w("gapi.iframes.getContext",_.wo);_.w("gapi.iframes.SAME_ORIGIN_IFRAMES_FILTER",_.po);_.w("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER",_.M);_.w("gapi.iframes.makeWhiteListIframesFilter",_.qo);_.w("gapi.iframes.Context",_.yo); _.w("gapi.iframes.Context.prototype.isDisposed",_.yo.prototype.Dn);_.w("gapi.iframes.Context.prototype.getWindow",_.yo.prototype.vb);_.w("gapi.iframes.Context.prototype.getFrameName",_.yo.prototype.Cd);_.w("gapi.iframes.Context.prototype.getGlobalParam",_.yo.prototype.Ez);_.w("gapi.iframes.Context.prototype.setGlobalParam",_.yo.prototype.gw);_.w("gapi.iframes.Context.prototype.open",_.yo.prototype.open);_.w("gapi.iframes.Context.prototype.openChild",_.yo.prototype.Tg); _.w("gapi.iframes.Context.prototype.getParentIframe",_.yo.prototype.pH);_.w("gapi.iframes.Context.prototype.closeSelf",_.yo.prototype.dy);_.w("gapi.iframes.Context.prototype.restyleSelf",_.yo.prototype.sC);_.w("gapi.iframes.Context.prototype.setCloseSelfFilter",_.yo.prototype.bL);_.w("gapi.iframes.Context.prototype.setRestyleSelfFilter",_.yo.prototype.rL);_.w("gapi.iframes.Iframe",_.zo);_.w("gapi.iframes.Iframe.prototype.isDisposed",_.zo.prototype.Dn); _.w("gapi.iframes.Iframe.prototype.getContext",_.zo.prototype.getContext);_.w("gapi.iframes.Iframe.prototype.getFrameName",_.zo.prototype.Cd);_.w("gapi.iframes.Iframe.prototype.getId",_.zo.prototype.ka);_.w("gapi.iframes.Iframe.prototype.register",_.zo.prototype.register);_.w("gapi.iframes.Iframe.prototype.unregister",_.zo.prototype.unregister);_.w("gapi.iframes.Iframe.prototype.send",_.zo.prototype.send);_.w("gapi.iframes.Iframe.prototype.applyIframesApi",_.zo.prototype.Yo); _.w("gapi.iframes.Iframe.prototype.getIframeEl",_.zo.prototype.Ha);_.w("gapi.iframes.Iframe.prototype.getSiteEl",_.zo.prototype.$a);_.w("gapi.iframes.Iframe.prototype.setSiteEl",_.zo.prototype.Ze);_.w("gapi.iframes.Iframe.prototype.getWindow",_.zo.prototype.vb);_.w("gapi.iframes.Iframe.prototype.getOrigin",_.zo.prototype.Qa);_.w("gapi.iframes.Iframe.prototype.close",_.zo.prototype.close);_.w("gapi.iframes.Iframe.prototype.restyle",_.zo.prototype.tr); _.w("gapi.iframes.Iframe.prototype.restyleDone",_.zo.prototype.bo);_.w("gapi.iframes.Iframe.prototype.registerWasRestyled",_.zo.prototype.sK);_.w("gapi.iframes.Iframe.prototype.registerWasClosed",_.zo.prototype.ik);_.w("gapi.iframes.Iframe.prototype.getParam",_.zo.prototype.Mz);_.w("gapi.iframes.Iframe.prototype.setParam",_.zo.prototype.pL);_.w("gapi.iframes.Iframe.prototype.ping",_.zo.prototype.ping); var LM=function(a,b){a.R.data=b;return a};_.yo.prototype.vK=_.rc(18,function(a,b){a=_.Td(this.wB,a,[]);if(b)for(var c=0,d=!1;!d&&c<a.length;c++)a[c].Oe===b&&(d=!0,a.splice(c,1));else a.splice(0,a.length)}); _.yo.prototype.fy=_.rc(17,function(a,b){a=new _.So(a);var c=new _.So(b),d=_.mo(a);b=a.getIframe();var e=c.getIframe();if(e){var f=_.Un(a),h=new _.ho;_.ap(b,e,h);LM(_.To((new _.So(h.value())).tk(f),a.R.role),a.R.data).$i(d);var k=new _.ho;_.ap(e,b,k);LM(_.To((new _.So(k.value())).tk(f),c.R.role),c.R.data).$i(!0);_.Ao(b,"_g_connect",h.value(),function(){d||_.Ao(e,"_g_connect",k.value())});d&&_.Ao(e,"_g_connect",k.value())}else c={},LM(_.To(_.Uo(new _.So(c)),a.R.role),a.R.data),_.Ao(b,"_g_connect",c)}); _.w("gapi.iframes.Context.prototype.addOnConnectHandler",_.yo.prototype.xx);_.w("gapi.iframes.Context.prototype.removeOnConnectHandler",_.yo.prototype.vK);_.w("gapi.iframes.Context.prototype.addOnOpenerHandler",_.yo.prototype.sj);_.w("gapi.iframes.Context.prototype.connectIframes",_.yo.prototype.fy); _.ak=window.googleapis&&window.googleapis.server||{}; (function(){function a(a,b){if(!(a<c)&&d)if(2===a&&d.warn)d.warn(b);else if(3===a&&d.error)try{d.error(b)}catch(h){}else d.log&&d.log(b)}var b=function(b){a(1,b)};_.Ra=function(b){a(2,b)};_.Sa=function(b){a(3,b)};_.oe=function(){};b.INFO=1;b.WARNING=2;b.NONE=4;var c=1,d=window.console?window.console:window.opera?window.opera.postError:void 0;return b})(); _.pe=function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(_.Wa(d)){var e=a.length||0,f=d.length||0;a.length=e+f;for(var h=0;h<f;h++)a[e+h]=d[h]}else a.push(d)}}; _.I=_.I||{};_.I.Hs=function(a,b,c,d){"undefined"!=typeof a.addEventListener?a.addEventListener(b,c,d):"undefined"!=typeof a.attachEvent?a.attachEvent("on"+b,c):_.Ra("cannot attachBrowserEvent: "+b)};_.I.VX=function(a){var b=window;b.removeEventListener?b.removeEventListener("mousemove",a,!1):b.detachEvent?b.detachEvent("onmousemove",a):_.Ra("cannot removeBrowserEvent: mousemove")}; _.bk=function(){function a(){e[0]=1732584193;e[1]=4023233417;e[2]=2562383102;e[3]=271733878;e[4]=3285377520;p=n=0}function b(a){for(var b=h,c=0;64>c;c+=4)b[c/4]=a[c]<<24|a[c+1]<<16|a[c+2]<<8|a[c+3];for(c=16;80>c;c++)a=b[c-3]^b[c-8]^b[c-14]^b[c-16],b[c]=(a<<1|a>>>31)&4294967295;a=e[0];var d=e[1],f=e[2],k=e[3],l=e[4];for(c=0;80>c;c++){if(40>c)if(20>c){var n=k^d&(f^k);var p=1518500249}else n=d^f^k,p=1859775393;else 60>c?(n=d&f|k&(d|f),p=2400959708):(n=d^f^k,p=3395469782);n=((a<<5|a>>>27)&4294967295)+ n+l+p+b[c]&4294967295;l=k;k=f;f=(d<<30|d>>>2)&4294967295;d=a;a=n}e[0]=e[0]+a&4294967295;e[1]=e[1]+d&4294967295;e[2]=e[2]+f&4294967295;e[3]=e[3]+k&4294967295;e[4]=e[4]+l&4294967295}function c(a,c){if("string"===typeof a){a=(0,window.unescape)((0,window.encodeURIComponent)(a));for(var d=[],e=0,h=a.length;e<h;++e)d.push(a.charCodeAt(e));a=d}c||(c=a.length);d=0;if(0==n)for(;d+64<c;)b(a.slice(d,d+64)),d+=64,p+=64;for(;d<c;)if(f[n++]=a[d++],p++,64==n)for(n=0,b(f);d+64<c;)b(a.slice(d,d+64)),d+=64,p+=64} function d(){var a=[],d=8*p;56>n?c(k,56-n):c(k,64-(n-56));for(var h=63;56<=h;h--)f[h]=d&255,d>>>=8;b(f);for(h=d=0;5>h;h++)for(var l=24;0<=l;l-=8)a[d++]=e[h]>>l&255;return a}for(var e=[],f=[],h=[],k=[128],l=1;64>l;++l)k[l]=0;var n,p;a();return{reset:a,update:c,digest:d,Ig:function(){for(var a=d(),b="",c=0;c<a.length;c++)b+="0123456789ABCDEF".charAt(Math.floor(a[c]/16))+"0123456789ABCDEF".charAt(a[c]%16);return b}}}; _.ck=function(){function a(a){var b=_.bk();b.update(a);return b.Ig()}var b=window.crypto;if(b&&"function"==typeof b.getRandomValues)return function(){var a=new window.Uint32Array(1);b.getRandomValues(a);return Number("0."+a[0])};var c=_.H("random/maxObserveMousemove");null==c&&(c=-1);var d=0,e=Math.random(),f=1,h=1E6*(window.screen.width*window.screen.width+window.screen.height),k=function(a){a=a||window.event;var b=a.screenX+a.clientX<<16;b+=a.screenY+a.clientY;b*=(new Date).getTime()%1E6;f=f*b% h;0<c&&++d==c&&_.I.VX(k)};0!=c&&_.I.Hs(window,"mousemove",k,!1);var l=a(window.document.cookie+"|"+window.document.location+"|"+(new Date).getTime()+"|"+e);return function(){var b=f;b+=(0,window.parseInt)(l.substr(0,20),16);l=a(l);return b/(h+Math.pow(16,20))}}(); _.w("shindig.random",_.ck); _.I=_.I||{};(function(){var a=[];_.I.P9=function(b){a.push(b)};_.I.c$=function(){for(var b=0,c=a.length;b<c;++b)a[b]()}})(); _.we=function(){var a=window.gadgets&&window.gadgets.config&&window.gadgets.config.get;a&&_.le(a());return{register:function(a,c,d){d&&d(_.H())},get:function(a){return _.H(a)},update:function(a,c){if(c)throw"Config replacement is not supported";_.le(a)},Pb:function(){}}}(); _.w("gadgets.config.register",_.we.register);_.w("gadgets.config.get",_.we.get);_.w("gadgets.config.init",_.we.Pb);_.w("gadgets.config.update",_.we.update); var jf;_.gf=function(){var a=_.Qd.readyState;return"complete"===a||"interactive"===a&&-1==window.navigator.userAgent.indexOf("MSIE")};_.hf=function(a){if(_.gf())a();else{var b=!1,c=function(){if(!b)return b=!0,a.apply(this,arguments)};_.Nd.addEventListener?(_.Nd.addEventListener("load",c,!1),_.Nd.addEventListener("DOMContentLoaded",c,!1)):_.Nd.attachEvent&&(_.Nd.attachEvent("onreadystatechange",function(){_.gf()&&c.apply(this,arguments)}),_.Nd.attachEvent("onload",c))}};jf=jf||{};jf.HK=null; jf.zJ=null;jf.uu=null;jf.frameElement=null; jf=jf||{}; jf.ZD||(jf.ZD=function(){function a(a,b,c){"undefined"!=typeof window.addEventListener?window.addEventListener(a,b,c):"undefined"!=typeof window.attachEvent&&window.attachEvent("on"+a,b);"message"===a&&(window.___jsl=window.___jsl||{},a=window.___jsl,a.RPMQ=a.RPMQ||[],a.RPMQ.push(b))}function b(a){var b=_.cf(a.data);if(b&&b.f){(0,_.oe)("gadgets.rpc.receive("+window.name+"): "+a.data);var d=_.K.Bl(b.f);e&&("undefined"!==typeof a.origin?a.origin!==d:a.domain!==/^.+:\/\/([^:]+).*/.exec(d)[1])?_.Sa("Invalid rpc message origin. "+ d+" vs "+(a.origin||"")):c(b,a.origin)}}var c,d,e=!0;return{ZG:function(){return"wpm"},RV:function(){return!0},Pb:function(f,h){_.we.register("rpc",null,function(a){"true"===String((a&&a.rpc||{}).disableForceSecure)&&(e=!1)});c=f;d=h;a("message",b,!1);d("..",!0);return!0},Dc:function(a){d(a,!0);return!0},call:function(a,b,c){var d=_.K.Bl(a),e=_.K.bF(a);d?window.setTimeout(function(){var a=_.df(c);(0,_.oe)("gadgets.rpc.send("+window.name+"): "+a);e.postMessage(a,d)},0):".."!=a&&_.Sa("No relay set (used as window.postMessage targetOrigin), cannot send cross-domain message"); return!0}}}()); if(window.gadgets&&window.gadgets.rpc)"undefined"!=typeof _.K&&_.K||(_.K=window.gadgets.rpc,_.K.config=_.K.config,_.K.register=_.K.register,_.K.unregister=_.K.unregister,_.K.qK=_.K.registerDefault,_.K.oM=_.K.unregisterDefault,_.K.RG=_.K.forceParentVerifiable,_.K.call=_.K.call,_.K.kq=_.K.getRelayUrl,_.K.Ph=_.K.setRelayUrl,_.K.ew=_.K.setAuthToken,_.K.Hr=_.K.setupReceiver,_.K.fl=_.K.getAuthToken,_.K.kC=_.K.removeReceiver,_.K.uH=_.K.getRelayChannel,_.K.nK=_.K.receive,_.K.pK=_.K.receiveSameDomain,_.K.Qa= _.K.getOrigin,_.K.Bl=_.K.getTargetOrigin,_.K.bF=_.K._getTargetWin,_.K.xP=_.K._parseSiblingId);else{_.K=function(){function a(a,b){if(!aa[a]){var c=R;b||(c=ka);aa[a]=c;b=la[a]||[];for(var d=0;d<b.length;++d){var e=b[d];e.t=G[a];c.call(a,e.f,e)}la[a]=[]}}function b(){function a(){Ga=!0}N||("undefined"!=typeof window.addEventListener?window.addEventListener("unload",a,!1):"undefined"!=typeof window.attachEvent&&window.attachEvent("onunload",a),N=!0)}function c(a,c,d,e,f){G[c]&&G[c]===d||(_.Sa("Invalid gadgets.rpc token. "+ G[c]+" vs "+d),ua(c,2));f.onunload=function(){J[c]&&!Ga&&(ua(c,1),_.K.kC(c))};b();e=_.cf((0,window.decodeURIComponent)(e))}function d(b,c){if(b&&"string"===typeof b.s&&"string"===typeof b.f&&b.a instanceof Array)if(G[b.f]&&G[b.f]!==b.t&&(_.Sa("Invalid gadgets.rpc token. "+G[b.f]+" vs "+b.t),ua(b.f,2)),"__ack"===b.s)window.setTimeout(function(){a(b.f,!0)},0);else{b.c&&(b.callback=function(a){_.K.call(b.f,(b.g?"legacy__":"")+"__cb",null,b.c,a)});if(c){var d=e(c);b.origin=c;var f=b.r;try{var h=e(f)}catch(Ha){}f&& h==d||(f=c);b.referer=f}c=(y[b.s]||y[""]).apply(b,b.a);b.c&&"undefined"!==typeof c&&_.K.call(b.f,"__cb",null,b.c,c)}}function e(a){if(!a)return"";a=a.split("#")[0].split("?")[0];a=a.toLowerCase();0==a.indexOf("//")&&(a=window.location.protocol+a);-1==a.indexOf("://")&&(a=window.location.protocol+"//"+a);var b=a.substring(a.indexOf("://")+3),c=b.indexOf("/");-1!=c&&(b=b.substring(0,c));a=a.substring(0,a.indexOf("://"));if("http"!==a&&"https"!==a&&"chrome-extension"!==a&&"file"!==a&&"android-app"!== a&&"chrome-search"!==a)throw Error("p");c="";var d=b.indexOf(":");if(-1!=d){var e=b.substring(d+1);b=b.substring(0,d);if("http"===a&&"80"!==e||"https"===a&&"443"!==e)c=":"+e}return a+"://"+b+c}function f(a){if("/"==a.charAt(0)){var b=a.indexOf("|");return{id:0<b?a.substring(1,b):a.substring(1),origin:0<b?a.substring(b+1):null}}return null}function h(a){if("undefined"===typeof a||".."===a)return window.parent;var b=f(a);if(b)return window.top.frames[b.id];a=String(a);return(b=window.frames[a])?b:(b= window.document.getElementById(a))&&b.contentWindow?b.contentWindow:null}function k(a,b){if(!0!==J[a]){"undefined"===typeof J[a]&&(J[a]=0);var c=h(a);".."!==a&&null==c||!0!==R.Dc(a,b)?!0!==J[a]&&10>J[a]++?window.setTimeout(function(){k(a,b)},500):(aa[a]=ka,J[a]=!0):J[a]=!0}}function l(a){(a=F[a])&&"/"===a.substring(0,1)&&(a="/"===a.substring(1,2)?window.document.location.protocol+a:window.document.location.protocol+"//"+window.document.location.host+a);return a}function n(a,b,c){b&&!/http(s)?:\/\/.+/.test(b)&& (0==b.indexOf("//")?b=window.location.protocol+b:"/"==b.charAt(0)?b=window.location.protocol+"//"+window.location.host+b:-1==b.indexOf("://")&&(b=window.location.protocol+"//"+b));F[a]=b;"undefined"!==typeof c&&(E[a]=!!c)}function p(a,b){b=b||"";G[a]=String(b);k(a,b)}function q(a){a=(a.passReferrer||"").split(":",2);za=a[0]||"none";pa=a[1]||"origin"}function t(b){"true"===String(b.useLegacyProtocol)&&(R=jf.uu||ka,R.Pb(d,a))}function x(a,b){function c(c){c=c&&c.rpc||{};q(c);var d=c.parentRelayUrl|| "";d=e(V.parent||b)+d;n("..",d,"true"===String(c.useLegacyProtocol));t(c);p("..",a)}!V.parent&&b?c({}):_.we.register("rpc",null,c)}function v(a,b,c){if(".."===a)x(c||V.rpctoken||V.ifpctok||"",b);else a:{var d=null;if("/"!=a.charAt(0)){if(!_.I)break a;d=window.document.getElementById(a);if(!d)throw Error("q`"+a);}d=d&&d.src;b=b||_.K.Qa(d);n(a,b);b=_.I.xc(d);p(a,c||b.rpctoken)}}var y={},F={},E={},G={},B=0,L={},J={},V={},aa={},la={},za=null,pa=null,ba=window.top!==window.self,qa=window.name,ua=function(){}, db=window.console,ra=db&&db.log&&function(a){db.log(a)}||function(){},ka=function(){function a(a){return function(){ra(a+": call ignored")}}return{ZG:function(){return"noop"},RV:function(){return!0},Pb:a("init"),Dc:a("setup"),call:a("call")}}();_.I&&(V=_.I.xc());var Ga=!1,N=!1,R=function(){if("rmr"==V.rpctx)return jf.HK;var a="function"===typeof window.postMessage?jf.ZD:"object"===typeof window.postMessage?jf.ZD:window.ActiveXObject?jf.zJ?jf.zJ:jf.uu:0<window.navigator.userAgent.indexOf("WebKit")? jf.HK:"Gecko"===window.navigator.product?jf.frameElement:jf.uu;a||(a=ka);return a}();y[""]=function(){ra("Unknown RPC service: "+this.s)};y.__cb=function(a,b){var c=L[a];c&&(delete L[a],c.call(this,b))};return{config:function(a){"function"===typeof a.MK&&(ua=a.MK)},register:function(a,b){if("__cb"===a||"__ack"===a)throw Error("r");if(""===a)throw Error("s");y[a]=b},unregister:function(a){if("__cb"===a||"__ack"===a)throw Error("t");if(""===a)throw Error("u");delete y[a]},qK:function(a){y[""]=a},oM:function(){delete y[""]}, RG:function(){},call:function(a,b,c,d){a=a||"..";var e="..";".."===a?e=qa:"/"==a.charAt(0)&&(e=_.K.Qa(window.location.href),e="/"+qa+(e?"|"+e:""));++B;c&&(L[B]=c);var h={s:b,f:e,c:c?B:0,a:Array.prototype.slice.call(arguments,3),t:G[a],l:!!E[a]};a:if("bidir"===za||"c2p"===za&&".."===a||"p2c"===za&&".."!==a){var k=window.location.href;var l="?";if("query"===pa)l="#";else if("hash"===pa)break a;l=k.lastIndexOf(l);l=-1===l?k.length:l;k=k.substring(0,l)}else k=null;k&&(h.r=k);if(".."===a||null!=f(a)|| window.document.getElementById(a))(k=aa[a])||null===f(a)||(k=R),0===b.indexOf("legacy__")&&(k=R,h.s=b.substring(8),h.c=h.c?h.c:B),h.g=!0,h.r=e,k?(E[a]&&(k=jf.uu),!1===k.call(a,e,h)&&(aa[a]=ka,R.call(a,e,h))):la[a]?la[a].push(h):la[a]=[h]},kq:l,Ph:n,ew:p,Hr:v,fl:function(a){return G[a]},kC:function(a){delete F[a];delete E[a];delete G[a];delete J[a];delete aa[a]},uH:function(){return R.ZG()},nK:function(a,b){4<a.length?R.V7(a,d):c.apply(null,a.concat(b))},pK:function(a){a.a=Array.prototype.slice.call(a.a); window.setTimeout(function(){d(a)},0)},Qa:e,Bl:function(a){var b=null,c=l(a);c?b=c:(c=f(a))?b=c.origin:".."==a?b=V.parent:(a=window.document.getElementById(a))&&"iframe"===a.tagName.toLowerCase()&&(b=a.src);return e(b)},Pb:function(){!1===R.Pb(d,a)&&(R=ka);ba?v(".."):_.we.register("rpc",null,function(a){a=a.rpc||{};q(a);t(a)})},bF:h,xP:f,c0:"__ack",E5:qa||"..",T5:0,S5:1,R5:2}}();_.K.Pb()}; _.K.config({MK:function(a){throw Error("v`"+a);}});_.oe=_.ve;_.w("gadgets.rpc.config",_.K.config);_.w("gadgets.rpc.register",_.K.register);_.w("gadgets.rpc.unregister",_.K.unregister);_.w("gadgets.rpc.registerDefault",_.K.qK);_.w("gadgets.rpc.unregisterDefault",_.K.oM);_.w("gadgets.rpc.forceParentVerifiable",_.K.RG);_.w("gadgets.rpc.call",_.K.call);_.w("gadgets.rpc.getRelayUrl",_.K.kq);_.w("gadgets.rpc.setRelayUrl",_.K.Ph);_.w("gadgets.rpc.setAuthToken",_.K.ew);_.w("gadgets.rpc.setupReceiver",_.K.Hr);_.w("gadgets.rpc.getAuthToken",_.K.fl); _.w("gadgets.rpc.removeReceiver",_.K.kC);_.w("gadgets.rpc.getRelayChannel",_.K.uH);_.w("gadgets.rpc.receive",_.K.nK);_.w("gadgets.rpc.receiveSameDomain",_.K.pK);_.w("gadgets.rpc.getOrigin",_.K.Qa);_.w("gadgets.rpc.getTargetOrigin",_.K.Bl); var dk=function(a){return{execute:function(b){var c={method:a.httpMethod||"GET",root:a.root,path:a.url,params:a.urlParams,headers:a.headers,body:a.body},d=window.gapi,e=function(){var a=d.config.get("client/apiKey"),e=d.config.get("client/version");try{var k=d.config.get("googleapis.config/developerKey"),l=d.config.get("client/apiKey",k);d.config.update("client/apiKey",l);d.config.update("client/version","1.0.0-alpha");var n=d.client;n.request.call(n,c).then(b,b)}finally{d.config.update("client/apiKey", a),d.config.update("client/version",e)}};d.client?e():d.load.call(d,"client",e)}}},ek=function(a,b){return function(c){var d={};c=c.body;var e=_.cf(c),f={};if(e&&e.length)for(var h=0,k=e.length;h<k;++h){var l=e[h];f[l.id]=l}h=0;for(k=b.length;h<k;++h)l=b[h].id,d[l]=e&&e.length?f[l]:e;a(d,c)}},fk=function(a){a.transport={name:"googleapis",execute:function(b,c){for(var d=[],e=0,f=b.length;e<f;++e){var h=b[e],k=h.method,l=String(k).split(".")[0];l=_.H("googleapis.config/versions/"+k)||_.H("googleapis.config/versions/"+ l)||"v1";d.push({jsonrpc:"2.0",id:h.id,method:k,apiVersion:String(l),params:h.params})}b=dk({httpMethod:"POST",root:a.transport.root,url:"/rpc?pp=0",headers:{"Content-Type":"application/json"},body:d});b.execute.call(b,ek(c,d))},root:void 0}},gk=function(a){var b=this.method,c=this.transport;c.execute.call(c,[{method:b,id:b,params:this.rpc}],function(c){c=c[b];c.error||(c=c.data||c.result);a(c)})},ik=function(){for(var a=hk,b=a.split("."),c=function(b){b=b||{};b.groupId=b.groupId||"@self";b.userId= b.userId||"@viewer";b={method:a,rpc:b||{}};fk(b);b.execute=gk;return b},d=_.m,e=0,f=b.length;e<f;++e){var h=d[b[e]]||{};e+1==f&&(h=c);d=d[b[e]]=h}if(1<b.length&&"googleapis"!=b[0])for(b[0]="googleapis","delete"==b[b.length-1]&&(b[b.length-1]="remove"),d=_.m,e=0,f=b.length;e<f;++e)h=d[b[e]]||{},e+1==f&&(h=c),d=d[b[e]]=h},hk;for(hk in _.H("googleapis.config/methods"))ik(); _.w("googleapis.newHttpRequest",function(a){return dk(a)});_.w("googleapis.setUrlParameter",function(a,b){if("trace"!==a)throw Error("M");_.le("client/trace",b)}); _.fp=_.Td(_.ce,"rw",_.D()); var gp=function(a,b){(a=_.fp[a])&&a.state<b&&(a.state=b)};var hp=function(a){a=(a=_.fp[a])?a.oid:void 0;if(a){var b=_.Qd.getElementById(a);b&&b.parentNode.removeChild(b);delete _.fp[a];hp(a)}};_.ip=function(a){a=a.container;"string"===typeof a&&(a=window.document.getElementById(a));return a};_.jp=function(a){var b=a.clientWidth;return"position:absolute;top:-10000px;width:"+(b?b+"px":a.style.width||"300px")+";margin:0px;border-style:none;"}; _.kp=function(a,b){var c={},d=a.Ob(),e=b&&b.width,f=b&&b.height,h=b&&b.verticalAlign;h&&(c.verticalAlign=h);e||(e=d.width||a.width);f||(f=d.height||a.height);d.width=c.width=e;d.height=c.height=f;d=a.Ha();e=a.ka();gp(e,2);a:{e=a.$a();c=c||{};if(_.ce.oa){var k=d.id;if(k){f=(f=_.fp[k])?f.state:void 0;if(1===f||4===f)break a;hp(k)}}(f=e.nextSibling)&&f.getAttribute&&f.getAttribute("data-gapistub")&&(e.parentNode.removeChild(f),e.style.cssText="");f=c.width;h=c.height;var l=e.style;l.textIndent="0";l.margin= "0";l.padding="0";l.background="transparent";l.borderStyle="none";l.cssFloat="none";l.styleFloat="none";l.lineHeight="normal";l.fontSize="1px";l.verticalAlign="baseline";e=e.style;e.display="inline-block";d=d.style;d.position="static";d.left="0";d.top="0";d.visibility="visible";f&&(e.width=d.width=f+"px");h&&(e.height=d.height=h+"px");c.verticalAlign&&(e.verticalAlign=c.verticalAlign);k&&gp(k,3)}(k=b?b.title:null)&&a.Ha().setAttribute("title",k);(b=b?b.ariaLabel:null)&&a.Ha().setAttribute("aria-label", b)};_.lp=function(a){var b=a.$a();b&&b.removeChild(a.Ha())};_.mp=function(a){a.where=_.ip(a);var b=a.messageHandlers=a.messageHandlers||{},c=function(a){_.kp(this,a)};b._ready=c;b._renderstart=c;var d=a.onClose;a.onClose=function(a){d&&d.call(this,a);_.lp(this)};a.onCreate=function(a){a=a.Ha();a.style.cssText=_.jp(a)}}; var Yj=_.Xj=_.Xj||{};window.___jsl=window.___jsl||{};Yj.Mx={E8:function(){return window.___jsl.bsh},iH:function(){return window.___jsl.h},KC:function(a){window.___jsl.bsh=a},qZ:function(a){window.___jsl.h=a}}; _.I=_.I||{};_.I.Yu=function(a,b,c){for(var d=[],e=2,f=arguments.length;e<f;++e)d.push(arguments[e]);return function(){for(var c=d.slice(),e=0,f=arguments.length;e<f;++e)c.push(arguments[e]);return b.apply(a,c)}};_.I.Rq=function(a){var b,c,d={};for(b=0;c=a[b];++b)d[c]=c;return d}; _.I=_.I||{}; (function(){function a(a,b){return String.fromCharCode(b)}var b={0:!1,10:!0,13:!0,34:!0,39:!0,60:!0,62:!0,92:!0,8232:!0,8233:!0,65282:!0,65287:!0,65308:!0,65310:!0,65340:!0};_.I.escape=function(a,b){if(a){if("string"===typeof a)return _.I.Ft(a);if("Array"===typeof a){var c=0;for(b=a.length;c<b;++c)a[c]=_.I.escape(a[c])}else if("object"===typeof a&&b){b={};for(c in a)a.hasOwnProperty(c)&&(b[_.I.Ft(c)]=_.I.escape(a[c],!0));return b}}return a};_.I.Ft=function(a){if(!a)return a;for(var c=[],e,f,h=0,k= a.length;h<k;++h)e=a.charCodeAt(h),f=b[e],!0===f?c.push("&#",e,";"):!1!==f&&c.push(a.charAt(h));return c.join("")};_.I.x$=function(b){return b?b.replace(/&#([0-9]+);/g,a):b}})(); _.O={};_.op={};window.iframer=_.op; _.O.Ia=_.O.Ia||{};_.O.Ia.fQ=function(a){try{return!!a.document}catch(b){}return!1};_.O.Ia.DH=function(a){var b=a.parent;return a!=b&&_.O.Ia.fQ(b)?_.O.Ia.DH(b):a};_.O.Ia.Z8=function(a){var b=a.userAgent||"";a=a.product||"";return 0!=b.indexOf("Opera")&&-1==b.indexOf("WebKit")&&"Gecko"==a&&0<b.indexOf("rv:1.")}; var Mr,Nr,Or,Qr,Rr,Sr,Xr,Yr,Zr,$r,bs,cs,ds,fs,gs,is;Mr=function(){_.O.tI++;return["I",_.O.tI,"_",(new Date).getTime()].join("")};Nr=function(a){return a instanceof Array?a.join(","):a instanceof Object?_.df(a):a};Or=function(){};Qr=function(a){a&&a.match(Pr)&&_.le("googleapis.config/gcv",a)};Rr=function(a){_.Xj.Mx.qZ(a)};Sr=function(a){_.Xj.Mx.KC(a)};_.Tr=function(a,b){b=b||{};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}; _.Vr=function(a,b,c,d,e){var f=[],h;for(h in a)if(a.hasOwnProperty(h)){var k=b,l=c,n=a[h],p=d,q=Ur(h);q[k]=q[k]||{};p=_.I.Yu(p,n);n._iframe_wrapped_rpc_&&(p._iframe_wrapped_rpc_=!0);q[k][l]=p;f.push(h)}if(e)for(h in _.O.tn)_.O.tn.hasOwnProperty(h)&&f.push(h);return f.join(",")};Xr=function(a,b,c){var d={};if(a&&a._methods){a=a._methods.split(",");for(var e=0;e<a.length;e++){var f=a[e];d[f]=Wr(f,b,c)}}return d}; Yr=function(a){if(a&&a.disableMultiLevelParentRelay)a=!1;else{var b;if(b=_.op&&_.op._open&&"inline"!=a.style&&!0!==a.inline)a=a.container,b=!(a&&("string"==typeof a&&window.document.getElementById(a)||window.document==(a.ownerDocument||a.document)));a=b}return a};Zr=function(a,b){var c={};b=b.params||{};for(var d in a)"#"==d.charAt(0)&&(c[d.substring(1)]=a[d]),0==d.indexOf("fr-")&&(c[d.substring(3)]=a[d]),"#"==b[d]&&(c[d]=a[d]);for(var e in c)delete a["fr-"+e],delete a["#"+e],delete a[e];return c}; $r=function(a){if(":"==a.charAt(0)){var b=_.H("iframes/"+a.substring(1));a={};_.Vd(b,a);(b=a.url)&&(a.url=_.In(b));a.params||(a.params={});return a}return{url:_.In(a)}};bs=function(a){function b(){}b.prototype=as.prototype;a.prototype=new b};cs=function(a){return _.O.Rr[a]};ds=function(a,b){_.O.Rr[a]=b};fs=function(a){a=a||{};"auto"===a.height&&(a.height=_.Jm.Xc());var b=window&&es&&es.Na();b?b.DK(a.width||0,a.height||0):_.op&&_.op._resizeMe&&_.op._resizeMe(a)};gs=function(a){Qr(a)}; _.hs=function(){return _.Nd.location.origin||_.Nd.location.protocol+"//"+_.Nd.location.host};is=function(a){var b=_.Xd(a.location.href,"urlindex");if(b=_.Td(_.ce,"fUrl",[])[b]){var c=a.location.hash;b+=/#/.test(b)?c.replace(/^#/,"&"):c;a.location.replace(b)}}; if(window.ToolbarApi)es=window.ToolbarApi,es.Na=window.ToolbarApi.getInstance,es.prototype=window.ToolbarApi.prototype,_.g=es.prototype,_.g.openWindow=es.prototype.openWindow,_.g.XF=es.prototype.closeWindow,_.g.nL=es.prototype.setOnCloseHandler,_.g.KF=es.prototype.canClosePopup,_.g.DK=es.prototype.resizeWindow;else{var es=function(){},js=null;es.Na=function(){!js&&window.external&&window.external.GTB_IsToolbar&&(js=new es);return js};_.g=es.prototype;_.g.openWindow=function(a){return window.external.GTB_OpenPopup&& window.external.GTB_OpenPopup(a)};_.g.XF=function(a){window.external.GTB_ClosePopupWindow&&window.external.GTB_ClosePopupWindow(a)};_.g.nL=function(a,b){window.external.GTB_SetOnCloseHandler&&window.external.GTB_SetOnCloseHandler(a,b)};_.g.KF=function(a){return window.external.GTB_CanClosePopup&&window.external.GTB_CanClosePopup(a)};_.g.DK=function(a,b){return window.external.GTB_ResizeWindow&&window.external.GTB_ResizeWindow(a,b)};window.ToolbarApi=es;window.ToolbarApi.getInstance=es.Na}; var ks=function(){_.K.register("_noop_echo",function(){this.callback(_.O.RS(_.O.Tj[this.f]))})},ls=function(){window.setTimeout(function(){_.K.call("..","_noop_echo",_.O.pX)},0)},Wr=function(a,b,c){var d=function(d){var e=Array.prototype.slice.call(arguments,0),h=e[e.length-1];if("function"===typeof h){var k=h;e.pop()}e.unshift(b,a,k,c);_.K.call.apply(_.K,e)};d._iframe_wrapped_rpc_=!0;return d},Ur=function(a){_.O.Lv[a]||(_.O.Lv[a]={},_.K.register(a,function(b,c){var d=this.f;if(!("string"!=typeof b|| b in{}||d in{})){var e=this.callback,f=_.O.Lv[a][d],h;f&&Object.hasOwnProperty.call(f,b)?h=f[b]:Object.hasOwnProperty.call(_.O.tn,a)&&(h=_.O.tn[a]);if(h)return d=Array.prototype.slice.call(arguments,1),h._iframe_wrapped_rpc_&&e&&d.push(e),h.apply({},d)}_.Sa(['Unregistered call in window "',window.name,'" for method "',a,'", via proxyId "',b,'" from frame "',d,'".'].join(""));return null}));return _.O.Lv[a]}; _.O.cQ=function(a,b,c){var d=Array.prototype.slice.call(arguments);_.O.qH(function(a){a.sameOrigin&&(d.unshift("/"+a.claimedOpenerId+"|"+window.location.protocol+"//"+window.location.host),_.K.call.apply(_.K,d))})};_.O.RX=function(a,b){_.K.register(a,b)}; var Pr=/^[-_.0-9A-Za-z]+$/,ms={open:"open",onready:"ready",close:"close",onresize:"resize",onOpen:"open",onReady:"ready",onClose:"close",onResize:"resize",onRenderStart:"renderstart"},ns={onBeforeParentOpen:"beforeparentopen"},os={onOpen:function(a){var b=a.Ob();a.Bf(b.container||b.element);return a},onClose:function(a){a.remove()}};_.O.hn=function(a){var b=_.D();_.Vd(_.wn,b);_.Vd(a,b);return b}; var as=function(a,b,c,d,e,f,h,k){this.config=$r(a);this.openParams=this.fr=b||{};this.params=c||{};this.methods=d;this.ww=!1;ps(this,b.style);this.jp={};qs(this,function(){var a;(a=this.fr.style)&&_.O.Rr[a]?a=_.O.Rr[a]:a?(_.Ra(['Missing handler for style "',a,'". Continuing with default handler.'].join("")),a=null):a=os;if(a){if("function"===typeof a)var b=a(this);else{var c={};for(b in a){var d=a[b];c[b]="function"===typeof d?_.I.Yu(a,d,this):d}b=c}for(var h in e)a=b[h],"function"===typeof a&&rs(this, e[h],_.I.Yu(b,a))}f&&rs(this,"close",f)});this.Ki=this.ac=h;this.HB=(k||[]).slice();h&&this.HB.unshift(h.ka())};as.prototype.Ob=function(){return this.fr};as.prototype.Nj=function(){return this.params};as.prototype.Xt=function(){return this.methods};as.prototype.Qc=function(){return this.Ki};var ps=function(a,b){a.ww||((b=b&&!_.O.Rr[b]&&_.O.wy[b])?(a.vy=[],b(function(){a.ww=!0;for(var b=0,d=a.vy.length;b<d;++b)a.vy[b].call(a)})):a.ww=!0)},qs=function(a,b){a.ww?b.call(a):a.vy.push(b)}; as.prototype.Uc=function(a,b){qs(this,function(){rs(this,a,b)})};var rs=function(a,b,c){a.jp[b]=a.jp[b]||[];a.jp[b].push(c)};as.prototype.cm=function(a,b){qs(this,function(){var c=this.jp[a];if(c)for(var d=0,e=c.length;d<e;++d)if(c[d]===b){c.splice(d,1);break}})}; as.prototype.Og=function(a,b){var c=this.jp[a];if(c)for(var d=Array.prototype.slice.call(arguments,1),e=0,f=c.length;e<f;++e)try{var h=c[e].apply({},d)}catch(k){_.Sa(['Exception when calling callback "',a,'" with exception "',k.name,": ",k.message,'".'].join(""))}return h}; var ss=function(a){return"number"==typeof a?{value:a,oz:a+"px"}:"100%"==a?{value:100,oz:"100%",QI:!0}:null},ts=function(a,b,c,d,e,f,h){as.call(this,a,b,c,d,ms,e,f,h);this.id=b.id||Mr();this.wr=b.rpctoken&&String(b.rpctoken)||Math.round(1E9*(0,_.ck)());this.WU=Zr(this.params,this.config);this.ez={};qs(this,function(){this.Og("open");_.Tr(this.ez,this)})};bs(ts);_.g=ts.prototype; _.g.Bf=function(a,b){if(!this.config.url)return _.Sa("Cannot open iframe, empty URL."),this;var c=this.id;_.O.Tj[c]=this;var d=_.Tr(this.methods);d._ready=this.uv;d._close=this.close;d._open=this.vv;d._resizeMe=this.Yn;d._renderstart=this.PJ;var e=this.WU;this.wr&&(e.rpctoken=this.wr);e._methods=_.Vr(d,c,"",this,!0);this.el=a="string"===typeof a?window.document.getElementById(a):a;d={};d.id=c;if(b){d.attributes=b;var f=b.style;if("string"===typeof f){if(f){var h=[];f=f.split(";");for(var k=0,l=f.length;k< l;++k){var n=f[k];if(0!=n.length||k+1!=l)n=n.split(":"),2==n.length&&n[0].match(/^[ a-zA-Z_-]+$/)&&n[1].match(/^[ +.%0-9a-zA-Z_-]+$/)?h.push(n.join(":")):_.Sa(['Iframe style "',f[k],'" not allowed.'].join(""))}h=h.join(";")}else h="";b.style=h}}this.Ob().allowPost&&(d.allowPost=!0);this.Ob().forcePost&&(d.forcePost=!0);d.queryParams=this.params;d.fragmentParams=e;d.paramsSerializer=Nr;this.Qg=_.Kn(this.config.url,a,d);a=this.Qg.getAttribute("data-postorigin")||this.Qg.src;_.O.Tj[c]=this;_.K.ew(this.id, this.wr);_.K.Ph(this.id,a);return this};_.g.le=function(a,b){this.ez[a]=b};_.g.ka=function(){return this.id};_.g.Ha=function(){return this.Qg};_.g.$a=function(){return this.el};_.g.Ze=function(a){this.el=a};_.g.uv=function(a){var b=Xr(a,this.id,"");this.Ki&&"function"==typeof this.methods._ready&&(a._methods=_.Vr(b,this.Ki.ka(),this.id,this,!1),this.methods._ready(a));_.Tr(a,this);_.Tr(b,this);this.Og("ready",a)};_.g.PJ=function(a){this.Og("renderstart",a)}; _.g.close=function(a){a=this.Og("close",a);delete _.O.Tj[this.id];return a};_.g.remove=function(){var a=window.document.getElementById(this.id);a&&a.parentNode&&a.parentNode.removeChild(a)}; _.g.vv=function(a){var b=Xr(a.params,this.id,a.proxyId);delete a.params._methods;"_parent"==a.openParams.anchor&&(a.openParams.anchor=this.el);if(Yr(a.openParams))new us(a.url,a.openParams,a.params,b,b._onclose,this,a.openedByProxyChain);else{var c=new ts(a.url,a.openParams,a.params,b,b._onclose,this,a.openedByProxyChain),d=this;qs(c,function(){var a={childId:c.ka()},f=c.ez;f._toclose=c.close;a._methods=_.Vr(f,d.id,c.id,c,!1);b._onopen(a)})}}; _.g.Yn=function(a){if(void 0===this.Og("resize",a)&&this.Qg){var b=ss(a.width);null!=b&&(this.Qg.style.width=b.oz);a=ss(a.height);null!=a&&(this.Qg.style.height=a.oz);this.Qg.parentElement&&(null!=b&&b.QI||null!=a&&a.QI)&&(this.Qg.parentElement.style.display="block")}}; var us=function(a,b,c,d,e,f,h){as.call(this,a,b,c,d,ns,e,f,h);this.url=a;this.xm=null;this.cC=Mr();qs(this,function(){this.Og("beforeparentopen");var a=_.Tr(this.methods);a._onopen=this.fX;a._ready=this.uv;a._onclose=this.dX;this.params._methods=_.Vr(a,"..",this.cC,this,!0);a={};for(c in this.params)a[c]=Nr(this.params[c]);var b=this.config.url;if(this.fr.hideUrlFromParent){var c=window.name;var d=b;b=_.ln(this.config.url,this.params,{},Nr);var e=a;a={};a._methods=e._methods;a["#opener"]=e["#opener"]; a["#urlindex"]=e["#urlindex"];a["#opener"]&&void 0!=e["#urlindex"]?(a["#opener"]=c+","+a["#opener"],c=d):(d=_.Td(_.ce,"fUrl",[]),e=d.length,d[e]=b,_.ce.rUrl=is,a["#opener"]=c,a["#urlindex"]=e,c=_.Xj.Qa(_.Nd.location.href),b=_.H("iframes/relay_url_"+(0,window.encodeURIComponent)(c))||"/_/gapi/sibling/1/frame.html",c+=b);b=c}_.op._open({url:b,openParams:this.fr,params:a,proxyId:this.cC,openedByProxyChain:this.HB})})};bs(us);us.prototype.iT=function(){return this.xm}; us.prototype.fX=function(a){this.xm=a.childId;var b=Xr(a,"..",this.xm);_.Tr(b,this);this.close=b._toclose;_.O.Tj[this.xm]=this;this.Ki&&this.methods._onopen&&(a._methods=_.Vr(b,this.Ki.ka(),this.xm,this,!1),this.methods._onopen(a))};us.prototype.uv=function(a){var b=String(this.xm),c=Xr(a,"..",b);_.Tr(a,this);_.Tr(c,this);this.Og("ready",a);this.Ki&&this.methods._ready&&(a._methods=_.Vr(c,this.Ki.ka(),b,this,!1),this.methods._ready(a))}; us.prototype.dX=function(a){if(this.Ki&&this.methods._onclose)this.methods._onclose(a);else return a=this.Og("close",a),delete _.O.Tj[this.xm],a}; var vs=function(a,b,c,d,e,f,h){as.call(this,a,b,c,d,ns,f,h);this.id=b.id||Mr();this.v_=e;d._close=this.close;this.onClosed=this.JJ;this.HM=0;qs(this,function(){this.Og("beforeparentopen");var b=_.Tr(this.methods);this.params._methods=_.Vr(b,"..",this.cC,this,!0);b={};b.queryParams=this.params;a=_.Bn(_.Qd,this.config.url,this.id,b);var c=e.openWindow(a);this.canAutoClose=function(a){a(e.KF(c))};e.nL(c,this);this.HM=c})};bs(vs); vs.prototype.close=function(a){a=this.Og("close",a);this.v_.XF(this.HM);return a};vs.prototype.JJ=function(){this.Og("close")}; (function(){_.O.Tj={};_.O.Rr={};_.O.wy={};_.O.tI=0;_.O.Lv={};_.O.tn={};_.O.Bv=null;_.O.Av=[];_.O.pX=function(a){var b=!1;try{if(null!=a){var c=window.parent.frames[a.id];b=c.iframer.id==a.id&&c.iframes.openedId_(_.op.id)}}catch(f){}try{_.O.Bv={origin:this.origin,referer:this.referer,claimedOpenerId:a&&a.id,claimedOpenerProxyChain:a&&a.proxyChain||[],sameOrigin:b};for(a=0;a<_.O.Av.length;++a)_.O.Av[a](_.O.Bv);_.O.Av=[]}catch(f){}};_.O.RS=function(a){var b=a&&a.Ki,c=null;b&&(c={},c.id=b.ka(),c.proxyChain= a.HB);return c};ks();if(window.parent!=window){var a=_.I.xc();a.gcv&&Qr(a.gcv);var b=a.jsh;b&&Rr(b);_.Tr(Xr(a,"..",""),_.op);_.Tr(a,_.op);ls()}_.O.Bb=cs;_.O.Xb=ds;_.O.pZ=gs;_.O.resize=fs;_.O.ZR=function(a){return _.O.wy[a]};_.O.NC=function(a,b){_.O.wy[a]=b};_.O.CK=fs;_.O.PZ=gs;_.O.ou={};_.O.ou.get=cs;_.O.ou.set=ds;_.O.EP=function(a,b){Ur(a);_.O.tn[a]=b||window[a]};_.O.s8=function(a){delete _.O.tn[a]};_.O.open=function(a,b,e,f,h,k){3==arguments.length?f={}:4==arguments.length&&"function"===typeof f&& (h=f,f={});var c="bubble"===b.style&&es?es.Na():null;return c?new vs(a,b,e,f,c,h,k):Yr(b)?new us(a,b,e,f,h,k):new ts(a,b,e,f,h,k)};_.O.close=function(a,b){_.op&&_.op._close&&_.op._close(a,b)};_.O.ready=function(a,b,e){2==arguments.length&&"function"===typeof b&&(e=b,b={});var c=a||{};"height"in c||(c.height=_.Jm.Xc());c._methods=_.Vr(b||{},"..","",_.op,!0);_.op&&_.op._ready&&_.op._ready(c,e)};_.O.qH=function(a){_.O.Bv?a(_.O.Bv):_.O.Av.push(a)};_.O.jX=function(a){return!!_.O.Tj[a]};_.O.kS=function(){return["https://ssl.gstatic.com/gb/js/", _.H("googleapis.config/gcv")].join("")};_.O.jK=function(a){var b={mouseover:1,mouseout:1};if(_.op._event)for(var c=0;c<a.length;c++){var f=a[c];f in b&&_.I.Hs(window.document,f,function(a){_.op._event({event:a.type,timestamp:(new Date).getTime()})},!0)}};_.O.zZ=Rr;_.O.KC=Sr;_.O.gJ=Or;_.O.vI=_.op})(); _.w("iframes.allow",_.O.EP);_.w("iframes.callSiblingOpener",_.O.cQ);_.w("iframes.registerForOpenedSibling",_.O.RX);_.w("iframes.close",_.O.close);_.w("iframes.getGoogleConnectJsUri",_.O.kS);_.w("iframes.getHandler",_.O.Bb);_.w("iframes.getDeferredHandler",_.O.ZR);_.w("iframes.getParentInfo",_.O.qH);_.w("iframes.iframer",_.O.vI);_.w("iframes.open",_.O.open);_.w("iframes.openedId_",_.O.jX);_.w("iframes.propagate",_.O.jK);_.w("iframes.ready",_.O.ready);_.w("iframes.resize",_.O.resize); _.w("iframes.setGoogleConnectJsVersion",_.O.pZ);_.w("iframes.setBootstrapHint",_.O.KC);_.w("iframes.setJsHint",_.O.zZ);_.w("iframes.setHandler",_.O.Xb);_.w("iframes.setDeferredHandler",_.O.NC);_.w("IframeBase",as);_.w("IframeBase.prototype.addCallback",as.prototype.Uc);_.w("IframeBase.prototype.getMethods",as.prototype.Xt);_.w("IframeBase.prototype.getOpenerIframe",as.prototype.Qc);_.w("IframeBase.prototype.getOpenParams",as.prototype.Ob);_.w("IframeBase.prototype.getParams",as.prototype.Nj); _.w("IframeBase.prototype.removeCallback",as.prototype.cm);_.w("Iframe",ts);_.w("Iframe.prototype.close",ts.prototype.close);_.w("Iframe.prototype.exposeMethod",ts.prototype.le);_.w("Iframe.prototype.getId",ts.prototype.ka);_.w("Iframe.prototype.getIframeEl",ts.prototype.Ha);_.w("Iframe.prototype.getSiteEl",ts.prototype.$a);_.w("Iframe.prototype.openInto",ts.prototype.Bf);_.w("Iframe.prototype.remove",ts.prototype.remove);_.w("Iframe.prototype.setSiteEl",ts.prototype.Ze); _.w("Iframe.prototype.addCallback",ts.prototype.Uc);_.w("Iframe.prototype.getMethods",ts.prototype.Xt);_.w("Iframe.prototype.getOpenerIframe",ts.prototype.Qc);_.w("Iframe.prototype.getOpenParams",ts.prototype.Ob);_.w("Iframe.prototype.getParams",ts.prototype.Nj);_.w("Iframe.prototype.removeCallback",ts.prototype.cm);_.w("IframeProxy",us);_.w("IframeProxy.prototype.getTargetIframeId",us.prototype.iT);_.w("IframeProxy.prototype.addCallback",us.prototype.Uc);_.w("IframeProxy.prototype.getMethods",us.prototype.Xt); _.w("IframeProxy.prototype.getOpenerIframe",us.prototype.Qc);_.w("IframeProxy.prototype.getOpenParams",us.prototype.Ob);_.w("IframeProxy.prototype.getParams",us.prototype.Nj);_.w("IframeProxy.prototype.removeCallback",us.prototype.cm);_.w("IframeWindow",vs);_.w("IframeWindow.prototype.close",vs.prototype.close);_.w("IframeWindow.prototype.onClosed",vs.prototype.JJ);_.w("iframes.util.getTopMostAccessibleWindow",_.O.Ia.DH);_.w("iframes.handlers.get",_.O.ou.get);_.w("iframes.handlers.set",_.O.ou.set); _.w("iframes.resizeMe",_.O.CK);_.w("iframes.setVersionOverride",_.O.PZ); as.prototype.send=function(a,b,c){_.O.QK(this,a,b,c)};_.op.send=function(a,b,c){_.O.QK(_.op,a,b,c)};as.prototype.register=function(a,b){var c=this;c.Uc(a,function(a){b.call(c,a)})};_.O.QK=function(a,b,c,d){var e=[];void 0!==c&&e.push(c);d&&e.push(function(a){d.call(this,[a])});a[b]&&a[b].apply(a,e)};_.O.Ho=function(){return!0};_.w("iframes.CROSS_ORIGIN_IFRAMES_FILTER",_.O.Ho);_.w("IframeBase.prototype.send",as.prototype.send);_.w("IframeBase.prototype.register",as.prototype.register); _.w("Iframe.prototype.send",ts.prototype.send);_.w("Iframe.prototype.register",ts.prototype.register);_.w("IframeProxy.prototype.send",us.prototype.send);_.w("IframeProxy.prototype.register",us.prototype.register);_.w("IframeWindow.prototype.send",vs.prototype.send);_.w("IframeWindow.prototype.register",vs.prototype.register);_.w("iframes.iframer.send",_.O.vI.send); var Iu=_.O.Xb,Ju={open:function(a){var b=_.ip(a.Ob());return a.Bf(b,{style:_.jp(b)})},attach:function(a,b){var c=_.ip(a.Ob()),d=b.id,e=b.getAttribute("data-postorigin")||b.src,f=/#(?:.*&)?rpctoken=(\d+)/.exec(e);f=f&&f[1];a.id=d;a.wr=f;a.el=c;a.Qg=b;_.O.Tj[d]=a;b=_.Tr(a.methods);b._ready=a.uv;b._close=a.close;b._open=a.vv;b._resizeMe=a.Yn;b._renderstart=a.PJ;_.Vr(b,d,"",a,!0);_.K.ew(a.id,a.wr);_.K.Ph(a.id,e);c=_.O.hn({style:_.jp(c)});for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&("style"== h?a.Qg.style.cssText=c[h]:a.Qg.setAttribute(h,c[h]))}};Ju.onready=_.kp;Ju.onRenderStart=_.kp;Ju.close=_.lp;Iu("inline",Ju); _.Wj=(window.gapi||{}).load; _.np=_.D(); _.pp=function(a){var b=window;a=(a||b.location.href).match(/.*(\?|#|&)usegapi=([^&#]+)/)||[];return"1"===(0,window.decodeURIComponent)(a[a.length-1]||"")}; var qp,rp,sp,tp,up,vp,zp,Ap;qp=function(a){if(_.Sd.test(Object.keys))return Object.keys(a);var b=[],c;for(c in a)_.Ud(a,c)&&b.push(c);return b};rp=function(a,b){if(!_.gf())try{a()}catch(c){}_.hf(b)};sp={button:!0,div:!0,span:!0};tp=function(a){var b=_.Td(_.ce,"sws",[]);return 0<=_.Xm.call(b,a)};up=function(a){return _.Td(_.ce,"watt",_.D())[a]};vp=function(a){return function(b,c){return a?_.Gn()[c]||a[c]||"":_.Gn()[c]||""}}; _.wp={apppackagename:1,callback:1,clientid:1,cookiepolicy:1,openidrealm:-1,includegrantedscopes:-1,requestvisibleactions:1,scope:1};_.xp=!1; _.yp=function(){if(!_.xp){for(var a=window.document.getElementsByTagName("meta"),b=0;b<a.length;++b){var c=a[b].name.toLowerCase();if(_.vc(c,"google-signin-")){c=c.substring(14);var d=a[b].content;_.wp[c]&&d&&(_.np[c]=d)}}if(window.self!==window.top){a=window.document.location.toString();for(var e in _.wp)0<_.wp[e]&&(b=_.Xd(a,e,""))&&(_.np[e]=b)}_.xp=!0}e=_.D();_.Vd(_.np,e);return e}; zp=function(a){var b;a.match(/^https?%3A/i)&&(b=(0,window.decodeURIComponent)(a));return _.mn(window.document,b?b:a)};Ap=function(a){a=a||"canonical";for(var b=window.document.getElementsByTagName("link"),c=0,d=b.length;c<d;c++){var e=b[c],f=e.getAttribute("rel");if(f&&f.toLowerCase()==a&&(e=e.getAttribute("href"))&&(e=zp(e))&&null!=e.match(/^https?:\/\/[\w\-_\.]+/i))return e}return window.location.href};_.Bp=function(){return window.location.origin||window.location.protocol+"//"+window.location.host}; _.Cp=function(a,b,c,d){return(a="string"==typeof a?a:void 0)?zp(a):Ap(d)};_.Dp=function(a,b,c){null==a&&c&&(a=c.db,null==a&&(a=c.gwidget&&c.gwidget.db));return a||void 0};_.Ep=function(a,b,c){null==a&&c&&(a=c.ecp,null==a&&(a=c.gwidget&&c.gwidget.ecp));return a||void 0}; _.Fp=function(a,b,c){return _.Cp(a,b,c,b.action?void 0:"publisher")};var Gp,Hp,Ip,Jp,Kp,Lp,Np,Mp;Gp={se:"0"};Hp={post:!0};Ip={style:"position:absolute;top:-10000px;width:450px;margin:0px;border-style:none"};Jp="onPlusOne _ready _close _open _resizeMe _renderstart oncircled drefresh erefresh".split(" ");Kp=_.Td(_.ce,"WI",_.D());Lp=["style","data-gapiscan"]; Np=function(a){for(var b=_.D(),c=0!=a.nodeName.toLowerCase().indexOf("g:"),d=0,e=a.attributes.length;d<e;d++){var f=a.attributes[d],h=f.name,k=f.value;0<=_.Xm.call(Lp,h)||c&&0!=h.indexOf("data-")||"null"===k||"specified"in f&&!f.specified||(c&&(h=h.substr(5)),b[h.toLowerCase()]=k)}a=a.style;(c=Mp(a&&a.height))&&(b.height=String(c));(a=Mp(a&&a.width))&&(b.width=String(a));return b}; _.Pp=function(a,b,c,d,e,f){if(c.rd)var h=b;else h=window.document.createElement("div"),b.setAttribute("data-gapistub",!0),h.style.cssText="position:absolute;width:450px;left:-10000px;",b.parentNode.insertBefore(h,b);f.siteElement=h;h.id||(h.id=_.Op(a));b=_.D();b[">type"]=a;_.Vd(c,b);a=_.Kn(d,h,e);f.iframeNode=a;f.id=a.getAttribute("id")};_.Op=function(a){_.Td(Kp,a,0);return"___"+a+"_"+Kp[a]++};Mp=function(a){var b=void 0;"number"===typeof a?b=a:"string"===typeof a&&(b=(0,window.parseInt)(a,10));return b}; var Qp=function(){},Tp=function(a){var b=a.Wm,c=function(a){c.H.constructor.call(this,a);var b=this.mh.length;this.Hg=[];for(var d=0;d<b;++d)this.mh[d].p8||(this.Hg[d]=new this.mh[d](a))};_.z(c,b);for(var d=[];a;){if(b=a.Wm){b.mh&&_.pe(d,b.mh);var e=b.prototype,f;for(f in e)if(e.hasOwnProperty(f)&&_.Xa(e[f])&&e[f]!==b){var h=!!e[f].c8,k=Rp(f,e,d,h);(h=Sp(f,e,k,h))&&(c.prototype[f]=h)}}a=a.H&&a.H.constructor}c.prototype.mh=d;return c},Rp=function(a,b,c,d){for(var e=[],f=0;f<c.length&&(c[f].prototype[a]=== b[a]||(e.push(f),!d));++f);return e},Sp=function(a,b,c,d){return c.length?d?function(b){var d=this.Hg[c[0]];return d?d[a].apply(this.Hg[c[0]],arguments):this.mh[c[0]].prototype[a].apply(this,arguments)}:b[a].eQ?function(b){a:{var d=Array.prototype.slice.call(arguments,0);for(var e=0;e<c.length;++e){var k=this.Hg[c[e]];if(k=k?k[a].apply(k,d):this.mh[c[e]].prototype[a].apply(this,d)){d=k;break a}}d=!1}return d}:b[a].dQ?function(b){a:{var d=Array.prototype.slice.call(arguments,0);for(var e=0;e<c.length;++e){var k= this.Hg[c[e]];k=k?k[a].apply(k,d):this.mh[c[e]].prototype[a].apply(this,d);if(null!=k){d=k;break a}}d=void 0}return d}:b[a].AJ?function(b){for(var d=Array.prototype.slice.call(arguments,0),e=0;e<c.length;++e){var k=this.Hg[c[e]];k?k[a].apply(k,d):this.mh[c[e]].prototype[a].apply(this,d)}}:function(b){for(var d=Array.prototype.slice.call(arguments,0),e=[],k=0;k<c.length;++k){var l=this.Hg[c[k]];e.push(l?l[a].apply(l,d):this.mh[c[k]].prototype[a].apply(this,d))}return e}:d||b[a].eQ||b[a].dQ||b[a].AJ? null:Up},Up=function(){return[]};Qp.prototype.jz=function(a){if(this.Hg)for(var b=0;b<this.Hg.length;++b)if(this.Hg[b]instanceof a)return this.Hg[b];return null}; var Vp=function(a){return this.Ya.jz(a)};var Wp,Xp,Yp,Zp,$p=/(?:^|\s)g-((\S)*)(?:$|\s)/,aq={plusone:!0,autocomplete:!0,profile:!0,signin:!0,signin2:!0};Wp=_.Td(_.ce,"SW",_.D());Xp=_.Td(_.ce,"SA",_.D());Yp=_.Td(_.ce,"SM",_.D());Zp=_.Td(_.ce,"FW",[]); var eq=function(a,b){var c;bq.ps0=(new Date).getTime();cq("ps0");a=("string"===typeof a?window.document.getElementById(a):a)||_.Qd;var d=_.Qd.documentMode;if(a.querySelectorAll&&(!d||8<d)){d=b?[b]:qp(Wp).concat(qp(Xp)).concat(qp(Yp));for(var e=[],f=0;f<d.length;f++){var h=d[f];e.push(".g-"+h,"g\\:"+h)}d=a.querySelectorAll(e.join(","))}else d=a.getElementsByTagName("*");a=_.D();for(e=0;e<d.length;e++){f=d[e];var k=f;h=b;var l=k.nodeName.toLowerCase(),n=void 0;if(k.getAttribute("data-gapiscan"))h=null; else{var p=l.indexOf("g:");0==p?n=l.substr(2):(p=(p=String(k.className||k.getAttribute("class")))&&$p.exec(p))&&(n=p[1]);h=!n||!(Wp[n]||Xp[n]||Yp[n])||h&&n!==h?null:n}h&&(aq[h]||0==f.nodeName.toLowerCase().indexOf("g:")||0!=qp(Np(f)).length)&&(f.setAttribute("data-gapiscan",!0),_.Td(a,h,[]).push(f))}for(q in a)Zp.push(q);bq.ps1=(new Date).getTime();cq("ps1");if(b=Zp.join(":"))try{_.Wd.load(b,void 0)}catch(t){_.ue(t);return}e=[];for(c in a){d=a[c];var q=0;for(b=d.length;q<b;q++)f=d[q],dq(c,f,Np(f), e,b)}}; var fq=function(a,b){var c=up(a);b&&c?(c(b),(c=b.iframeNode)&&c.setAttribute("data-gapiattached",!0)):_.Wd.load(a,function(){var c=up(a),e=b&&b.iframeNode,f=b&&b.userParams;e&&c?(c(b),e.setAttribute("data-gapiattached",!0)):(c=_.Wd[a].go,"signin2"==a?c(e,f):c(e&&e.parentNode,f))})},dq=function(a,b,c,d,e,f,h){switch(gq(b,a,f)){case 0:a=Yp[a]?a+"_annotation":a;d={};d.iframeNode=b;d.userParams=c;fq(a,d);break;case 1:if(b.parentNode){for(var k in c){if(f=_.Ud(c,k))f=c[k],f=!!f&&"object"===typeof f&&(!f.toString|| f.toString===Object.prototype.toString||f.toString===Array.prototype.toString);if(f)try{c[k]=_.df(c[k])}catch(F){delete c[k]}}k=!0;c.dontclear&&(k=!1);delete c.dontclear;var l;f={};var n=l=a;"plus"==a&&c.action&&(l=a+"_"+c.action,n=a+"/"+c.action);(l=_.H("iframes/"+l+"/url"))||(l=":im_socialhost:/:session_prefix::im_prefix:_/widget/render/"+n+"?usegapi=1");for(p in Gp)f[p]=p+"/"+(c[p]||Gp[p])+"/";var p=_.mn(_.Qd,l.replace(_.Fn,vp(f)));n="iframes/"+a+"/params/";f={};_.Vd(c,f);(l=_.H("lang")||_.H("gwidget/lang"))&& (f.hl=l);Hp[a]||(f.origin=_.Bp());f.exp=_.H(n+"exp");if(n=_.H(n+"location"))for(l=0;l<n.length;l++){var q=n[l];f[q]=_.Nd.location[q]}switch(a){case "plus":case "follow":f.url=_.Fp(f.href,c,null);delete f.href;break;case "plusone":n=(n=c.href)?zp(n):Ap();f.url=n;f.db=_.Dp(c.db,void 0,_.H());f.ecp=_.Ep(c.ecp,void 0,_.H());delete f.href;break;case "signin":f.url=Ap()}_.ce.ILI&&(f.iloader="1");delete f["data-onload"];delete f.rd;for(var t in Gp)f[t]&&delete f[t];f.gsrc=_.H("iframes/:source:");t=_.H("inline/css"); "undefined"!==typeof t&&0<e&&t>=e&&(f.ic="1");t=/^#|^fr-/;e={};for(var x in f)_.Ud(f,x)&&t.test(x)&&(e[x.replace(t,"")]=f[x],delete f[x]);x="q"==_.H("iframes/"+a+"/params/si")?f:e;t=_.yp();for(var v in t)!_.Ud(t,v)||_.Ud(f,v)||_.Ud(e,v)||(x[v]=t[v]);v=[].concat(Jp);x=_.H("iframes/"+a+"/methods");_.Wm(x)&&(v=v.concat(x));for(y in c)_.Ud(c,y)&&/^on/.test(y)&&("plus"!=a||"onconnect"!=y)&&(v.push(y),delete f[y]);delete f.callback;e._methods=v.join(",");var y=_.ln(p,f,e);v=h||{};v.allowPost=1;v.attributes= Ip;v.dontclear=!k;h={};h.userParams=c;h.url=y;h.type=a;_.Pp(a,b,c,y,v,h);b=h.id;c=_.D();c.id=b;c.userParams=h.userParams;c.url=h.url;c.type=h.type;c.state=1;_.fp[b]=c;b=h}else b=null;b&&((c=b.id)&&d.push(c),fq(a,b))}},gq=function(a,b,c){if(a&&1===a.nodeType&&b){if(c)return 1;if(Yp[b]){if(sp[a.nodeName.toLowerCase()])return(a=a.innerHTML)&&a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")?0:1}else{if(Xp[b])return 0;if(Wp[b])return 1}}return null}; _.Td(_.Wd,"platform",{}).go=function(a,b){eq(a,b)};var hq=_.Td(_.ce,"perf",_.D()),bq=_.Td(hq,"g",_.D()),iq=_.Td(hq,"i",_.D()),jq,kq,lq,cq,nq,oq,pq;_.Td(hq,"r",[]);jq=_.D();kq=_.D();lq=function(a,b,c,d){jq[c]=jq[c]||!!d;_.Td(kq,c,[]);kq[c].push([a,b])};cq=function(a,b,c){var d=hq.r;"function"===typeof d?d(a,b,c):d.push([a,b,c])};nq=function(a,b,c,d){if("_p"==b)throw Error("S");_.mq(a,b,c,d)};_.mq=function(a,b,c,d){oq(b,c)[a]=d||(new Date).getTime();cq(a,b,c)};oq=function(a,b){a=_.Td(iq,a,_.D());return _.Td(a,b,_.D())}; pq=function(a,b,c){var d=null;b&&c&&(d=oq(b,c)[a]);return d||bq[a]}; (function(){function a(a){this.t={};this.tick=function(a,b,c){this.t[a]=[void 0!=c?c:(new Date).getTime(),b];if(void 0==c)try{window.console.timeStamp("CSI/"+a)}catch(p){}};this.tick("start",null,a)}var b;if(window.performance)var c=(b=window.performance.timing)&&b.responseStart;var d=0<c?new a(c):new a;window.__gapi_jstiming__={Timer:a,load:d};if(b){var e=b.navigationStart;0<e&&c>=e&&(window.__gapi_jstiming__.srt=c-e)}if(b){var f=window.__gapi_jstiming__.load;0<e&&c>=e&&(f.tick("_wtsrt",void 0,e), f.tick("wtsrt_","_wtsrt",c),f.tick("tbsd_","wtsrt_"))}try{b=null,window.chrome&&window.chrome.csi&&(b=Math.floor(window.chrome.csi().pageT),f&&0<e&&(f.tick("_tbnd",void 0,window.chrome.csi().startE),f.tick("tbnd_","_tbnd",e))),null==b&&window.gtbExternal&&(b=window.gtbExternal.pageT()),null==b&&window.external&&(b=window.external.pageT,f&&0<e&&(f.tick("_tbnd",void 0,window.external.startE),f.tick("tbnd_","_tbnd",e))),b&&(window.__gapi_jstiming__.pt=b)}catch(h){}})(); if(window.__gapi_jstiming__){window.__gapi_jstiming__.AF={};window.__gapi_jstiming__.eY=1;var sq=function(a,b,c){var d=a.t[b],e=a.t.start;if(d&&(e||c))return d=a.t[b][0],e=void 0!=c?c:e[0],Math.round(d-e)};window.__gapi_jstiming__.getTick=sq;window.__gapi_jstiming__.getLabels=function(a){var b=[],c;for(c in a.t)b.push(c);return b};var tq=function(a,b,c){var d="";window.__gapi_jstiming__.srt&&(d+="&srt="+window.__gapi_jstiming__.srt);window.__gapi_jstiming__.pt&&(d+="&tbsrt="+window.__gapi_jstiming__.pt); try{window.external&&window.external.tran?d+="&tran="+window.external.tran:window.gtbExternal&&window.gtbExternal.tran?d+="&tran="+window.gtbExternal.tran():window.chrome&&window.chrome.csi&&(d+="&tran="+window.chrome.csi().tran)}catch(q){}var e=window.chrome;if(e&&(e=e.loadTimes)){e().wasFetchedViaSpdy&&(d+="&p=s");if(e().wasNpnNegotiated){d+="&npn=1";var f=e().npnNegotiatedProtocol;f&&(d+="&npnv="+(window.encodeURIComponent||window.escape)(f))}e().wasAlternateProtocolAvailable&&(d+="&apa=1")}var h= a.t,k=h.start;e=[];f=[];for(var l in h)if("start"!=l&&0!=l.indexOf("_")){var n=h[l][1];n?h[n]&&f.push(l+"."+sq(a,l,h[n][0])):k&&e.push(l+"."+sq(a,l))}if(b)for(var p in b)d+="&"+p+"="+b[p];(b=c)||(b="https:"==window.document.location.protocol?"https://csi.gstatic.com/csi":"http://csi.gstatic.com/csi");return[b,"?v=3","&s="+(window.__gapi_jstiming__.sn||"")+"&action=",a.name,f.length?"&it="+f.join(","):"",d,"&rt=",e.join(",")].join("")},uq=function(a,b,c){a=tq(a,b,c);if(!a)return"";b=new window.Image; var d=window.__gapi_jstiming__.eY++;window.__gapi_jstiming__.AF[d]=b;b.onload=b.onerror=function(){window.__gapi_jstiming__&&delete window.__gapi_jstiming__.AF[d]};b.src=a;b=null;return a};window.__gapi_jstiming__.report=function(a,b,c){var d=window.document.visibilityState,e="visibilitychange";d||(d=window.document.webkitVisibilityState,e="webkitvisibilitychange");if("prerender"==d){var f=!1,h=function(){if(!f){b?b.prerender="1":b={prerender:"1"};if("prerender"==(window.document.visibilityState|| window.document.webkitVisibilityState))var d=!1;else uq(a,b,c),d=!0;d&&(f=!0,window.document.removeEventListener(e,h,!1))}};window.document.addEventListener(e,h,!1);return""}return uq(a,b,c)}}; var vq={g:"gapi_global",m:"gapi_module",w:"gwidget"},wq=function(a,b){this.type=a?"_p"==a?"m":"w":"g";this.name=a;this.wo=b};wq.prototype.key=function(){switch(this.type){case "g":return this.type;case "m":return this.type+"."+this.wo;case "w":return this.type+"."+this.name+this.wo}}; var xq=new wq,yq=window.navigator.userAgent.match(/iPhone|iPad|Android|PalmWebOS|Maemo|Bada/),zq=_.Td(hq,"_c",_.D()),Aq=Math.random()<(_.H("csi/rate")||0),Cq=function(a,b,c){for(var d=new wq(b,c),e=_.Td(zq,d.key(),_.D()),f=kq[a]||[],h=0;h<f.length;++h){var k=f[h],l=k[0],n=a,p=b,q=c;k=pq(k[1],p,q);n=pq(n,p,q);e[l]=k&&n?n-k:null}jq[a]&&Aq&&(Bq(xq),Bq(d))},Dq=function(a,b){b=b||[];for(var c=[],d=0;d<b.length;d++)c.push(a+b[d]);return c},Bq=function(a){var b=_.Nd.__gapi_jstiming__;b.sn=vq[a.type];var c= new b.Timer(0);a:{switch(a.type){case "g":var d="global";break a;case "m":d=a.wo;break a;case "w":d=a.name;break a}d=void 0}c.name=d;d=!1;var e=a.key(),f=zq[e];c.tick("_start",null,0);for(var h in f)c.tick(h,"_start",f[h]),d=!0;zq[e]=_.D();d&&(h=[],h.push("l"+(_.H("isPlusUser")?"1":"0")),d="m"+(yq?"1":"0"),h.push(d),"m"==a.type?h.push("p"+a.wo):"w"==a.type&&(e="n"+a.wo,h.push(e),"0"==a.wo&&h.push(d+e)),h.push("u"+(_.H("isLoggedIn")?"1":"0")),a=Dq("",h),a=Dq("abc_",a).join(","),b.report(c,{e:a}))}; lq("blt","bs0","bs1");lq("psi","ps0","ps1");lq("rpcqi","rqe","rqd");lq("bsprt","bsrt0","bsrt1");lq("bsrqt","bsrt1","bsrt2");lq("bsrst","bsrt2","bsrt3");lq("mli","ml0","ml1");lq("mei","me0","me1",!0);lq("wcdi","wrs","wcdi");lq("wci","wrs","wdc");lq("wdi","wrs","wrdi");lq("wdt","bs0","wrdt");lq("wri","wrs","wrri",!0);lq("wrt","bs0","wrrt");lq("wji","wje0","wje1",!0);lq("wjli","wjl0","wjl1");lq("whi","wh0","wh1",!0);lq("wai","waaf0","waaf1",!0);lq("wadi","wrs","waaf1",!0);lq("wadt","bs0","waaf1",!0); lq("wprt","wrt0","wrt1");lq("wrqt","wrt1","wrt2");lq("wrst","wrt2","wrt3",!0);lq("fbprt","fsrt0","fsrt1");lq("fbrqt","fsrt1","fsrt2");lq("fbrst","fsrt2","fsrt3",!0);lq("fdns","fdns0","fdns1");lq("fcon","fcon0","fcon1");lq("freq","freq0","freq1");lq("frsp","frsp0","frsp1");lq("fttfb","fttfb0","fttfb1");lq("ftot","ftot0","ftot1",!0);var Eq=hq.r;if("function"!==typeof Eq){for(var Fq;Fq=Eq.shift();)Cq.apply(null,Fq);hq.r=Cq}; var Gq=["div"],Hq="onload",Iq=!0,Jq=!0,Kq=function(a){return a},Lq=null,Mq=function(a){var b=_.H(a);return"undefined"!==typeof b?b:_.H("gwidget/"+a)},hr,ir,jr,kr,ar,cr,lr,br,mr,nr,or,pr;Lq=_.H();_.H("gwidget");var Nq=Mq("parsetags");Hq="explicit"===Nq||"onload"===Nq?Nq:Hq;var Oq=Mq("google_analytics");"undefined"!==typeof Oq&&(Iq=!!Oq);var Pq=Mq("data_layer");"undefined"!==typeof Pq&&(Jq=!!Pq); var Qq=function(){var a=this&&this.ka();a&&(_.ce.drw=a)},Rq=function(){_.ce.drw=null},Sq=function(a){return function(b){var c=a;"number"===typeof b?c=b:"string"===typeof b&&(c=b.indexOf("px"),-1!=c&&(b=b.substring(0,c)),c=(0,window.parseInt)(b,10));return c}},Tq=function(a){"string"===typeof a&&(a=window[a]);return"function"===typeof a?a:null},Uq=function(){return Mq("lang")||"en-US"},Vq=function(a){if(!_.O.Bb("attach")){var b={},c=_.O.Bb("inline"),d;for(d in c)c.hasOwnProperty(d)&&(b[d]=c[d]);b.open= function(a){var b=a.Ob().renderData.id;b=window.document.getElementById(b);if(!b)throw Error("T");return c.attach(a,b)};_.O.Xb("attach",b)}a.style="attach"},Wq=function(){var a={};a.width=[Sq(450)];a.height=[Sq(24)];a.onready=[Tq];a.lang=[Uq,"hl"];a.iloader=[function(){return _.ce.ILI},"iloader"];return a}(),Zq=function(a){var b={};b.De=a[0];b.Bo=-1;b.D$="___"+b.De+"_";b.W_="g:"+b.De;b.o9="g-"+b.De;b.wK=[];b.config={};b.Vs=[];b.uM={};b.Ew={};var c=function(a){for(var c in a)if(_.Ud(a,c)){b.config[c]= [Tq];b.Vs.push(c);var d=a[c],e=null,l=null,n=null;"function"===typeof d?e=d:d&&"object"===typeof d&&(e=d.Y8,l=d.Xr,n=d.Mw);n&&(b.Vs.push(n),b.config[n]=[Tq],b.uM[c]=n);e&&(b.config[c]=[e]);l&&(b.Ew[c]=l)}},d=function(a){for(var c={},d=0;d<a.length;++d)c[a[d].toLowerCase()]=1;c[b.W_]=1;b.lW=c};a[1]&&(b.parameters=a[1]);(function(a){b.config=a;for(var c in Wq)Wq.hasOwnProperty(c)&&!b.config.hasOwnProperty(c)&&(b.config[c]=Wq[c])})(a[2]||{});a[3]&&c(a[3]);a[4]&&d(a[4]);a[5]&&(b.jk=a[5]);b.u$=!0===a[6]; b.EX=a[7];b.H_=a[8];b.lW||d(Gq);b.CB=function(a){b.Bo++;nq("wrs",b.De,String(b.Bo));var c=[],d=a.element,e=a.config,l=":"+b.De;":plus"==l&&a.hk&&a.hk.action&&(l+="_"+a.hk.action);var n=Xq(b,e),p={};_.Vd(_.yp(),p);for(var q in a.hk)null!=a.hk[q]&&(p[q]=a.hk[q]);q={container:d.id,renderData:a.$X,style:"inline",height:e.height,width:e.width};Vq(q);b.jk&&(c[2]=q,c[3]=p,c[4]=n,b.jk("i",c));l=_.O.open(l,q,p,n);Yq(b,l,e,d,a.GQ);c[5]=l;b.jk&&b.jk("e",c)};return b},Xq=function(a,b){for(var c={},d=a.Vs.length- 1;0<=d;--d){var e=a.Vs[d],f=b[a.uM[e]||e]||b[e],h=b[e];h&&f!==h&&(f=function(a,b){return function(c){b.apply(this,arguments);a.apply(this,arguments)}}(f,h));f&&(c[e]=f)}for(var k in a.Ew)a.Ew.hasOwnProperty(k)&&(c[k]=$q(c[k]||function(){},a.Ew[k]));c.drefresh=Qq;c.erefresh=Rq;return c},$q=function(a,b){return function(c){var d=b(c);if(d){var e=c.href||null;if(Iq){if(window._gat)try{var f=window._gat._getTrackerByName("~0");f&&"UA-XXXXX-X"!=f._getAccount()?f._trackSocial("Google",d,e):window._gaq&& window._gaq.push(["_trackSocial","Google",d,e])}catch(k){}if(window.ga&&window.ga.getAll)try{var h=window.ga.getAll();for(f=0;f<h.length;f++)h[f].send("social","Google",d,e)}catch(k){}}if(Jq&&window.dataLayer)try{window.dataLayer.push({event:"social",socialNetwork:"Google",socialAction:d,socialTarget:e})}catch(k){}}a.call(this,c)}},Yq=function(a,b,c,d,e){ar(b,c);br(b,d);cr(a,b,e);dr(a.De,a.Bo.toString(),b);(new er).Ya.Jk(a,b,c,d,e)},er=function(){if(!this.Ya){for(var a=this.constructor;a&&!a.Wm;)a= a.H&&a.H.constructor;a.Wm.lG||(a.Wm.lG=Tp(a));this.Ya=new a.Wm.lG(this);this.jz||(this.jz=Vp)}},fr=function(){},gr=er;fr.H||_.z(fr,Qp);gr.Wm=fr;fr.prototype.Jk=function(a){a=a?a:function(){};a.AJ=!0;return a}();hr=function(a){return _.zo&&"undefined"!=typeof _.zo&&a instanceof _.zo};ir=function(a){return hr(a)?"_renderstart":"renderstart"};jr=function(a){return hr(a)?"_ready":"ready"};kr=function(){return!0}; ar=function(a,b){if(b.onready){var c=!1,d=function(){c||(c=!0,b.onready.call(null))};a.register(jr(a),d,kr);a.register(ir(a),d,kr)}}; cr=function(a,b,c){var d=a.De,e=String(a.Bo),f=!1,h=function(){f||(f=!0,c&&nq("wrdt",d,e),nq("wrdi",d,e))};b.register(ir(b),h,kr);var k=!1;a=function(){k||(k=!0,h(),c&&nq("wrrt",d,e),nq("wrri",d,e))};b.register(jr(b),a,kr);hr(b)?b.register("widget-interactive-"+b.id,a,kr):_.K.register("widget-interactive-"+b.id,a);_.K.register("widget-csi-tick-"+b.id,function(a,b,c){"wdc"===a?nq("wdc",d,e,c):"wje0"===a?nq("wje0",d,e,c):"wje1"===a?nq("wje1",d,e,c):"wh0"==a?_.mq("wh0",d,e,c):"wh1"==a?_.mq("wh1",d,e, c):"wcdi"==a&&_.mq("wcdi",d,e,c)})};lr=function(a){return"number"==typeof a?a+"px":"100%"==a?a:null};br=function(a,b){var c=function(c){c=c||a;var d=lr(c.width);d&&b.style.width!=d&&(b.style.width=d);(c=lr(c.height))&&b.style.height!=c&&(b.style.height=c)};hr(a)?a.pL("onRestyle",c):(a.register("ready",c,kr),a.register("renderstart",c,kr),a.register("resize",c,kr))};mr=function(a,b){for(var c in Wq)if(Wq.hasOwnProperty(c)){var d=Wq[c][1];d&&!b.hasOwnProperty(d)&&(b[d]=a[d])}return b}; nr=function(a,b){var c={},d;for(d in a)a.hasOwnProperty(d)&&(c[a[d][1]||d]=(a[d]&&a[d][0]||Kq)(b[d.toLowerCase()],b,Lq));return c};or=function(a){if(a=a.EX)for(var b=0;b<a.length;b++)(new window.Image).src=a[b]};pr=function(a,b){var c=b.userParams,d=b.siteElement;d||(d=(d=b.iframeNode)&&d.parentNode);if(d&&1===d.nodeType){var e=nr(a.config,c);a.wK.push({element:d,config:e,hk:mr(e,nr(a.parameters,c)),X9:3,GQ:!!c["data-onload"],$X:b})}b=a.wK;for(a=a.CB;0<b.length;)a(b.shift())}; _.qr=function(a){var b=Zq(a);or(b);_.pn(b.De,function(a){pr(b,a)});Wp[b.De]=!0;var c={va:function(a,c,f){var d=c||{};d.type=b.De;c=d.type;delete d.type;var e=("string"===typeof a?window.document.getElementById(a):a)||void 0;if(e){a={};for(var l in d)_.Ud(d,l)&&(a[l.toLowerCase()]=d[l]);a.rd=1;(l=!!a.ri)&&delete a.ri;dq(c,e,a,[],0,l,f)}else _.ue("string"==="gapi."+c+".render: missing element "+typeof a?a:"")},go:function(a){eq(a,b.De)},Y9:function(){var a=_.Td(_.ce,"WI",_.D()),b;for(b in a)delete a[b]}}; a=function(){"onload"===Hq&&c.go()};tp(b.De)||rp(a,a);_.w("gapi."+b.De+".go",c.go);_.w("gapi."+b.De+".render",c.va);return c}; var rr=pr,sr=function(a,b){a.Bo++;nq("wrs",a.De,String(a.Bo));var c=b.userParams,d=nr(a.config,c),e=[],f=b.iframeNode,h=b.siteElement,k=Xq(a,d),l=nr(a.parameters,c);_.Vd(_.yp(),l);l=mr(d,l);c=!!c["data-onload"];var n=_.ao,p=_.D();p.renderData=b;p.height=d.height;p.width=d.width;p.id=b.id;p.url=b.url;p.iframeEl=f;p.where=p.container=h;p.apis=["_open"];p.messageHandlers=k;p.messageHandlersFilter=_.M;_.mp(p);f=l;a.jk&&(e[2]=p,e[3]=f,e[4]=k,a.jk("i",e));k=n.uj(p);k.id=b.id;k.aD(k,p);Yq(a,k,d,h,c);e[5]= k;a.jk&&a.jk("e",e)};pr=function(a,b){var c=b.url;a.H_||_.pp(c)?_.wo?sr(a,b):(0,_.Wj)("gapi.iframes.impl",function(){sr(a,b)}):_.O.open?rr(a,b):(0,_.Wj)("iframes",function(){rr(a,b)})}; var tr=function(){var a=window;return!!a.performance&&!!a.performance.getEntries},dr=function(a,b,c){if(tr()){var d=function(){var a=!1;return function(){if(a)return!0;a=!0;return!1}}(),e=function(){d()||window.setTimeout(function(){var d=c.Ha().src;var e=d.indexOf("#");-1!=e&&(d=d.substring(0,e));d=window.performance.getEntriesByName(d);1>d.length?d=null:(d=d[0],d=0==d.responseStart?null:d);if(d){e=Math.round(d.requestStart);var k=Math.round(d.responseStart),l=Math.round(d.responseEnd);nq("wrt0", a,b,Math.round(d.startTime));nq("wrt1",a,b,e);nq("wrt2",a,b,k);nq("wrt3",a,b,l)}},1E3)};c.register(ir(c),e,kr);c.register(jr(c),e,kr)}}; _.w("gapi.widget.make",_.qr); var ur,vr,wr,yr;ur=["left","right"];vr="inline bubble none only pp vertical-bubble".split(" ");wr=function(a,b){if("string"==typeof a){a=a.toLowerCase();var c;for(c=0;c<b.length;c++)if(b[c]==a)return a}};_.xr=function(a){return wr(a,vr)};yr=function(a){return wr(a,ur)};_.zr=function(a){a.source=[null,"source"];a.expandTo=[null,"expandTo"];a.align=[yr];a.annotation=[_.xr];a.origin=[_.Bp]}; _.O.NC("bubble",function(a){(0,_.Wj)("iframes-styles-bubble",a)}); _.O.NC("slide-menu",function(a){(0,_.Wj)("iframes-styles-slide-menu",a)}); _.w("gapi.plusone.render",_.TV);_.w("gapi.plusone.go",_.UV); var VV={tall:{"true":{width:50,height:60},"false":{width:50,height:24}},small:{"false":{width:24,height:15},"true":{width:70,height:15}},medium:{"false":{width:32,height:20},"true":{width:90,height:20}},standard:{"false":{width:38,height:24},"true":{width:106,height:24}}},WV={width:180,height:35},XV=function(a){return"string"==typeof a?""!=a&&"0"!=a&&"false"!=a.toLowerCase():!!a},YV=function(a){var b=(0,window.parseInt)(a,10);if(b==a)return String(b)},ZV=function(a){if(XV(a))return"true"},$V=function(a){return"string"== typeof a&&VV[a.toLowerCase()]?a.toLowerCase():"standard"},aW=function(a,b){return"tall"==$V(b)?"true":null==a||XV(a)?"true":"false"},bW=function(a,b){return VV[$V(a)][aW(b,a)]},cW=function(a,b,c){a=_.xr(a);b=$V(b);if(""!=a){if("inline"==a||"only"==a)return a=450,c.width&&(a=120<c.width?c.width:120),{width:a,height:VV[b]["false"].height};if("bubble"!=a){if("none"==a)return VV[b]["false"];if("pp"==a)return WV}}return VV[b]["true"]},dW={href:[_.Cp,"url"],width:[YV],size:[$V],resize:[ZV],autosize:[ZV], count:[function(a,b){return aW(b.count,b.size)}],db:[_.Dp],ecp:[_.Ep],textcolor:[function(a){if("string"==typeof a&&a.match(/^[0-9A-F]{6}$/i))return a}],drm:[ZV],recommendations:[],fu:[],ad:[ZV],cr:[YV],ag:[YV],"fr-ai":[],"fr-sigh":[]}; (function(){var a={0:"plusone"},b=_.H("iframes/plusone/preloadUrl");b&&(a[7]=b);_.zr(dW);a[1]=dW;a[2]={width:[function(a,b){return b.annotation?cW(b.annotation,b.size,b).width:bW(b.size,b.count).width}],height:[function(a,b){return b.annotation?cW(b.annotation,b.size,b).height:bW(b.size,b.count).height}]};a[3]={onPlusOne:{Xr:function(a){return"on"==a.state?"+1":null},Mw:"callback"},onstartinteraction:!0,onendinteraction:!0,onpopup:!0};a[4]=["div","button"];a=_.qr(a);_.UV=a.go;_.TV=a.va})(); }); // Google Inc.
SOYJUN / FTP Implement Based On UDPThe aim of this assignment is to have you do UDP socket client / server programming with a focus on two broad aspects : Setting up the exchange between the client and server in a secure way despite the lack of a formal connection (as in TCP) between the two, so that ‘outsider’ UDP datagrams (broadcast, multicast, unicast - fortuitously or maliciously) cannot intrude on the communication. Introducing application-layer protocol data-transmission reliability, flow control and congestion control in the client and server using TCP-like ARQ sliding window mechanisms. The second item above is much more of a challenge to implement than the first, though neither is particularly trivial. But they are not tightly interdependent; each can be worked on separately at first and then integrated together at a later stage. Apart from the material in Chapters 8, 14 & 22 (especially Sections 22.5 - 22.7), and the experience you gained from the preceding assignment, you will also need to refer to the following : ioctl function (Chapter 17). get_ifi_info function (Section 17.6, Chapter 17). This function will be used by the server code to discover its node’s network interfaces so that it can bind all its interface IP addresses (see Section 22.6). ‘Race’ conditions (Section 20.5, Chapter 20) You also need a thorough understanding of how the TCP protocol implements reliable data transfer, flow control and congestion control. Chapters 17- 24 of TCP/IP Illustrated, Volume 1 by W. Richard Stevens gives a good overview of TCP. Though somewhat dated for some things (it was published in 1994), it remains, overall, a good basic reference. Overview This assignment asks you to implement a primitive file transfer protocol for Unix platforms, based on UDP, and with TCP-like reliability added to the transfer operation using timeouts and sliding-window mechanisms, and implementing flow and congestion control. The server is a concurrent server which can handle multiple clients simultaneously. A client gives the server the name of a file. The server forks off a child which reads directly from the file and transfers the contents over to the client using UDP datagrams. The client prints out the file contents as they come in, in order, with nothing missing and with no duplication of content, directly on to stdout (via the receiver sliding window, of course, but with no other intermediate buffering). The file to be transferred can be of arbitrary length, but its contents are always straightforward ascii text. As an aside let me mention that assuming the file contents ascii is not as restrictive as it sounds. We can always pretend, for example, that binary files are base64 encoded (“ASCII armor”). A real file transfer protocol would, of course, have to worry about transferring files between heterogeneous platforms with different file structure conventions and semantics. The sender would first have to transform the file into a platform-independent, protocol-defined, format (using, say, ASN.1, or some such standard), and the receiver would have to transform the received file into its platform’s native file format. This kind of thing can be fairly time consuming, and is certainly very tedious, to implement, with little educational value - it is not part of this assignment. Arguments for the server You should provide the server with an input file server.in from which it reads the following information, in the order shown, one item per line : Well-known port number for server. Maximum sending sliding-window size (in datagram units). You will not be handing in your server.in file. We shall create our own when we come to test your code. So it is important that you stick strictly to the file name and content conventions specified above. The same applies to the client.in input file below. Arguments for the client The client is to be provided with an input file client.in from which it reads the following information, in the order shown, one item per line : IP address of server (not the hostname). Well-known port number of server. filename to be transferred. Receiving sliding-window size (in datagram units). Random generator seed value. Probability p of datagram loss. This should be a real number in the range [ 0.0 , 1.0 ] (value 0.0 means no loss occurs; value 1.0 means all datagrams all lost). The mean µ, in milliseconds, for an exponential distribution controlling the rate at which the client reads received datagram payloads from its receive buffer. Operation Server starts up and reads its arguments from file server.in. As we shall see, when a client communicates with the server, the server will want to know what IP address that client is using to identify the server (i.e. , the destination IP address in the incoming datagram). Normally, this can be done relatively straightforwardly using the IP_RECVDESTADDR socket option, and picking up the information using the ancillary data (‘control information’) capability of the recvmsg function. Unfortunately, Solaris 2.10 does not support the IP_RECVDESTADDR option (nor, incidentally, does it support the msg_flags option in msghdr - see p.390). This considerably complicates things. In the absence of IP_RECVDESTADDR, what the server has to do as part of its initialization phase is to bind each IP address it has (and, simultaneously, its well-known port number, which it has read in from server.in) to a separate UDP socket. The code in Section 22.6, which uses the get_ifi_info function, shows you how to do that. However, there are important differences between that code and the version you want to implement. The code of Section 22.6 binds the IP addresses and forks off a child for each address that is bound to. We do not want to do that. Instead you should have an array of socket descriptors. For each IP address, create a new socket and bind the address (and well-known port number) to the socket without forking off child processes. Creating child processes comes later, when clients arrive. The code of Section 22.6 also attempts to bind broadcast addresses. We do not want to do this. It binds a wildcard IP address, which we certainly do not want to do either. We should bind strictly only unicast addresses (including the loopback address). The get_ifi_info function (which the code in Section 22.6 uses) has to be modified so that it also gets the network masks for the IP addresses of the node, and adds these to the information stored in the linked list of ifi_info structures (see Figure 17.5, p.471) it produces. As you go binding each IP address to a distinct socket, it will be useful for later processing to build your own array of structures, where a structure element records the following information for each socket : sockfd IP address bound to the socket network mask for the IP address subnet address (obtained by doing a bit-wise and between the IP address and its network mask) Report, in a ReadMe file which you hand in with your code, on the modifications you had to introduce to ensure that only unicast addresses are bound, and on your implementation of the array of structures described above. You should print out on stdout, with an appropriate message and appropriately formatted in dotted decimal notation, the IP address, network mask, and subnet address for each socket in your array of structures (you do not need to print the sockfd). The server now uses select to monitor the sockets it has created for incoming datagrams. When it returns from select, it must use recvfrom or recvmsg to read the incoming datagram (see 6. below). When a client starts, it first reads its arguments from the file client.in. The client checks if the server host is ‘local’ to its (extended) Ethernet. If so, all its communication to the server is to occur as MSG_DONTROUTE (or SO_DONTROUTE socket option). It determines if the server host is ‘local’ as follows. The first thing the client should do is to use the modified get_ifi_info function to obtain all of its IP addresses and associated network masks. Print out on stdout, in dotted decimal notation and with an appropriate message, the IP addresses and network masks obtained. In the following, IPserver designates the IP address the client will use to identify the server, and IPclient designates the IP address the client will choose to identify itself. The client checks whether the server is on the same host. If so, it should use the loopback address 127.0.0.1 for the server (i.e. , IPserver = 127.0.0.1). IPclient should also be set to the loopback address. Otherwise it proceeds as follows: IPserver is set to the IP address for the server in the client.in file. Given IPserver and the (unicast) IP addresses and network masks for the client returned by get_ifi_info in the linked list of ifi_info structures, you should be able to figure out if the server node is ‘local’ or not. This will be discussed in class; but let me just remind you here that you should use ‘longest prefix matching’ where applicable. If there are multiple client addresses, and the server host is ‘local’, the client chooses an IP address for itself, IPclient, which matches up as ‘local’ according to your examination above. If the server host is not ‘local’, then IPclient can be chosen arbitrarily. Print out on stdout the results of your examination, as to whether the server host is ‘local’ or not, as well as the IPclient and IPserver addresses selected. Note that this manner of determining whether the server is local or not is somewhat clumsy and ‘over-engineered’, and, as such, should be viewed more in the nature of a pedagogical exercise. Ideally, we would like to look up the server IP address(es) in the routing table (see Section 18.3). This requires that a routing socket be created, for which we need superuser privilege. Alternatively, we might want to dump out the routing table, using the sysctl function for example (see Section 18.4), and examine it directly. Unfortunately, Solaris 2.10 does not support sysctl. Furthermore, note that there is a slight problem with the address 130.245.1.123/24 assigned to compserv3 (see rightmost column of file hosts, and note that this particular compserv3 address “overlaps” with the 130.245.1.x/28 addresses in that same column assigned to compserv1, compserv2 & comserv4). In particular, if the client is running on compserv3 and the server on any of the other three compservs, and if that server node is also being identified to the client by its /28 (rather than its /24) address, then the client will get a “false positive” when it tests as to whether the server node is local or not. In other words, the client will deem the server node to be local, whereas in fact it should not be considered local. Because of this, it is perhaps best simply not to use compserv3 to run the client (but it is o.k. to use it to run the server). Finally, using MSG_DONTROUTE where possible would seem to gain us efficiency, in as much as the kernel does not need to consult the routing table for every datagram sent. But, in fact, that is not so. Recall that one effect of connect with UDP sockets is that routing information is obtained by the kernel at the time the connect is issued. That information is cached and used for subsequent sends from the connected socket (see p.255). The client now creates a UDP socket and calls bind on IPclient, with 0 as the port number. This will cause the kernel to bind an ephemeral port to the socket. After the bind, use the getsockname function (Section 4.10) to obtain IPclient and the ephemeral port number that has been assigned to the socket, and print that information out on stdout, with an appropriate message and appropriately formatted. The client connects its socket to IPserver and the well-known port number of the server. After the connect, use the getpeername function (Section 4.10) to obtain IPserver and the well-known port number of the server, and print that information out on stdout, with an appropriate message and appropriately formatted. The client sends a datagram to the server giving the filename for the transfer. This send needs to be backed up by a timeout in case the datagram is lost. Note that the incoming datagram from the client will be delivered to the server at the socket to which the destination IP address that the datagram is carrying has been bound. Thus, the server can obtain that address (it is, of course, IPserver) and thereby achieve what IP_RECVDESTADDR would have given us had it been available. Furthermore, the server process can obtain the IP address (this will, of course, be IPclient) and ephemeral port number of the client through the recvfrom or recvmsg functions. The server forks off a child process to handle the client. The server parent process goes back to the select to listen for new clients. Hereafter, and unless otherwise stated, whenever we refer to the ‘server’, we mean the server child process handling the client’s file transfer, not the server parent process. Typically, the first thing the server child would be expected to do is to close all sockets it ‘inherits’ from its parent. However, this is not the case with us. The server child does indeed close the sockets it inherited, but not the socket on which the client request arrived. It leaves that socket open for now. Call this socket the ‘listening’ socket. The server (child) then checks if the client host is local to its (extended) Ethernet. If so, all its communication to the client is to occur as MSG_DONTROUTE (or SO_DONTROUTE socket option). If IPserver (obtained in 5. above) is the loopback address, then we are done. Otherwise, the server has to proceed with the following step. Use the array of structures you built in 1. above, together with the addresses IPserver and IPclient to determine if the client is ‘local’. Print out on stdout the results of your examination, as to whether the client host is ‘local’ or not. The server (child) creates a UDP socket to handle file transfer to the client. Call this socket the ‘connection’ socket. It binds the socket to IPserver, with port number 0 so that its kernel assigns an ephemeral port. After the bind, use the getsockname function (Section 4.10) to obtain IPserver and the ephemeral port number that has been assigned to the socket, and print that information out on stdout, with an appropriate message and appropriately formatted. The server then connects this ‘connection’ socket to the client’s IPclient and ephemeral port number. The server now sends the client a datagram, in which it passes it the ephemeral port number of its ‘connection’ socket as the data payload of the datagram. This datagram is sent using the ‘listening’ socket inherited from its parent, otherwise the client (whose socket is connected to the server’s ‘listening’ socket at the latter’s well-known port number) will reject it. This datagram must be backed up by the ARQ mechanism, and retransmitted in the event of loss. Note that if this datagram is indeed lost, the client might well time out and retransmit its original request message (the one carrying the file name). In this event, you must somehow ensure that the parent server does not mistake this retransmitted request for a new client coming in, and spawn off yet another child to handle it. How do you do that? It is potentially more involved than it might seem. I will be discussing this in class, as well as ‘race’ conditions that could potentially arise, depending on how you code the mechanisms I present. When the client receives the datagram carrying the ephemeral port number of the server’s ‘connection’ socket, it reconnects its socket to the server’s ‘connection’ socket, using IPserver and the ephemeral port number received in the datagram (see p.254). It now uses this reconnected socket to send the server an acknowledgment. Note that this implies that, in the event of the server timing out, it should retransmit two copies of its ‘ephemeral port number’ message, one on its ‘listening’ socket and the other on its ‘connection’ socket (why?). When the server receives the acknowledgment, it closes the ‘listening’ socket it inherited from its parent. The server can now commence the file transfer through its ‘connection’ socket. The net effect of all these binds and connects at server and client is that no ‘outsider’ UDP datagram (broadcast, multicast, unicast - fortuitously or maliciously) can now intrude on the communication between server and client. Starting with the first datagram sent out, the client behaves as follows. Whenever a datagram arrives, or an ACK is about to be sent out (or, indeed, the initial datagram to the server giving the filename for the transfer), the client uses some random number generator function random() (initialized by the client.in argument value seed) to decide with probability p (another client.in argument value) if the datagram or ACK should be discarded by way of simulating transmission loss across the network. (I will briefly discuss in class how you do this.) Adding reliability to UDP The mechanisms you are to implement are based on TCP Reno. These include : Reliable data transmission using ARQ sliding-windows, with Fast Retransmit. Flow control via receiver window advertisements. Congestion control that implements : SlowStart Congestion Avoidance (‘Additive-Increase/Multiplicative Decrease’ – AIMD) Fast Recovery (but without the window-inflation aspect of Fast Recovery) Only some, and by no means all, of the details for these are covered below. The rest will be presented in class, especially those concerning flow control and TCP Reno’s congestion control mechanisms in general : Slow Start, Congestion Avoidance, Fast Retransmit and Fast Recovery. Implement a timeout mechanism on the sender (server) side. This is available to you from Stevens, Section 22.5 . Note, however, that you will need to modify the basic driving mechanism of Figure 22.7 appropriately since the situation at the sender side is not a repetitive cycle of send-receive, but rather a straightforward progression of send-send-send-send- . . . . . . . . . . . Also, modify the RTT and RTO mechanisms of Section 22.5 as specified below. I will be discussing the details of these modifications and the reasons for them in class. Modify function rtt_stop (Fig. 22.13) so that it uses integer arithmetic rather than floating point. This will entail your also having to modify some of the variable and function parameter declarations throughout Section 22.5 from float to int, as appropriate. In the unprrt.h header file (Fig. 22.10) set : RTT_RXTMIN to 1000 msec. (1 sec. instead of the current value 3 sec.) RTT_RXTMAX to 3000 msec. (3 sec. instead of the current value 60 sec.) RTT_MAXNREXMT to 12 (instead of the current value 3) In function rtt_timeout (Fig. 22.14), after doubling the RTO in line 86, pass its value through the function rtt_minmax of Fig. 22.11 (somewhat along the lines of what is done in line 77 of rtt_stop, Fig. 22.13). Finally, note that with the modification to integer calculation of the smoothed RTT and its variation, and given the small RTT values you will experience on the cs / sbpub network, these calculations should probably now be done on a millisecond or even microsecond scale (rather than in seconds, as is the case with Stevens’ code). Otherwise, small measured RTTs could show up as 0 on a scale of seconds, yielding a negative result when we subtract the smoothed RTT from the measured RTT (line 72 of rtt_stop, Fig. 22.13). Report the details of your modifications to the code of Section 22.5 in the ReadMe file which you hand in with your code. We need to have a sender sliding window mechanism for the retransmission of lost datagrams; and a receiver sliding window in order to ensure correct sequencing of received file contents, and some measure of flow control. You should implement something based on TCP Reno’s mechanisms, with cumulative acknowledgments, receiver window advertisements, and a congestion control mechanism I will explain in detail in class. For a reference on TCP’s mechanisms generally, see W. Richard Stevens, TCP/IP Illustrated, Volume 1 , especially Sections 20.2 - 20.4 of Chapter 20 , and Sections 21.1 - 21.8 of Chapter 21 . Bear in mind that our sequence numbers should count datagrams, not bytes as in TCP. Remember that the sender and receiver window sizes have to be set according to the argument values in client.in and server.in, respectively. Whenever the sender window becomes full and so ‘locks’, the server should print out a message to that effect on stdout. Similarly, whenever the receiver window ‘locks’, the client should print out a message on stdout. Be aware of the potential for deadlock when the receiver window ‘locks’. This situation is handled by having the receiver process send a duplicate ACK which acts as a window update when its window opens again (see Figure 20.3 and the discussion about it in TCP/IP Illustrated). However, this is not enough, because ACKs are not backed up by a timeout mechanism in the event they are lost. So we will also need to implement a persist timer driving window probes in the sender process (see Sections 22.1 & 22.2 in Chapter 22 of TCP/IP Illustrated). Note that you do not have to worry about the Silly Window Syndrome discussed in Section 22.3 of TCP/IP Illustrated since the receiver process consumes ‘full sized’ 512-byte messages from the receiver buffer (see 3. below). Report on the details of the ARQ mechanism you implemented in the ReadMe file you hand in. Indeed, you should report on all the TCP mechanisms you implemented in the ReadMe file, both the ones discussed here, and the ones I will be discussing in class. Make your datagram payload a fixed 512 bytes, inclusive of the file transfer protocol header (which must, at the very least, carry: the sequence number of the datagram; ACKs; and advertised window notifications). The client reads the file contents in its receive buffer and prints them out on stdout using a separate thread. This thread sits in a repetitive loop till all the file contents have been printed out, doing the following. It samples from an exponential distribution with mean µ milliseconds (read from the client.in file), sleeps for that number of milliseconds; wakes up to read and print all in-order file contents available in the receive buffer at that point; samples again from the exponential distribution; sleeps; and so on. The formula -1 × µ × ln( random( ) ) , where ln is the natural logarithm, yields variates from an exponential distribution with mean µ, based on the uniformly-distributed variates over ( 0 , 1 ) returned by random(). Note that you will need to implement some sort of mutual exclusion/semaphore mechanism on the client side so that the thread that sleeps and wakes up to consume from the receive buffer is not updating the state variables of the buffer at the same time as the main thread reading from the socket and depositing into the buffer is doing the same. Furthermore, we need to ensure that the main thread does not effectively monopolize the semaphore (and thus lock out for prolonged periods of time) the sleeping thread when the latter wakes up. See the textbook, Section 26.7, ‘Mutexes: Mutual Exclusion’, pp.697-701. You might also find Section 26.8, ‘Condition Variables’, pp.701-705, useful. You will need to devise some way by which the sender can notify the receiver when it has sent the last datagram of the file transfer, without the receiver mistaking that EOF marker as part of the file contents. (Also, note that the last data segment could be a “short” segment of less than 512 bytes – your client needs to be able to handle this correctly somehow.) When the sender receives an ACK for the last datagram of the transfer, the (child) server terminates. The parent server has to take care of cleaning up zombie children. Note that if we want a clean closing, the client process cannot simply terminate when the receiver ACKs the last datagram. This ACK could be lost, which would leave the (child) server process ‘hanging’, timing out, and retransmitting the last datagram. TCP attempts to deal with this problem by means of the TIME_WAIT state. You should have your receiver process behave similarly, sticking around in something akin to a TIME_WAIT state in case in case it needs to retransmit the ACK. In the ReadMe file you hand in, report on how you dealt with the issues raised here: sender notifying receiver of the last datagram, clean closing, and so on. Output Some of the output required from your program has been described in the section Operation above. I expect you to provide further output – clear, well-structured, well-laid-out, concise but sufficient and helpful – in the client and server windows by means of which we can trace the correct evolution of your TCP’s behaviour in all its intricacies : information (e.g., sequence number) on datagrams and acks sent and dropped, window advertisements, datagram retransmissions (and why : dup acks or RTO); entering/exiting Slow Start and Congestion Avoidance, ssthresh and cwnd values; sender and receiver windows locking/unlocking; etc., etc. . . . . The onus is on you to convince us that the TCP mechanisms you implemented are working correctly. Too many students do not put sufficient thought, creative imagination, time or effort into this. It is not the TA’s nor my responsibility to sit staring at an essentially blank screen, trying to summon up our paranormal psychology skills to figure out if your TCP implementation is really working correctly in all its very intricate aspects, simply because the transferred file seems to be printing o.k. in the client window. Nor is it our responsibility to strain our eyes and our patience wading through a mountain of obscure, ill-structured, hyper-messy, debugging-style output because, for example, your effort-conserving concept of what is ‘suitable’ is to dump your debugging output on us, relevant, irrelevant, and everything in between.
joenali / Waterfallwaterfall } $("body").addClass("noscroll"); c.show(); g = e.outerHeight(); e.css("margin-bottom", "-" + g / 2 + "px"); setTimeout(function() { c.addClass("visible"); c.css("-webkit-transform", "none") }, 1); this.trigger("show", b); return false }, close: function(b) { var c = $("#" + b); c.data("parent") && c.data("parent").append(c); $("#zoomScroll").length === 0 && $("body").removeClass("noscroll"); c.removeClass("visible"); setTimeout(function() { c.hide(); c.css("-webkit-transform", "translateZ(0)") }, 251); this.trigger("close", b); return false } }; _.extend(Modal, Backbone.Events); var Arrays = { conjunct: function(b) { if (b.length == 1) return b[0]; else { b = b.slice(0); last = b.pop(); b.push("and " + last); return b.join(", ") } } }; $(document).ready(function() { ScrollToTop.setup(); Modal.setup(); $(".tipsyHover").tipsy({ gravity: "n", delayIn: 0.1, delayOut: 0.1, opacity: 0.7, live: true, html: true }); $("#query").focus(function() { cache && $(this).catcomplete("search", $(this).val()) }); $.widget("custom.catcomplete", $.ui.autocomplete, { _renderMenu: function(c, e) { var g = this, f = ""; $.each(e, function(d, h) { if (h.category != f) { c.append("<li class='ui-autocomplete-category'>" + h.category + "</li>"); f = h.category } g._renderItem(c, h) }); e = { link: "/search/?q=" + this.term }; $("<li></li>").data("item.autocomplete", e).append("<a href='/search/?q=" + this.term + "' class='ui-corner-all' tabindex='-1' style='font-weight:bold; min-height:0 !important;'>Search for " + this.term + "</a>").appendTo(c) } }); var b = $("#query").catcomplete({ source: function(c, e) { Tagging.getFriends(c, function(g) { var f = g; if (myboards) { f = tagmate.filter_options(myboards, c.term); f = g.concat(f) } for (g = 0; g < f.length; g++) f[g].value = f[g].label; e(f) }) }, minLength: 1, delay: 0, appendTo: "#SearchAutocompleteHolder", select: function(c, e) { document.location.href = e.item.link } }); if (typeof b.data("catcomplete") != "undefined") b.data("catcomplete")._renderItem = function(c, e) { var g = "<a href='" + e.link + "'><img src='" + e.image + "' class='AutocompletePhoto' alt='Photo of " + e.label + "' width='38px' height='38px'/><span class='AutocompleteName'>" + e.label + "</span></a>"; return $("<li></li>").data("item.autocomplete", e).append(g).appendTo(c) }; $("#query").defaultValue($("#query").attr("placeholder"), "default_value"); $("#Search #query_button").click(function() { $("#Search form").submit(); return false }); $("body").on("click", "a[rel=nofollow]", function(c) { var e = $(this).attr("href"); if (e === "#") return c.isDefaultPrevented(); if (!e.match(/^(http|https):\/\//) || e.match(/(http:\/\/|https:\/\/|\.)pinterest\.com\//gi) || $(this).hasClass("safelink")) return true; c = (c = $(this).parents(".pin").attr("data-id") || $(this).parents(".pin").attr("pin-id") || $(this).attr("data-id")) ? "&pin=" + c: ""; var g = $(this).parents(".comment").attr("comment-id"); g = g ? "&comment_id=" + g: ""; var f = (new jsSHA(getCookie("csrftoken"), "ASCII")).getHash("HEX"); window.open("//" + window.location.host + "/offsite/?url=" + encodeURIComponent(e) + "&shatoken=" + f + c + g); return false }) }); Twitter = new(function() { var b = this; this.startTwitterConnect = function() { b._twitterWindow = window.open("/connect/twitter/", "Pinterest", "location=0,status=0,width=800,height=400"); b._twitterInterval = window.setInterval(b.completeTwitterConnect, 1E3) }; this.completeTwitterConnect = function() { if (b._twitterWindow.closed) { window.clearInterval(b._twitterInterval); window.location.reload() } } }); Facebook = new(function() { var b = this; this.startFacebookConnect = function(c, e, g, f) { g = g == undefined ? true: g; var d = "/connect/facebook/", h = "?"; if (c) { d += h + "scope=" + c; h = "&" } if (e) { d += h + "enable_timeline=1"; h = "&" } if (f) d += h + "ref_page=" + f; b._facebookWindow = window.open(d, "Pinterest", "location=0,status=0,width=800,height=400"); if (g) b._facebookInterval = window.setInterval(this.completeFacebookConnect, 1E3) }; this.completeFacebookConnect = function() { if (b._facebookWindow.closed) { window.clearInterval(b._facebookInterval); window.location.reload() } } }); Google = new(function() { var b = this; this.startGoogleConnect = function() { b._googleWindow = window.open("/connect/google/", "Google", "location=0,status=0,width=800,height=400"); b._googleInterval = window.setInterval(b.completeGoogleConnect, 1E3) }; this.completeGoogleConnect = function() { if (b._googleWindow.closed) { window.clearInterval(b._googleInterval); window.location.reload() } } }); Yahoo = new(function() { var b = this; this.startYahooConnect = function() { b._yahooWindow = window.open("/connect/yahoo/", "Yahoo", "location=0,status=0,width=800,height=400"); b._yahooInterval = window.setInterval(b.completeYahooConnect, 1E3) }; this.completeYahooConnect = function() { if (b._yahooWindow.closed) { window.clearInterval(b._yahooInterval); window.location.reload() } } }); (function(b) { function c(g) { return typeof g == "object" ? g: { top: g, left: g } } var e = b.scrollTo = function(g, f, d) { b(window).scrollTo(g, f, d) }; e.defaults = { axis: "xy", duration: parseFloat(b.fn.jquery) >= 1.3 ? 0 : 1 }; e.window = function() { return b(window)._scrollable() }; b.fn._scrollable = function() { return this.map(function() { var g = this; if (! (!g.nodeName || b.inArray(g.nodeName.toLowerCase(), ["iframe", "#document", "html", "body"]) != -1)) return g; g = (g.contentWindow || g).document || g.ownerDocument || g; return b.browser.safari || g.compatMode == "BackCompat" ? g.body: g.documentElement }) }; b.fn.scrollTo = function(g, f, d) { if (typeof f == "object") { d = f; f = 0 } if (typeof d == "function") d = { onAfter: d }; if (g == "max") g = 9E9; d = b.extend({}, e.defaults, d); f = f || d.speed || d.duration; d.queue = d.queue && d.axis.length > 1; if (d.queue) f /= 2; d.offset = c(d.offset); d.over = c(d.over); return this._scrollable().each(function() { function h(m) { k.animate(u, f, d.easing, m && function() { m.call(this, g, d) }) } var j = this, k = b(j), l = g, r, u = {}, o = k.is("html,body"); switch (typeof l) { case "number": case "string": if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(l)) { l = c(l); break } l = b(l, this); case "object": if (l.is || l.style) r = (l = b(l)).offset() } b.each(d.axis.split(""), function(m, q) { var v = q == "x" ? "Left": "Top", w = v.toLowerCase(), B = "scroll" + v, D = j[B], I = e.max(j, q); if (r) { u[B] = r[w] + (o ? 0 : D - k.offset()[w]); if (d.margin) { u[B] -= parseInt(l.css("margin" + v)) || 0; u[B] -= parseInt(l.css("border" + v + "Width")) || 0 } u[B] += d.offset[w] || 0; if (d.over[w]) u[B] += l[q == "x" ? "width": "height"]() * d.over[w] } else { q = l[w]; u[B] = q.slice && q.slice( - 1) == "%" ? parseFloat(q) / 100 * I: q } if (/^\d+$/.test(u[B])) u[B] = u[B] <= 0 ? 0 : Math.min(u[B], I); if (!m && d.queue) { D != u[B] && h(d.onAfterFirst); delete u[B] } }); h(d.onAfter) }).end() }; e.max = function(g, f) { var d = f == "x" ? "Width": "Height"; f = "scroll" + d; if (!b(g).is("html,body")) return g[f] - b(g)[d.toLowerCase()](); d = "client" + d; var h = g.ownerDocument.documentElement; g = g.ownerDocument.body; return Math.max(h[f], g[f]) - Math.min(h[d], g[d]) } })(jQuery); (function() { jQuery.each({ getSelection: function() { var b = this.jquery ? this[0] : this; return ("selectionStart" in b && function() { var c = b.selectionEnd - b.selectionStart; return { start: b.selectionStart, end: b.selectionEnd, length: c, text: b.value.substr(b.selectionStart, c) } } || document.selection && function() { b.focus(); var c = document.selection.createRange(); if (c == null) return { start: 0, end: b.value.length, length: 0 }; var e = b.createTextRange(), g = e.duplicate(); e.moveToBookmark(c.getBookmark()); g.setEndPoint("EndToStart", e); var f = g.text.length, d = f; for (e = 0; e < f; e++) g.text.charCodeAt(e) == 13 && d--; f = g = c.text.length; for (e = 0; e < g; e++) c.text.charCodeAt(e) == 13 && f--; return { start: d, end: d + f, length: f, text: c.text } } || function() { return { start: 0, end: b.value.length, length: 0 } })() }, setSelection: function(b, c) { var e = this.jquery ? this[0] : this, g = b || 0, f = c || 0; return ("selectionStart" in e && function() { e.focus(); e.selectionStart = g; e.selectionEnd = f; return this } || document.selection && function() { e.focus(); var d = e.createTextRange(), h = g; for (i = 0; i < h; i++) if (e.value[i].search(/[\r\n]/) != -1) g -= 0.5; h = f; for (i = 0; i < h; i++) if (e.value[i].search(/[\r\n]/) != -1) f -= 0.5; d.moveEnd("textedit", -1); d.moveStart("character", g); d.moveEnd("character", f - g); d.select(); return this } || function() { return this })() }, replaceSelection: function(b) { var c = this.jquery ? this[0] : this, e = b || ""; return ("selectionStart" in c && function() { c.value = c.value.substr(0, c.selectionStart) + e + c.value.substr(c.selectionEnd, c.value.length); return this } || document.selection && function() { c.focus(); document.selection.createRange().text = e; return this } || function() { c.value += e; return this })() } }, function(b) { jQuery.fn[b] = this }) })(); var tagmate = tagmate || { USER_TAG_EXPR: "@\\w+(?: \\w*)?", HASH_TAG_EXPR: "#\\w+", USD_TAG_EXPR: "\\$(?:(?:\\d{1,3}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?", GBP_TAG_EXPR: "\\\u00a3(?:(?:\\d{1,3}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?", filter_options: function(b, c) { for (var e = [], g = 0; g < b.length; g++) { var f = b[g].label.toLowerCase(), d = c.toLowerCase(); d.length <= f.length && f.indexOf(d) == 0 && e.push(b[g]) } return e }, sort_options: function(b) { return b.sort(function(c, e) { c = c.label.toLowerCase(); e = e.label.toLowerCase(); if (c > e) return 1; else if (c < e) return - 1; return 0 }) } }; (function(b) { function c(d, h, j) { d = d.substring(j || 0).search(h); return d >= 0 ? d + (j || 0) : d } function e(d) { return d.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") } function g(d, h, j) { var k = {}; for (tok in h) if (j && j[tok]) { var l = {}, r = {}; for (key in j[tok]) { var u = j[tok][key].value, o = j[tok][key].label, m = e(tok + o), q = ["(?:^(", ")$|^(", ")\\W|\\W(", ")\\W|\\W(", ")$)"].join(m), v = 0; for (q = new RegExp(q, "gm"); (v = c(d.val(), q, v)) > -1;) { var w = r[v] ? r[v] : null; if (!w || l[w].length < o.length) r[v] = u; l[u] = o; v += o.length + 1 } } for (v in r) k[tok + r[v]] = tok } else { l = null; for (q = new RegExp("(" + h[tok] + ")", "gm"); l = q.exec(d.val());) k[l[1]] = tok } d = []; for (m in k) d.push(m); return d } var f = { "@": tagmate.USER_TAG_EXPR, "#": tagmate.HASH_TAG_EXPR, $: tagmate.USD_TAG_EXPR, "\u00a3": tagmate.GBP_TAG_EXPR }; b.fn.extend({ getTags: function(d, h) { var j = b(this); d = d || j.data("_tagmate_tagchars"); h = h || j.data("_tagmate_sources"); return g(j, d, h) }, tagmate: function(d) { function h(o, m, q) { for (m = new RegExp("[" + m + "]"); q >= 0 && !m.test(o[q]); q--); return q } function j(o) { var m = o.val(), q = o.getSelection(), v = -1; o = null; for (tok in u.tagchars) { var w = h(m, tok, q.start); if (w > v) { v = w; o = tok } } m = m.substring(v + 1, q.start); if ((new RegExp("^" + u.tagchars[o])).exec(o + m)) return o + m; return null } function k(o, m, q) { var v = o.val(), w = o.getSelection(); w = h(v, m[0], w.start); var B = v.substr(0, w); v = v.substr(w + m.length); o.val(B + m[0] + q + v); v = w + q.length + 1; o.setSelection(v, v); u.replace_tag && u.replace_tag(m, q) } function l(o, m) { m = tagmate.sort_options(m); for (var q = 0; q < m.length; q++) { var v = m[q].label, w = m[q].image; q == 0 && o.html(""); var B = "<span>" + v + "</span>"; if (w) B = "<img src='" + w + "' alt='" + v + "'/>" + B; v = u.menu_option_class; if (q == 0) v += " " + u.menu_option_active_class; o.append("<div class='" + v + "'>" + B + "</div>") } } function r(o, m) { var q = m == "down" ? ":first-child": ":last-child", v = m == "down" ? "next": "prev"; m = o.children("." + u.menu_option_active_class); if (m.length == 0) m = o.children(q); else { m.removeClass(u.menu_option_active_class); m = m[v]().length > 0 ? m[v]() : m } m.addClass(u.menu_option_active_class); v = o.children(); var w = Math.floor(b(o).height() / b(v[0]).height()) - 1; if (b(o).height() % b(v[0]).height() > 0) w -= 1; for (q = 0; q < v.length && b(v[q]).html() != b(m).html(); q++); q > w && q - w >= 0 && q - w < v.length && o.scrollTo(v[q - w]) } var u = { tagchars: f, sources: null, capture_tag: null, replace_tag: null, menu: null, menu_class: "tagmate-menu", menu_option_class: "tagmate-menu-option", menu_option_active_class: "tagmate-menu-option-active" }; return this.each(function() { function o() { w.hide(); var D = j(m); if (D) { var I = D[0], p = D.substr(1), n = m.getSelection(), z = h(m.val(), I, n.start); n.start - z <= D.length && function(A) { if (typeof u.sources[I] === "object") A(tagmate.filter_options(u.sources[I], p)); else typeof u.sources[I] === "function" ? u.sources[I]({ term: p }, A) : A() } (function(A) { if (A && A.length > 0) { l(w, A); w.css("top", m.outerHeight() - 1 + "px"); w.show(); for (var E = m.data("_tagmate_sources"), F = 0; F < A.length; F++) { for (var Q = false, H = 0; ! Q && H < E[I].length; H++) Q = E[I][H].value == A[F].value; Q || E[I].push(A[F]) } } D && u.capture_tag && u.capture_tag(D) }) } } d && b.extend(u, d); var m = b(this); m.data("_tagmate_tagchars", u.tagchars); var q = {}; for (var v in u.sources) q[v] = []; m.data("_tagmate_sources", q); var w = u.menu; if (!w) { w = b("<div class='" + u.menu_class + "'></div>"); m.after(w) } m.offset(); w.css("position", "absolute"); w.hide(); var B = false; b(m).unbind(".tagmate").bind("focus.tagmate", function() { o() }).bind("blur.tagmate", function() { setTimeout(function() { w.hide() }, 300) }).bind("click.tagmate", function() { o() }).bind("keydown.tagmate", function(D) { if (w.is(":visible")) if (D.keyCode == 40) { r(w, "down"); B = true; return false } else if (D.keyCode == 38) { r(w, "up"); B = true; return false } else if (D.keyCode == 13) { D = w.children("." + u.menu_option_active_class).text(); var I = j(m); if (I && D) { k(m, I, D); w.hide(); B = true; return false } } else if (D.keyCode == 27) { w.hide(); B = true; return false } }).bind("keyup.tagmate", function() { if (B) { B = false; return true } o() }); b("." + u.menu_class + " ." + u.menu_option_class).die("click.tagmate").live("click.tagmate", function() { var D = b(this).text(), I = j(m); k(m, I, D); w.hide(); B = true; return false }) }) } }) })(jQuery); (function(b) { function c(f) { var d; if (f && f.constructor == Array && f.length == 3) return f; if (d = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)) return [parseInt(d[1]), parseInt(d[2]), parseInt(d[3])]; if (d = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)) return [parseFloat(d[1]) * 2.55, parseFloat(d[2]) * 2.55, parseFloat(d[3]) * 2.55]; if (d = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)) return [parseInt(d[1], 16), parseInt(d[2], 16), parseInt(d[3], 16)]; if (d = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)) return [parseInt(d[1] + d[1], 16), parseInt(d[2] + d[2], 16), parseInt(d[3] + d[3], 16)]; return g[b.trim(f).toLowerCase()] } function e(f, d) { var h; do { h = b.curCSS(f, d); if (h != "" && h != "transparent" || b.nodeName(f, "body")) break; d = "backgroundColor" } while ( f = f . parentNode ); return c(h) } b.each(["backgroundColor", "borderBottomColor", "borderLeftColor", "borderRightColor", "borderTopColor", "color", "outlineColor"], function(f, d) { b.fx.step[d] = function(h) { if (h.state == 0) { h.start = e(h.elem, d); h.end = c(h.end) } h.elem.style[d] = "rgb(" + [Math.max(Math.min(parseInt(h.pos * (h.end[0] - h.start[0]) + h.start[0]), 255), 0), Math.max(Math.min(parseInt(h.pos * (h.end[1] - h.start[1]) + h.start[1]), 255), 0), Math.max(Math.min(parseInt(h.pos * (h.end[2] - h.start[2]) + h.start[2]), 255), 0)].join(",") + ")" } }); var g = { aqua: [0, 255, 255], azure: [240, 255, 255], beige: [245, 245, 220], black: [0, 0, 0], blue: [0, 0, 255], brown: [165, 42, 42], cyan: [0, 255, 255], darkblue: [0, 0, 139], darkcyan: [0, 139, 139], darkgrey: [169, 169, 169], darkgreen: [0, 100, 0], darkkhaki: [189, 183, 107], darkmagenta: [139, 0, 139], darkolivegreen: [85, 107, 47], darkorange: [255, 140, 0], darkorchid: [153, 50, 204], darkred: [139, 0, 0], darksalmon: [233, 150, 122], darkviolet: [148, 0, 211], fuchsia: [255, 0, 255], gold: [255, 215, 0], green: [0, 128, 0], indigo: [75, 0, 130], khaki: [240, 230, 140], lightblue: [173, 216, 230], lightcyan: [224, 255, 255], lightgreen: [144, 238, 144], lightgrey: [211, 211, 211], lightpink: [255, 182, 193], lightyellow: [255, 255, 224], lime: [0, 255, 0], magenta: [255, 0, 255], maroon: [128, 0, 0], navy: [0, 0, 128], olive: [128, 128, 0], orange: [255, 165, 0], pink: [255, 192, 203], purple: [128, 0, 128], violet: [128, 0, 128], red: [255, 0, 0], silver: [192, 192, 192], white: [255, 255, 255], yellow: [255, 255, 0] } })(jQuery); jQuery.cookie = function(b, c, e) { if (arguments.length > 1 && String(c) !== "[object Object]") { e = jQuery.extend({}, e); if (c === null || c === undefined) e.expires = -1; if (typeof e.expires === "number") { var g = e.expires, f = e.expires = new Date; f.setDate(f.getDate() + g) } c = String(c); return document.cookie = [encodeURIComponent(b), "=", e.raw ? c: encodeURIComponent(c), e.expires ? "; expires=" + e.expires.toUTCString() : "", e.path ? "; path=" + e.path: "", e.domain ? "; domain=" + e.domain: "", e.secure ? "; secure": ""].join("") } e = c || {}; f = e.raw ? function(d) { return d }: decodeURIComponent; return (g = (new RegExp("(?:^|; )" + encodeURIComponent(b) + "=([^;]*)")).exec(document.cookie)) ? f(g[1]) : null }; if (!window.JSON) window.JSON = {}; (function() { function b(r) { return r < 10 ? "0" + r: r } function c(r) { d.lastIndex = 0; return d.test(r) ? '"' + r.replace(d, function(u) { var o = k[u]; return typeof o === "string" ? o: "\\u" + ("0000" + u.charCodeAt(0).toString(16)).slice( - 4) }) + '"': '"' + r + '"' } function e(r, u) { var o, m, q = h, v, w = u[r]; if (w && typeof w === "object" && typeof w.toJSON === "function") w = w.toJSON(r); if (typeof l === "function") w = l.call(u, r, w); switch (typeof w) { case "string": return c(w); case "number": return isFinite(w) ? String(w) : "null"; case "boolean": case "null": return String(w); case "object": if (!w) return "null"; h += j; v = []; if (Object.prototype.toString.apply(w) === "[object Array]") { m = w.length; for (r = 0; r < m; r += 1) v[r] = e(r, w) || "null"; u = v.length === 0 ? "[]": h ? "[\n" + h + v.join(",\n" + h) + "\n" + q + "]": "[" + v.join(",") + "]"; h = q; return u } if (l && typeof l === "object") { m = l.length; for (r = 0; r < m; r += 1) { o = l[r]; if (typeof o === "string") if (u = e(o, w)) v.push(c(o) + (h ? ": ": ":") + u) } } else { for (o in w) if (Object.hasOwnProperty.call(w, o)) if (u = e(o, w)) { v.push(c(o) + (h ? ": ": ":") + u); } } u = v.length === 0 ? "{}": h ? "{\n" + h + v.join(",\n" + h) + "\n" + q + "}": "{" + v.join(",") + "}"; h = q; return u } } if (typeof Date.prototype.toJSON !== "function") { Date.prototype.toJSON = function() { return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + b(this.getUTCMonth() + 1) + "-" + b(this.getUTCDate()) + "T" + b(this.getUTCHours()) + ":" + b(this.getUTCMinutes()) + ":" + b(this.getUTCSeconds()) + "Z": null }; String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function() { return this.valueOf() } } var g = window.JSON, f = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, d = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, h, j, k = { "\u0008": "\\b", "\t": "\\t", "\n": "\\n", "\u000c": "\\f", "\r": "\\r", '"': '\\"', "\\": "\\\\" }, l; if (typeof g.stringify !== "function") g.stringify = function(r, u, o) { var m; j = h = ""; if (typeof o === "number") for (m = 0; m < o; m += 1) j += " "; else if (typeof o === "string") j = o; if ((l = u) && typeof u !== "function" && (typeof u !== "object" || typeof u.length !== "number")) throw new Error("JSON.stringify"); return e("", { "": r }) }; if (typeof g.parse !== "function") g.parse = function(r, u) { function o(m, q) { var v, w, B = m[q]; if (B && typeof B === "object") for (v in B) if (Object.hasOwnProperty.call(B, v)) { w = o(B, v); if (w !== undefined) B[v] = w; else delete B[v] } return u.call(m, q, B) } r = String(r); f.lastIndex = 0; if (f.test(r)) r = r.replace(f, function(m) { return "\\u" + ("0000" + m.charCodeAt(0).toString(16)).slice( - 4) }); if (/^[\],:{}\s]*$/.test(r.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) { r = eval("(" + r + ")"); return typeof u === "function" ? o({ "": r }, "") : r } throw new SyntaxError("JSON.parse"); } })(); (function() { var b = function(o) { var m = [], q = o.length * 8, v; for (v = 0; v < q; v += 8) m[v >> 5] |= (o.charCodeAt(v / 8) & 255) << 24 - v % 32; return m }, c = function(o) { var m = [], q = o.length, v, w; for (v = 0; v < q; v += 2) { w = parseInt(o.substr(v, 2), 16); if (isNaN(w)) return "INVALID HEX STRING"; else m[v >> 3] |= w << 24 - 4 * (v % 8) } return m }, e = function(o) { var m = "", q = o.length * 4, v, w; for (v = 0; v < q; v += 1) { w = o[v >> 2] >> (3 - v % 4) * 8; m += "0123456789abcdef".charAt(w >> 4 & 15) + "0123456789abcdef".charAt(w & 15) } return m }, g = function(o) { var m = "", q = o.length * 4, v, w, B; for (v = 0; v < q; v += 3) { B = (o[v >> 2] >> 8 * (3 - v % 4) & 255) << 16 | (o[v + 1 >> 2] >> 8 * (3 - (v + 1) % 4) & 255) << 8 | o[v + 2 >> 2] >> 8 * (3 - (v + 2) % 4) & 255; for (w = 0; w < 4; w += 1) m += v * 8 + w * 6 <= o.length * 32 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(B >> 6 * (3 - w) & 63) : "" } return m }, f = function(o, m) { return o << m | o >>> 32 - m }, d = function(o, m, q) { return o ^ m ^ q }, h = function(o, m, q) { return o & m ^ ~o & q }, j = function(o, m, q) { return o & m ^ o & q ^ m & q }, k = function(o, m) { var q = (o & 65535) + (m & 65535); return ((o >>> 16) + (m >>> 16) + (q >>> 16) & 65535) << 16 | q & 65535 }, l = function(o, m, q, v, w) { var B = (o & 65535) + (m & 65535) + (q & 65535) + (v & 65535) + (w & 65535); return ((o >>> 16) + (m >>> 16) + (q >>> 16) + (v >>> 16) + (w >>> 16) + (B >>> 16) & 65535) << 16 | B & 65535 }, r = function(o, m) { var q = [], v, w, B, D, I, p, n, z, A = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], E = [1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782]; o[m >> 5] |= 128 << 24 - m % 32; o[(m + 65 >> 9 << 4) + 15] = m; z = o.length; for (p = 0; p < z; p += 16) { m = A[0]; v = A[1]; w = A[2]; B = A[3]; D = A[4]; for (n = 0; n < 80; n += 1) { q[n] = n < 16 ? o[n + p] : f(q[n - 3] ^ q[n - 8] ^ q[n - 14] ^ q[n - 16], 1); I = n < 20 ? l(f(m, 5), h(v, w, B), D, E[n], q[n]) : n < 40 ? l(f(m, 5), d(v, w, B), D, E[n], q[n]) : n < 60 ? l(f(m, 5), j(v, w, B), D, E[n], q[n]) : l(f(m, 5), d(v, w, B), D, E[n], q[n]); D = B; B = w; w = f(v, 30); v = m; m = I } A[0] = k(m, A[0]); A[1] = k(v, A[1]); A[2] = k(w, A[2]); A[3] = k(B, A[3]); A[4] = k(D, A[4]) } return A }, u = function(o, m) { this.strToHash = this.strBinLen = this.sha1 = null; if ("HEX" === m) { if (0 !== o.length % 2) return "TEXT MUST BE IN BYTE INCREMENTS"; this.strBinLen = o.length * 4; this.strToHash = c(o) } else if ("ASCII" === m || "undefined" === typeof m) { this.strBinLen = o.length * 8; this.strToHash = b(o) } else return "UNKNOWN TEXT INPUT TYPE" }; u.prototype = { getHash: function(o) { var m = null, q = this.strToHash.slice(); switch (o) { case "HEX": m = e; break; case "B64": m = g; break; default: return "FORMAT NOT RECOGNIZED" } if (null === this.sha1) this.sha1 = r(q, this.strBinLen); return m(this.sha1) }, getHMAC: function(o, m, q) { var v; v = []; var w = []; switch (q) { case "HEX": q = e; break; case "B64": q = g; break; default: return "FORMAT NOT RECOGNIZED" } if ("HEX" === m) { if (0 !== o.length % 2) return "KEY MUST BE IN BYTE INCREMENTS"; m = c(o); o = o.length * 4 } else if ("ASCII" === m) { m = b(o); o = o.length * 8 } else return "UNKNOWN KEY INPUT TYPE"; if (64 < o / 8) { m = r(m, o); m[15] &= 4294967040 } else if (64 > o / 8) m[15] &= 4294967040; for (o = 0; o <= 15; o += 1) { v[o] = m[o] ^ 909522486; w[o] = m[o] ^ 1549556828 } v = r(v.concat(this.strToHash), 512 + this.strBinLen); v = r(w.concat(v), 672); return q(v) } }; window.jsSHA = u })(); var Router = function() { var b; if (!window.history.pushState) return null; b = new Backbone.Router({ routes: { "pin/:pinID/": "zoom", "pin/:pinID/repin/": "repin", ".*": "other" } }); Backbone.history.start({ pushState: true, silent: true }); return b } (); var BoardLayout = function() { return { setup: function(b) { if (!this.setupComplete) { this.setupFlow(); $(function() { if (window.userIsAuthenticated) { Like.gridListeners(); Follow.listeners(); Comment.gridComment(); RepinDialog2.setup() } Zoom.setup() }); this.center = !!b; this.setupComplete = true } }, setupFlow: function(b) { if (!this.flowSetupComplete) { BoardLayout.allPins(); b || $(window).resize(_.throttle(function() { BoardLayout.allPins() }, 200)); this.flowSetupComplete = true } }, pinsContainer: ".BoardLayout", pinArray: [], orderedPins: [], mappedPins: {}, nextPin: function(b) { b = this.orderedPins.indexOf(b) + 1; if (b >= this.orderedPins.length) return 0; return this.orderedPins[b] }, previousPin: function(b) { b = this.orderedPins.indexOf(b) - 1; if (b >= this.orderedPins.length) return 0; return this.orderedPins[b] }, columnCount: 4, columns: 0, columnWidthInner: 192, columnMargin: 15, columnPadding: 30, columnContainerWidth: 0, allPins: function() { var b = $(this.pinsContainer + " .pin"), c = this.getContentArea(); this.columnWidthOuter = this.columnWidthInner + this.columnMargin + this.columnPadding; this.columns = Math.max(this.columnCount, parseInt(c / this.columnWidthOuter, 10)); if (b.length < this.columns) this.columns = Math.max(this.columnCount, b.length); c = this.columnWidthOuter * this.columns - this.columnMargin; var e = document.getElementById("wrapper"); if (e) e.style.width = c + "px"; $(".LiquidContainer").css("width", c + "px"); for (c = 0; c < this.columns; c++) this.pinArray[c] = 0; document.getElementById("SortableButtons") ? this.showPins() : this.flowPins(b, true); if ($("#ColumnContainer .pin").length === 0 && window.location.pathname === "/") { $("#ColumnContainer").addClass("empty"); setTimeout(function() { window.location.reload() }, 5E3) } }, newPins: function() { var b = window.jQuery ? ":last": ":last-of-type", c = $(this.pinsContainer + b + " .pin"); c = c.length > 0 ? c: $(this.pinsContainer + b + " .pin"); this.flowPins(c) }, flowPins: function(b, c) { if (c) { this.mappedPins = {}; this.orderedPins = [] } if (this.pinArray.length > this.columns) this.pinArray = this.pinArray.slice(0, this.columns); for (c = 0; c < b.length; c++) this.positionPin(b[c]); this.updateContainerHeight(); this.showPins(); window.useLazyLoad && LazyLoad.invalidate() }, positionPin: function(b) { var c = $(b).attr("data-id"); if (c && this.mappedPins[c]) $(b).remove(); else { var e = _.indexOf(this.pinArray, Math.min.apply(Math, this.pinArray)), g = this.shortestColumnTop = this.pinArray[e]; b.style.top = g + "px"; b.style.left = e * this.columnWidthOuter + "px"; b.setAttribute("data-col", e); this.pinArray[e] = g + b.offsetHeight + this.columnMargin; this.mappedPins[c] = this.orderedPins.length; this.orderedPins.push(c) } }, showPins: function() { $.browser.msie && parseInt($.browser.version, 10) == 7 || $(this.pinsContainer).css("opacity", 1); var b = $(this.pinsContainer); setTimeout(function() { b.css({ visibility: "visible" }) }, 200) }, imageLoaded: function() { $(this).removeClass("lazy") }, getContentArea: function() { return this.contentArea || document.documentElement.clientWidth }, updateContainerHeight: function() { $("#ColumnContainer").height(Math.max.apply(Math, this.pinArray)) } } } (); var LazyLoad = new(function() { var b = this, c = 0, e = 0, g = 100, f = $(window); b.images = {}; b.invalidate = function() { $("img.lazy").each(function(u, o) { u = $(o); b.images[u.attr("data-id")] = u; h(u) && j(u) }) }; b.check = function() { var u, o = false; return function() { if (!o) { o = true; clearTimeout(u); u = setTimeout(function() { o = false; d() }, 200) } } } (); var d = function() { var u = 0, o = 0; for (var m in b.images) { var q = b.images[m]; u++; if (h(q)) { j(q); o++ } } }; b.stop = function() { f.unbind("scroll", k); f.unbind("resize", l) }; var h = function(u) { return u.offset().top <= g }, j = function(u) { if (u.hasClass("lazy")) { var o = u.attr("data-src"), m = u.attr("data-id"); u.load(function() { if (u[0]) u[0].style.opacity = "1"; delete b.images[m] }); u.attr("src", o); u.removeClass("lazy"); if (u[0]) u[0].style.opacity = "0" } }, k = function() { c = $(window).scrollTop(); r(); b.check() }, l = function() { e = $(window).height(); r(); b.check() }, r = function() { g = c + e + 600 }; if (window.useLazyLoad) { f.ready(function() { k(); l() }); f.scroll(k); f.resize(l) } }); var FancySelect = function() { var b; return { setup: function(c, e, g) { function f() { b.hide(); j.hide() } function d() { j.show(); b.show() } var h = $('<div class="FancySelect"><div class="current"><span class="CurrentSelection"></span><span class="DownArrow"></span></div><div class="FancySelectList"><div class="wrapper"><ul></ul></div></div></div>'), j = $(".FancySelectList", h), k = $("ul", j), l = $(".CurrentSelection", h), r = "", u, o; b || (b = $('<div class="FancySelectOverlay"></div>').appendTo("body")); c = $(c); u = c.prop("selectedIndex"); e = e || function() { return '<li data="' + $(this).val() + '"><span>' + $(this).text() + "</span></li>" }; o = $("option", c); o.each(function(m) { r += e.call(this, m, m === u) }); k.html(r); l.text(o.eq(u).text()); c.before(h); c.hide(); h.click(function() { d() }); b.click(function() { f() }); k.on("click", "li", function() { var m = $(this).prevAll().length; l.text($(this).text()); c.prop("selectedIndex", m); f(); g && g($(this).attr("data")); return false }) } } } (); var boardPicker = function() { return { setup: function(b, c, e) { b = $(b); var g = $(".boardListOverlay", b.parent()), f = $(".boardList", b), d = $(".currentBoard", b), h = $("ul", f); b.click(function() { f.show(); g.show() }); g.click(function() { f.hide(); g.hide() }); $(h).on("click", "li", function() { if (!$(this).hasClass("noSelect")) { d.text($(this).text()); g.hide(); f.hide(); c && c($(this).attr("data")) } return false }); b = $(".createBoard", f); var j = $("input", b), k = $(".Button", b), l = $(".CreateBoardStatus", b); j.defaultValue("Create New Board"); k.click(function() { if (k.attr("disabled") == "disabled") return false; if (j.val() == "Create New Board") { l.html("Enter a board name").css("color", "red").show(); return false } l.html("").hide(); k.addClass("disabled").attr("disabled", "disabled"); $.post("/board/create/", { name: j.val(), pass_category: true }, function(r) { if (r && r.status == "success") { h.append("<li data='" + r.id + "'><span>" + $("<div/>").text(r.name).html() + "</span></li>"); f.hide(); d.text(r.name); j.val("").blur(); k.removeClass("disabled").removeAttr("disabled"); e && e(r.id) } else { l.html(r.message).css("color", "red").show(); k.removeClass("disabled").removeAttr("disabled") } }, "json"); return false }) } } } (); var CropImage = function() { this.initialize.apply(this, arguments) }; (function() { var b = Backbone.View.extend({ el: "#CropImage", events: { "click .cancel": "onClose", "click .save": "onSave", "mousedown .drag": "onStartDrag" }, dragging: false, mousePosition: {}, initialize: function() { _.bindAll(this, "onDragging", "onStopDragging", "onImageLoaded"); _.defaults(this.options, { title: "Crop Image", buttonTitle: "Save", size: { width: 222, height: 150 } }); this.$holder = this.$el.find(".holder"); this.$bg = this.$el.find(".holder .bg"); this.$overlay = this.$el.find(".holder .overlayContent"); this.$frame = this.$el.find(".holder .frame"); this.$mask = this.$el.find(".holder .mask"); this.$footer = this.$el.find(".footer"); this.$button = this.$el.find(".footer .Button.save"); this.$spinner = this.$el.find(".holder .spinner") }, render: function() { this.$el.find(".header span").text(this.options.title); this.$button.text(this.options.buttonTitle).removeClass("disabled"); this.$holder.show().css("height", this.options.size.height + 120 + 40); this.$footer.find(".buttons").css("visibility", "visible"); this.$footer.find(".complete").hide(); this.$bg.html("").show(); this.$spinner.hide(); this.options.className && this.$el.addClass(this.options.className); this.options.overlay && this.$overlay.html("").append(this.options.overlay); var c = this.bounds = { left: this.$holder.width() / 2 - this.options.size.width / 2, width: this.options.size.width, top: 60, height: this.options.size.height }; c.ratio = c.height / c.width; this.$frame.css(c); this.$mask.find("span").each(function(e, g) { e === 0 && $(g).css({ top: 0, left: 0, right: 0, height: c.top }); e === 1 && $(g).css({ top: c.top, left: c.left + c.width, right: 0, height: c.height }); e === 2 && $(g).css({ top: c.top + c.height, left: 0, right: 0, bottom: 0 }); e === 3 && $(g).css({ top: c.top, left: 0, width: c.left, height: c.height }) }); this.options.image && this.setImage(this.options.image) }, onClose: function() { this.trigger("close"); return false }, onSave: function() { this.trigger("save"); return false }, onImageLoaded: function(c) { if (this.$img.height() === 0) return setTimeout(this.onImageLoaded, 200, c); this.$img.removeAttr("width").removeAttr("height"); c = this.imageBounds = { originalWidth: this.$img.width(), originalHeight: this.$img.height() }; c.ratio = c.originalHeight / c.originalWidth; this.$img.css({ visibility: "visible", opacity: 1 }); this.fitImage(); this.centerImage(); this.hideSpinner() }, onStartDrag: function(c) { this.mousePosition = { x: c.pageX, y: c.pageY }; this.startPosition = { x: parseInt(this.$bg.css("left"), 10), y: parseInt(this.$bg.css("top"), 10) }; this.trigger("startDrag"); this.dragging = true; $("body").on({ mousemove: this.onDragging, mouseup: this.onStopDragging }); c.preventDefault() }, onDragging: function(c) { var e = { top: this.startPosition.y + (c.pageY - this.mousePosition.y), left: this.startPosition.x + (c.pageX - this.mousePosition.x) }; if (this.enforceBounds(e)) { this.$bg.css(e); c.preventDefault() } }, onStopDragging: function() { this.trigger("stopDrag"); this.dragging = false; $("body").off({ mousemove: this.onDragging, mouseup: this.onStopDragging }) }, enforceBounds: function(c) { c.top = Math.min(c.top, this.bounds.top); c.left = Math.min(c.left, this.bounds.left); if (c.left + this.imageBounds.width < this.bounds.left + this.bounds.width) c.left = this.bounds.left + this.bounds.width - this.imageBounds.width + 1; if (c.top + this.imageBounds.height < this.bounds.top + this.bounds.height) c.top = this.bounds.top + this.bounds.height - this.imageBounds.height + 1; return c }, showComplete: function() { this.$footer.find(".buttons").css("visibility", "hidden"); this.$footer.find(".complete").fadeIn(300); this.hideSpinner() }, setImage: function(c) { this.showSpinner(); var e = this.$img = $("<img>"); e.load(this.onImageLoaded).css({ opacity: "0.01", visibility: "hidden" }); e.attr("src", c); this.$bg.html(e) }, fitImage: function() { var c = 1; c = this.imageBounds.ratio >= this.bounds.ratio ? this.bounds.width / this.imageBounds.originalWidth: this.bounds.height / this.imageBounds.originalHeight; this.scaleImage(c, 10) }, centerImage: function() { var c = this.$holder.height() - 40, e = this.$holder.width(); this.$bg.css({ top: c / 2 - this.$bg.height() / 2 + 1, left: e / 2 - this.$bg.width() / 2 + 1 }) }, scaleImage: function(c, e) { var g = this.imageBounds.width = this.imageBounds.originalWidth * c + e || 0; c = this.imageBounds.height = this.imageBounds.originalHeight * c + e || 0; this.$img.attr("width", g); this.$img.attr("height", c) }, getOffset: function() { return { x: Math.abs(parseInt(this.$bg.css("left"), 10) - this.bounds.left), y: Math.abs(parseInt(this.$bg.css("top"), 10) - this.bounds.top) } }, getScale: function() { return this.$img.width() / this.imageBounds.originalWidth }, saving: function() { this.showSpinner(); this.$button.addClass("disabled") }, showSpinner: function() { this.$spinner.show() }, hideSpinner: function() { this.$spinner.hide() } }); CropImage.prototype = { initialize: function() { _.bindAll(this, "save", "close") }, show: function(c) { var e = this; c = this.view = new b(c); this.options = this.view.options; c.on("save", this.save); c.on("close", this.close); c.on("stopDrag", function() { e.trigger("dragComplete") }); Modal.show("CropImage"); c.render() }, setImage: function(c) { this.view.setImage(c) }, setParams: function(c) { this.options.params = c }, save: function() { var c = this, e = this.view.getOffset(), g = this.view.getScale(); e = _.extend({ x: e.x, y: e.y, width: this.options.size.width, height: this.options.size.height, scale: g }, this.options.params || {}); this.view.saving(); this.trigger("saving", e); $.ajax({ url: this.options.url, data: e, dataType: "json", type: "POST", success: function(f) { c.view.hideSpinner(); c.trigger("save", f); c.options.delay !== 0 && c.view.showComplete(); setTimeout(c.close, c.options.delay || 1200) } }) }, close: function() { Modal.close("CropImage"); this.view.undelegateEvents(); this.trigger("close"); delete this.view; delete this.options } }; _.extend(CropImage.prototype, Backbone.Events) })(); var BoardCoverSelector = function() { this.initialize.apply(this, arguments) }; (function() { var b = null; BoardCoverSelector.prototype = { pins: null, index: null, boardURL: null, initialize: function() { if (b) { b.cancel(); b = null } _.bindAll(this, "onKeyup", "onPinsLoaded", "onSave", "onSaving", "removeListeners", "next", "previous"); b = this; this.options = {}; this.imageCrop = new CropImage; this.imageCrop.on("close", this.removeListeners); this.imageCrop.on("save", this.onSave); this.imageCrop.on("saving", this.onSaving); this.imageCrop.on("dragComplete", function() { trackGAEvent("board_cover", "dragged") }); this.$img = $("<img>") }, loadPins: function() { $.ajax({ url: this.options.boardURL + "pins/", dataType: "json", success: this.onPinsLoaded }); this.boardURL = this.options.boardURL }, show: function(c) { this.options = c; this.imageCrop.show({ className: "BoardCover", overlay: this.overlayContent(), params: { pin: c.pin }, image: this.options.image, size: { width: 222, height: 150 }, title: c.title || "Select a cover photo and drag to position it.", buttonTitle: c.buttonTitle || "Set Cover", url: this.options.boardURL + "cover/", delay: c.delay }); if (!this.pins || this.boardURL != this.options.boardURL) this.loadPins(); else this.options.image || this.setIndex(0); trackGAEvent("board_cover", "show"); $("body").keyup(this.onKeyup) }, onPinsLoaded: function(c) { var e = null; if (this.options.image) { var g = this.options.image; _.each(c.pins, function(f, d) { if (e == null && g.match(new RegExp(f.image_key, "gi"))) e = d }) } this.index = e || 0; this.pins = c.pins; if (this.pins.length !== 0) { this.pins.length === 1 ? this.hideArrows() : this.preload([e - 1, e + 1]); e === null && this.setIndex(0) } }, onKeyup: function(c) { if (this.index !== null) { c.keyCode === 37 && this.previous(); c.keyCode === 39 && this.next(); c.keyCode === 27 && this.imageCrop.close(); c.keyCode === 13 && this.imageCrop.save() } }, overlayContent: function() { var c = this.$holder = $("<div class='BoardOverlay'></div>"), e = $('<button class="prev Button WhiteButton Button13" type="button"><em></em></button>').click(this.previous), g = $('<button class="next Button WhiteButton Button13" type="button"><em></em></button>').click(this.next); c.append("<h3 class='serif'>" + this.options.boardName + "</h3>"); c.append(e, g); return c }, next: function() { this.index === this.pins.length - 1 ? this.setIndex(0) : this.setIndex(this.index + 1); trackGAEvent("board_cover", "toggle_pin"); return false }, previous: function() { this.index === 0 ? this.setIndex(this.pins.length - 1) : this.setIndex(this.index - 1); trackGAEvent("board_cover", "toggle_pin"); return false }, setIndex: function(c) { var e = this.pins[c]; if (e) { this.imageCrop.setImage(e.url); this.imageCrop.setParams({ pin: e.id }); this.index = c; this.preload([this.index - 2, this.index - 1, this.index + 1, this.index + 2]) } }, preload: function(c) { var e = this; _.each(c, function(g) { if (g = e.pins[g])(new Image).src = g.url }) }, hideArrows: function() { this.$holder.find(".arrow").hide() }, removeListeners: function() { $("body").unbind("keyup", this.onKeyup) }, onSaving: function() { this.hideArrows() }, onSave: function(c) { this.options.success && this.options.success(c); trackGAEvent("board_cover", "saved") } }; _.extend(BoardCoverSelector.prototype, Backbone.Events) })(); var AddDialog = function() { return { setup: function(b) { var c = "#" + b, e = $(c), g = $(".Buttons .RedButton", e), f = $(".mainerror", e), d = $(".DescriptionTextarea", e); BoardPicker.setup(c + " .BoardPicker", function(h) { $(c + " #id_board").val(h) }, function(h) { $(c + " #id_board").val(h) }); AddDialog.shareCheckboxes(b); Tagging.initTextarea(c + " .DescriptionTextarea"); Tagging.priceTag(c + " .DescriptionTextarea", c + " .ImagePicker"); CharacterCount.setup(c + " .DescriptionTextarea", c + " .CharacterCount", c + " .Button"); g.click(function() { if (g.hasClass("disabled")) return false; trackGAEvent("pin", "clicked", "add_dialogue"); if (d.val() === "" || d.val() === "Describe your pin...") { f.html("Please describe your pin").slideDown(300); return false } else f.slideUp(300, function() { f.html("") }); g.addClass("disabled").html("Pinning..."); $("#id_details", e).val(d.val()); Tagging.loadTags(c + " .DescriptionTextarea", c + " #peeps_holder", c + " #id_tags", c + " #currency_holder"); $("form", e).ajaxSubmit({ url: "/pin/create/", type: "POST", dataType: "json", iframe: true, success: function(h) { if (h.status == "success") { trackGAEvent("pin", "success", "add_dialogue"); window.location = h.url } else if (h.captcha) { RecaptchaDialog.challenge(); AddDialog.reset(b) } else f.html(h.message).slideDown(300) } }); return false }) }, reset: function(b) { b === "CreateBoard" && CreateBoardDialog.reset(); b === "ScrapePin" && ScrapePinDialog.reset(); b === "UploadPin" && UploadPinDialog.reset(); AddDialog._resets[b] && AddDialog._resets[b]() }, close: function(b, c) { $("#" + b).addClass("super"); Modal.show(c) }, childClose: function(b, c) { var e = this, g = $("#" + c); $(".ModalContainer", g); e.reset(c); $("#" + b).removeClass("super"); Modal.close(b); Modal.close(c) }, pinBottom: function(b) { var c = $("#" + b); $(".PinBottom", c).slideDown(300, function() { var e = $(".modal:first", c);
arashstar1 / Bot LuaCode Issues 0 Pull requests 0 Pulse MaTaDoR/ 3233fdf V 5.7 MaTaDoR @MaTaDoRTeaMMaTaDoRTeaM committed on GitHub about 1 month ago 2 changed files 2,704 additions and 0 deletions cli/tg/tdcli.lua @@ -0,0 +1,2704 @@ +--[[ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + +]]-- + +-- Vector example form is like this: {[0] = v} or {v1, v2, v3, [0] = v} +-- If false or true crashed your telegram-cli, try to change true to 1 and false to 0 + +-- Main Bot Framework +local M = {} + +-- @chat_id = user, group, channel, and broadcast +-- @group_id = normal group +-- @channel_id = channel and broadcast +local function getChatId(chat_id) + local chat = {} + local chat_id = tostring(chat_id) + + if chat_id:match('^-100') then + local channel_id = chat_id:gsub('-100', '') + chat = {ID = channel_id, type = 'channel'} + else + local group_id = chat_id:gsub('-', '') + chat = {ID = group_id, type = 'group'} + end + + return chat +end + +local function getInputFile(file) + if file:match('/') then + infile = {ID = "InputFileLocal", path_ = file} + elseif file:match('^%d+$') then + infile = {ID = "InputFileId", id_ = file} + else + infile = {ID = "InputFilePersistentId", persistent_id_ = file} + end + + return infile +end + +-- User can send bold, italic, and monospace text uses HTML or Markdown format. +local function getParseMode(parse_mode) + if parse_mode then + local mode = parse_mode:lower() + + if mode == 'markdown' or mode == 'md' then + P = {ID = "TextParseModeMarkdown"} + elseif mode == 'html' then + P = {ID = "TextParseModeHTML"} + end + end + + return P +end + +-- Returns current authorization state, offline request +local function getAuthState(dl_cb, cmd) + tdcli_function ({ + ID = "GetAuthState", + }, dl_cb, cmd) +end + +M.getAuthState = getAuthState + +-- Sets user's phone number and sends authentication code to the user. +-- Works only when authGetState returns authStateWaitPhoneNumber. +-- If phone number is not recognized or another error has happened, returns an error. Otherwise returns authStateWaitCode +-- @phone_number User's phone number in any reasonable format +-- @allow_flash_call Pass True, if code can be sent via flash call to the specified phone number +-- @is_current_phone_number Pass true, if the phone number is used on the current device. Ignored if allow_flash_call is False +local function setAuthPhoneNumber(phone_number, allow_flash_call, is_current_phone_number, dl_cb, cmd) + tdcli_function ({ + ID = "SetAuthPhoneNumber", + phone_number_ = phone_number, + allow_flash_call_ = allow_flash_call, + is_current_phone_number_ = is_current_phone_number + }, dl_cb, cmd) +end + +M.setAuthPhoneNumber = setAuthPhoneNumber + +-- Resends authentication code to the user. +-- Works only when authGetState returns authStateWaitCode and next_code_type of result is not null. +-- Returns authStateWaitCode on success +local function resendAuthCode(dl_cb, cmd) + tdcli_function ({ + ID = "ResendAuthCode", + }, dl_cb, cmd) +end + +M.resendAuthCode = resendAuthCode + +-- Checks authentication code. +-- Works only when authGetState returns authStateWaitCode. +-- Returns authStateWaitPassword or authStateOk on success +-- @code Verification code from SMS, Telegram message, voice call or flash call +-- @first_name User first name, if user is yet not registered, 1-255 characters +-- @last_name Optional user last name, if user is yet not registered, 0-255 characters +local function checkAuthCode(code, first_name, last_name, dl_cb, cmd) + tdcli_function ({ + ID = "CheckAuthCode", + code_ = code, + first_name_ = first_name, + last_name_ = last_name + }, dl_cb, cmd) +end + +M.checkAuthCode = checkAuthCode + +-- Checks password for correctness. +-- Works only when authGetState returns authStateWaitPassword. +-- Returns authStateOk on success +-- @password Password to check +local function checkAuthPassword(password, dl_cb, cmd) + tdcli_function ({ + ID = "CheckAuthPassword", + password_ = password + }, dl_cb, cmd) +end + +M.checkAuthPassword = checkAuthPassword + +-- Requests to send password recovery code to email. +-- Works only when authGetState returns authStateWaitPassword. +-- Returns authStateWaitPassword on success +local function requestAuthPasswordRecovery(dl_cb, cmd) + tdcli_function ({ + ID = "RequestAuthPasswordRecovery", + }, dl_cb, cmd) +end + +M.requestAuthPasswordRecovery = requestAuthPasswordRecovery + +-- Recovers password with recovery code sent to email. +-- Works only when authGetState returns authStateWaitPassword. +-- Returns authStateOk on success +-- @recovery_code Recovery code to check +local function recoverAuthPassword(recovery_code, dl_cb, cmd) + tdcli_function ({ + ID = "RecoverAuthPassword", + recovery_code_ = recovery_code + }, dl_cb, cmd) +end + +M.recoverAuthPassword = recoverAuthPassword + +-- Logs out user. +-- If force == false, begins to perform soft log out, returns authStateLoggingOut after completion. +-- If force == true then succeeds almost immediately without cleaning anything at the server, but returns error with code 401 and description "Unauthorized" +-- @force If true, just delete all local data. Session will remain in list of active sessions +local function resetAuth(force, dl_cb, cmd) + tdcli_function ({ + ID = "ResetAuth", + force_ = force or nil + }, dl_cb, cmd) +end + +M.resetAuth = resetAuth + +-- Check bot's authentication token to log in as a bot. +-- Works only when authGetState returns authStateWaitPhoneNumber. +-- Can be used instead of setAuthPhoneNumber and checkAuthCode to log in. +-- Returns authStateOk on success +-- @token Bot token +local function checkAuthBotToken(token, dl_cb, cmd) + tdcli_function ({ + ID = "CheckAuthBotToken", + token_ = token + }, dl_cb, cmd) +end + +M.checkAuthBotToken = checkAuthBotToken + +-- Returns current state of two-step verification +local function getPasswordState(dl_cb, cmd) + tdcli_function ({ + ID = "GetPasswordState", + }, dl_cb, cmd) +end + +M.getPasswordState = getPasswordState + +-- Changes user password. +-- If new recovery email is specified, then error EMAIL_UNCONFIRMED is returned and password change will not be applied until email confirmation. +-- Application should call getPasswordState from time to time to check if email is already confirmed +-- @old_password Old user password +-- @new_password New user password, may be empty to remove the password +-- @new_hint New password hint, can be empty +-- @set_recovery_email Pass True, if recovery email should be changed +-- @new_recovery_email New recovery email, may be empty +local function setPassword(old_password, new_password, new_hint, set_recovery_email, new_recovery_email, dl_cb, cmd) + tdcli_function ({ + ID = "SetPassword", + old_password_ = old_password, + new_password_ = new_password, + new_hint_ = new_hint, + set_recovery_email_ = set_recovery_email, + new_recovery_email_ = new_recovery_email + }, dl_cb, cmd) +end + +M.setPassword = setPassword + +-- Returns set up recovery email. +-- This method can be used to verify a password provided by the user +-- @password Current user password +local function getRecoveryEmail(password, dl_cb, cmd) + tdcli_function ({ + ID = "GetRecoveryEmail", + password_ = password + }, dl_cb, cmd) +end + +M.getRecoveryEmail = getRecoveryEmail + +-- Changes user recovery email. +-- If new recovery email is specified, then error EMAIL_UNCONFIRMED is returned and email will not be changed until email confirmation. +-- Application should call getPasswordState from time to time to check if email is already confirmed. +-- If new_recovery_email coincides with the current set up email succeeds immediately and aborts all other requests waiting for email confirmation +-- @password Current user password +-- @new_recovery_email New recovery email +local function setRecoveryEmail(password, new_recovery_email, dl_cb, cmd) + tdcli_function ({ + ID = "SetRecoveryEmail", + password_ = password, + new_recovery_email_ = new_recovery_email + }, dl_cb, cmd) +end + +M.setRecoveryEmail = setRecoveryEmail + +-- Requests to send password recovery code to email +local function requestPasswordRecovery(dl_cb, cmd) + tdcli_function ({ + ID = "RequestPasswordRecovery", + }, dl_cb, cmd) +end + +M.requestPasswordRecovery = requestPasswordRecovery + +-- Recovers password with recovery code sent to email +-- @recovery_code Recovery code to check +local function recoverPassword(recovery_code, dl_cb, cmd) + tdcli_function ({ + ID = "RecoverPassword", + recovery_code_ = tostring(recovery_code) + }, dl_cb, cmd) +end + +M.recoverPassword = recoverPassword + +-- Returns current logged in user +local function getMe(dl_cb, cmd) + tdcli_function ({ + ID = "GetMe", + }, dl_cb, cmd) +end + +M.getMe = getMe + +-- Returns information about a user by its identifier, offline request if current user is not a bot +-- @user_id User identifier +local function getUser(user_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetUser", + user_id_ = user_id + }, dl_cb, cmd) +end + +M.getUser = getUser + +-- Returns full information about a user by its identifier +-- @user_id User identifier +local function getUserFull(user_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetUserFull", + user_id_ = user_id + }, dl_cb, cmd) +end + +M.getUserFull = getUserFull + +-- Returns information about a group by its identifier, offline request if current user is not a bot +-- @group_id Group identifier +local function getGroup(group_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetGroup", + group_id_ = getChatId(group_id).ID + }, dl_cb, cmd) +end + +M.getGroup = getGroup + +-- Returns full information about a group by its identifier +-- @group_id Group identifier +local function getGroupFull(group_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetGroupFull", + group_id_ = getChatId(group_id).ID + }, dl_cb, cmd) +end + +M.getGroupFull = getGroupFull + +-- Returns information about a channel by its identifier, offline request if current user is not a bot +-- @channel_id Channel identifier +local function getChannel(channel_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetChannel", + channel_id_ = getChatId(channel_id).ID + }, dl_cb, cmd) +end + +M.getChannel = getChannel + +-- Returns full information about a channel by its identifier, cached for at most 1 minute +-- @channel_id Channel identifier +local function getChannelFull(channel_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetChannelFull", + channel_id_ = getChatId(channel_id).ID + }, dl_cb, cmd) +end + +M.getChannelFull = getChannelFull + +-- Returns information about a secret chat by its identifier, offline request +-- @secret_chat_id Secret chat identifier +local function getSecretChat(secret_chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetSecretChat", + secret_chat_id_ = secret_chat_id + }, dl_cb, cmd) +end + +M.getSecretChat = getSecretChat + +-- Returns information about a chat by its identifier, offline request if current user is not a bot +-- @chat_id Chat identifier +local function getChat(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetChat", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.getChat = getChat + +-- Returns information about a message +-- @chat_id Identifier of the chat, message belongs to +-- @message_id Identifier of the message to get +local function getMessage(chat_id, message_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetMessage", + chat_id_ = chat_id, + message_id_ = message_id + }, dl_cb, cmd) +end + +M.getMessage = getMessage + +-- Returns information about messages. +-- If message is not found, returns null on the corresponding position of the result +-- @chat_id Identifier of the chat, messages belongs to +-- @message_ids Identifiers of the messages to get +local function getMessages(chat_id, message_ids, dl_cb, cmd) + tdcli_function ({ + ID = "GetMessages", + chat_id_ = chat_id, + message_ids_ = message_ids -- vector + }, dl_cb, cmd) +end + +M.getMessages = getMessages + +-- Returns information about a file, offline request +-- @file_id Identifier of the file to get +local function getFile(file_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetFile", + file_id_ = file_id + }, dl_cb, cmd) +end + +M.getFile = getFile + +-- Returns information about a file by its persistent id, offline request +-- @persistent_file_id Persistent identifier of the file to get +local function getFilePersistent(persistent_file_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetFilePersistent", + persistent_file_id_ = persistent_file_id + }, dl_cb, cmd) +end + +M.getFilePersistent = getFilePersistent + +-- Returns list of chats in the right order, chats are sorted by (order, chat_id) in decreasing order. +-- For example, to get list of chats from the beginning, the offset_order should be equal 2^63 - 1 +-- @offset_order Chat order to return chats from +-- @offset_chat_id Chat identifier to return chats from +-- @limit Maximum number of chats to be returned +local function getChats(offset_order, offset_chat_id, limit, dl_cb, cmd) + if not limit or limit > 20 then + limit = 20 + end + + tdcli_function ({ + ID = "GetChats", + offset_order_ = offset_order or 9223372036854775807, + offset_chat_id_ = offset_chat_id or 0, + limit_ = limit + }, dl_cb, cmd) +end + +M.getChats = getChats + +-- Searches public chat by its username. +-- Currently only private and channel chats can be public. +-- Returns chat if found, otherwise some error is returned +-- @username Username to be resolved +local function searchPublicChat(username, dl_cb, cmd) + tdcli_function ({ + ID = "SearchPublicChat", + username_ = username + }, dl_cb, cmd) +end + +M.searchPublicChat = searchPublicChat + +-- Searches public chats by prefix of their username. +-- Currently only private and channel (including supergroup) chats can be public. +-- Returns meaningful number of results. +-- Returns nothing if length of the searched username prefix is less than 5. +-- Excludes private chats with contacts from the results +-- @username_prefix Prefix of the username to search +local function searchPublicChats(username_prefix, dl_cb, cmd) + tdcli_function ({ + ID = "SearchPublicChats", + username_prefix_ = username_prefix + }, dl_cb, cmd) +end + +M.searchPublicChats = searchPublicChats + +-- Searches for specified query in the title and username of known chats, offline request. +-- Returns chats in the order of them in the chat list +-- @query Query to search for, if query is empty, returns up to 20 recently found chats +-- @limit Maximum number of chats to be returned +local function searchChats(query, limit, dl_cb, cmd) + if not limit or limit > 20 then + limit = 20 + end + + tdcli_function ({ + ID = "SearchChats", + query_ = query, + limit_ = limit + }, dl_cb, cmd) +end + +M.searchChats = searchChats + +-- Adds chat to the list of recently found chats. +-- The chat is added to the beginning of the list. +-- If the chat is already in the list, at first it is removed from the list +-- @chat_id Identifier of the chat to add +local function addRecentlyFoundChat(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "AddRecentlyFoundChat", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.addRecentlyFoundChat = addRecentlyFoundChat + +-- Deletes chat from the list of recently found chats +-- @chat_id Identifier of the chat to delete +local function deleteRecentlyFoundChat(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteRecentlyFoundChat", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.deleteRecentlyFoundChat = deleteRecentlyFoundChat + +-- Clears list of recently found chats +local function deleteRecentlyFoundChats(dl_cb, cmd) + tdcli_function ({ + ID = "DeleteRecentlyFoundChats", + }, dl_cb, cmd) +end + +M.deleteRecentlyFoundChats = deleteRecentlyFoundChats + +-- Returns list of common chats with an other given user. +-- Chats are sorted by their type and creation date +-- @user_id User identifier +-- @offset_chat_id Chat identifier to return chats from, use 0 for the first request +-- @limit Maximum number of chats to be returned, up to 100 +local function getCommonChats(user_id, offset_chat_id, limit, dl_cb, cmd) + if not limit or limit > 100 then + limit = 100 + end + + tdcli_function ({ + ID = "GetCommonChats", + user_id_ = user_id, + offset_chat_id_ = offset_chat_id, + limit_ = limit + }, dl_cb, cmd) +end + +M.getCommonChats = getCommonChats + +-- Returns messages in a chat. +-- Automatically calls openChat. +-- Returns result in reverse chronological order, i.e. in order of decreasing message.message_id +-- @chat_id Chat identifier +-- @from_message_id Identifier of the message near which we need a history, you can use 0 to get results from the beginning, i.e. from oldest to newest +-- @offset Specify 0 to get results exactly from from_message_id or negative offset to get specified message and some newer messages +-- @limit Maximum number of messages to be returned, should be positive and can't be greater than 100. +-- If offset is negative, limit must be greater than -offset. +-- There may be less than limit messages returned even the end of the history is not reached +local function getChatHistory(chat_id, from_message_id, offset, limit, dl_cb, cmd) + if not limit or limit > 100 then + limit = 100 + end + + tdcli_function ({ + ID = "GetChatHistory", + chat_id_ = chat_id, + from_message_id_ = from_message_id, + offset_ = offset or 0, + limit_ = limit + }, dl_cb, cmd) +end + +M.getChatHistory = getChatHistory + +-- Deletes all messages in the chat. +-- Can't be used for channel chats +-- @chat_id Chat identifier +-- @remove_from_chat_list Pass true, if chat should be removed from the chat list +local function deleteChatHistory(chat_id, remove_from_chat_list, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteChatHistory", + chat_id_ = chat_id, + remove_from_chat_list_ = remove_from_chat_list + }, dl_cb, cmd) +end + +M.deleteChatHistory = deleteChatHistory + +-- Searches for messages with given words in the chat. +-- Returns result in reverse chronological order, i. e. in order of decreasimg message_id. +-- Doesn't work in secret chats +-- @chat_id Chat identifier to search in +-- @query Query to search for +-- @from_message_id Identifier of the message from which we need a history, you can use 0 to get results from beginning +-- @limit Maximum number of messages to be returned, can't be greater than 100 +-- @filter Filter for content of searched messages +-- filter = Empty|Animation|Audio|Document|Photo|Video|Voice|PhotoAndVideo|Url|ChatPhoto +local function searchChatMessages(chat_id, query, from_message_id, limit, filter, dl_cb, cmd) + if not limit or limit > 100 then + limit = 100 + end + + tdcli_function ({ + ID = "SearchChatMessages", + chat_id_ = chat_id, + query_ = query, + from_message_id_ = from_message_id, + limit_ = limit, + filter_ = { + ID = 'SearchMessagesFilter' .. filter + }, + }, dl_cb, cmd) +end + +M.searchChatMessages = searchChatMessages + +-- Searches for messages in all chats except secret chats. Returns result in reverse chronological order, i. e. in order of decreasing (date, chat_id, message_id) +-- @query Query to search for +-- @offset_date Date of the message to search from, you can use 0 or any date in the future to get results from the beginning +-- @offset_chat_id Chat identifier of the last found message or 0 for the first request +-- @offset_message_id Message identifier of the last found message or 0 for the first request +-- @limit Maximum number of messages to be returned, can't be greater than 100 +local function searchMessages(query, offset_date, offset_chat_id, offset_message_id, limit, dl_cb, cmd) + if not limit or limit > 100 then + limit = 100 + end + + tdcli_function ({ + ID = "SearchMessages", + query_ = query, + offset_date_ = offset_date, + offset_chat_id_ = offset_chat_id, + offset_message_id_ = offset_message_id, + limit_ = limit + }, dl_cb, cmd) +end + +M.searchMessages = searchMessages + +-- Invites bot to a chat (if it is not in the chat) and send /start to it. +-- Bot can't be invited to a private chat other than chat with the bot. +-- Bots can't be invited to broadcast channel chats and secret chats. +-- Returns sent message. +-- UpdateChatTopMessage will not be sent, so returned message should be used to update chat top message +-- @bot_user_id Identifier of the bot +-- @chat_id Identifier of the chat +-- @parameter Hidden parameter sent to bot for deep linking (https://api.telegram.org/bots#deep-linking) +-- parameter=start|startgroup or custom as defined by bot creator +local function sendBotStartMessage(bot_user_id, chat_id, parameter, dl_cb, cmd) + tdcli_function ({ + ID = "SendBotStartMessage", + bot_user_id_ = bot_user_id, + chat_id_ = chat_id, + parameter_ = parameter + }, dl_cb, cmd) +end + +M.sendBotStartMessage = sendBotStartMessage + +-- Sends result of the inline query as a message. +-- Returns sent message. +-- UpdateChatTopMessage will not be sent, so returned message should be used to update chat top message. +-- Always clears chat draft message +-- @chat_id Chat to send message +-- @reply_to_message_id Identifier of a message to reply to or 0 +-- @disable_notification Pass true, to disable notification about the message, doesn't works in secret chats +-- @from_background Pass true, if the message is sent from background +-- @query_id Identifier of the inline query +-- @result_id Identifier of the inline result +local function sendInlineQueryResultMessage(chat_id, reply_to_message_id, disable_notification, from_background, query_id, result_id, dl_cb, cmd) + tdcli_function ({ + ID = "SendInlineQueryResultMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + query_id_ = query_id, + result_id_ = result_id + }, dl_cb, cmd) +end + +M.sendInlineQueryResultMessage = sendInlineQueryResultMessage + +-- Forwards previously sent messages. +-- Returns forwarded messages in the same order as message identifiers passed in message_ids. +-- If message can't be forwarded, null will be returned instead of the message. +-- UpdateChatTopMessage will not be sent, so returned messages should be used to update chat top message +-- @chat_id Identifier of a chat to forward messages +-- @from_chat_id Identifier of a chat to forward from +-- @message_ids Identifiers of messages to forward +-- @disable_notification Pass true, to disable notification about the message, doesn't works if messages are forwarded to secret chat +-- @from_background Pass true, if the message is sent from background +local function forwardMessages(chat_id, from_chat_id, message_ids, disable_notification, dl_cb, cmd) + tdcli_function ({ + ID = "ForwardMessages", + chat_id_ = chat_id, + from_chat_id_ = from_chat_id, + message_ids_ = message_ids, -- vector + disable_notification_ = disable_notification, + from_background_ = 1 + }, dl_cb, cmd) +end + +M.forwardMessages = forwardMessages + +-- Changes current ttl setting in a secret chat and sends corresponding message +-- @chat_id Chat identifier +-- @ttl New value of ttl in seconds +local function sendChatSetTtlMessage(chat_id, ttl, dl_cb, cmd) + tdcli_function ({ + ID = "SendChatSetTtlMessage", + chat_id_ = chat_id, + ttl_ = ttl + }, dl_cb, cmd) +end + +M.sendChatSetTtlMessage = sendChatSetTtlMessage + +-- Deletes messages. +-- UpdateDeleteMessages will not be sent for messages deleted through that function +-- @chat_id Chat identifier +-- @message_ids Identifiers of messages to delete +local function deleteMessages(chat_id, message_ids, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteMessages", + chat_id_ = chat_id, + message_ids_ = message_ids -- vector + }, dl_cb, cmd) +end + +M.deleteMessages = deleteMessages + +-- Deletes all messages in the chat sent by the specified user. +-- Works only in supergroup channel chats, needs appropriate privileges +-- @chat_id Chat identifier +-- @user_id User identifier +local function deleteMessagesFromUser(chat_id, user_id, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteMessagesFromUser", + chat_id_ = chat_id, + user_id_ = user_id + }, dl_cb, cmd) +end + +M.deleteMessagesFromUser = deleteMessagesFromUser + +-- Edits text of text or game message. +-- Non-bots can edit message in a limited period of time. +-- Returns edited message after edit is complete server side +-- @chat_id Chat the message belongs to +-- @message_id Identifier of the message +-- @reply_markup Bots only. New message reply markup +-- @input_message_content New text content of the message. Should be of type InputMessageText +local function editMessageText(chat_id, message_id, reply_markup, text, disable_web_page_preview, parse_mode, dl_cb, cmd) + local TextParseMode = getParseMode(parse_mode) + + tdcli_function ({ + ID = "EditMessageText", + chat_id_ = chat_id, + message_id_ = message_id, + reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup + input_message_content_ = { + ID = "InputMessageText", + text_ = text, + disable_web_page_preview_ = disable_web_page_preview, + clear_draft_ = 0, + entities_ = {}, + parse_mode_ = TextParseMode, + }, + }, dl_cb, cmd) +end + +M.editMessageText = editMessageText + +-- Edits message content caption. +-- Non-bots can edit message in a limited period of time. +-- Returns edited message after edit is complete server side +-- @chat_id Chat the message belongs to +-- @message_id Identifier of the message +-- @reply_markup Bots only. New message reply markup +-- @caption New message content caption, 0-200 characters +local function editMessageCaption(chat_id, message_id, reply_markup, caption, dl_cb, cmd) + tdcli_function ({ + ID = "EditMessageCaption", + chat_id_ = chat_id, + message_id_ = message_id, + reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup + caption_ = caption + }, dl_cb, cmd) +end + +M.editMessageCaption = editMessageCaption + +-- Bots only. +-- Edits message reply markup. +-- Returns edited message after edit is complete server side +-- @chat_id Chat the message belongs to +-- @message_id Identifier of the message +-- @reply_markup New message reply markup +local function editMessageReplyMarkup(inline_message_id, reply_markup, caption, dl_cb, cmd) + tdcli_function ({ + ID = "EditInlineMessageCaption", + inline_message_id_ = inline_message_id, + reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup + caption_ = caption + }, dl_cb, cmd) +end + +M.editMessageReplyMarkup = editMessageReplyMarkup + +-- Bots only. +-- Edits text of an inline text or game message sent via bot +-- @inline_message_id Inline message identifier +-- @reply_markup New message reply markup +-- @input_message_content New text content of the message. Should be of type InputMessageText +local function editInlineMessageText(inline_message_id, reply_markup, text, disable_web_page_preview, dl_cb, cmd) + tdcli_function ({ + ID = "EditInlineMessageText", + inline_message_id_ = inline_message_id, + reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup + input_message_content_ = { + ID = "InputMessageText", + text_ = text, + disable_web_page_preview_ = disable_web_page_preview, + clear_draft_ = 0, + entities_ = {} + }, + }, dl_cb, cmd) +end + +M.editInlineMessageText = editInlineMessageText + +-- Bots only. +-- Edits caption of an inline message content sent via bot +-- @inline_message_id Inline message identifier +-- @reply_markup New message reply markup +-- @caption New message content caption, 0-200 characters +local function editInlineMessageCaption(inline_message_id, reply_markup, caption, dl_cb, cmd) + tdcli_function ({ + ID = "EditInlineMessageCaption", + inline_message_id_ = inline_message_id, + reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup + caption_ = caption + }, dl_cb, cmd) +end + +M.editInlineMessageCaption = editInlineMessageCaption + +-- Bots only. +-- Edits reply markup of an inline message sent via bot +-- @inline_message_id Inline message identifier +-- @reply_markup New message reply markup +local function editInlineMessageReplyMarkup(inline_message_id, reply_markup, dl_cb, cmd) + tdcli_function ({ + ID = "EditInlineMessageReplyMarkup", + inline_message_id_ = inline_message_id, + reply_markup_ = reply_markup -- reply_markup:ReplyMarkup + }, dl_cb, cmd) +end + +M.editInlineMessageReplyMarkup = editInlineMessageReplyMarkup + + +-- Sends inline query to a bot and returns its results. +-- Unavailable for bots +-- @bot_user_id Identifier of the bot send query to +-- @chat_id Identifier of the chat, where the query is sent +-- @user_location User location, only if needed +-- @query Text of the query +-- @offset Offset of the first entry to return +local function getInlineQueryResults(bot_user_id, chat_id, latitude, longitude, query, offset, dl_cb, cmd) + tdcli_function ({ + ID = "GetInlineQueryResults", + bot_user_id_ = bot_user_id, + chat_id_ = chat_id, + user_location_ = { + ID = "Location", + latitude_ = latitude, + longitude_ = longitude + }, + query_ = query, + offset_ = offset + }, dl_cb, cmd) +end + +M.getInlineQueryResults = getInlineQueryResults + +-- Bots only. +-- Sets result of the inline query +-- @inline_query_id Identifier of the inline query +-- @is_personal Does result of the query can be cached only for specified user +-- @results Results of the query +-- @cache_time Allowed time to cache results of the query in seconds +-- @next_offset Offset for the next inline query, pass empty string if there is no more results +-- @switch_pm_text If non-empty, this text should be shown on the button, which opens private chat with the bot and sends bot start message with parameter switch_pm_parameter +-- @switch_pm_parameter Parameter for the bot start message +local function answerInlineQuery(inline_query_id, is_personal, cache_time, next_offset, switch_pm_text, switch_pm_parameter, dl_cb, cmd) + tdcli_function ({ + ID = "AnswerInlineQuery", + inline_query_id_ = inline_query_id, + is_personal_ = is_personal, + results_ = results, --vector<InputInlineQueryResult>, + cache_time_ = cache_time, + next_offset_ = next_offset, + switch_pm_text_ = switch_pm_text, + switch_pm_parameter_ = switch_pm_parameter + }, dl_cb, cmd) +end + +M.answerInlineQuery = answerInlineQuery + +-- Sends callback query to a bot and returns answer to it. +-- Unavailable for bots +-- @chat_id Identifier of the chat with a message +-- @message_id Identifier of the message, from which the query is originated +-- @payload Query payload +-- @text Text of the answer +-- @show_alert If true, an alert should be shown to the user instead of a toast +-- @url URL to be open +local function getCallbackQueryAnswer(chat_id, message_id, text, show_alert, url, dl_cb, cmd) + tdcli_function ({ + ID = "GetCallbackQueryAnswer", + chat_id_ = chat_id, + message_id_ = message_id, + payload_ = { + ID = "CallbackQueryAnswer", + text_ = text, + show_alert_ = show_alert, + url_ = url + }, + }, dl_cb, cmd) +end + +M.getCallbackQueryAnswer = getCallbackQueryAnswer + +-- Bots only. +-- Sets result of the callback query +-- @callback_query_id Identifier of the callback query +-- @text Text of the answer +-- @show_alert If true, an alert should be shown to the user instead of a toast +-- @url Url to be opened +-- @cache_time Allowed time to cache result of the query in seconds +local function answerCallbackQuery(callback_query_id, text, show_alert, url, cache_time, dl_cb, cmd) + tdcli_function ({ + ID = "AnswerCallbackQuery", + callback_query_id_ = callback_query_id, + text_ = text, + show_alert_ = show_alert, + url_ = url, + cache_time_ = cache_time + }, dl_cb, cmd) +end + +M.answerCallbackQuery = answerCallbackQuery + +-- Bots only. +-- Updates game score of the specified user in the game +-- @chat_id Chat a message with the game belongs to +-- @message_id Identifier of the message +-- @edit_message True, if message should be edited +-- @user_id User identifier +-- @score New score +-- @force Pass True to update the score even if it decreases. If score is 0, user will be deleted from the high scores table +local function setGameScore(chat_id, message_id, edit_message, user_id, score, force, dl_cb, cmd) + tdcli_function ({ + ID = "SetGameScore", + chat_id_ = chat_id, + message_id_ = message_id, + edit_message_ = edit_message, + user_id_ = user_id, + score_ = score, + force_ = force + }, dl_cb, cmd) +end + +M.setGameScore = setGameScore + +-- Bots only. +-- Updates game score of the specified user in the game +-- @inline_message_id Inline message identifier +-- @edit_message True, if message should be edited +-- @user_id User identifier +-- @score New score +-- @force Pass True to update the score even if it decreases. If score is 0, user will be deleted from the high scores table +local function setInlineGameScore(inline_message_id, edit_message, user_id, score, force, dl_cb, cmd) + tdcli_function ({ + ID = "SetInlineGameScore", + inline_message_id_ = inline_message_id, + edit_message_ = edit_message, + user_id_ = user_id, + score_ = score, + force_ = force + }, dl_cb, cmd) +end + +M.setInlineGameScore = setInlineGameScore + +-- Bots only. +-- Returns game high scores and some part of the score table around of the specified user in the game +-- @chat_id Chat a message with the game belongs to +-- @message_id Identifier of the message +-- @user_id User identifie +local function getGameHighScores(chat_id, message_id, user_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetGameHighScores", + chat_id_ = chat_id, + message_id_ = message_id, + user_id_ = user_id + }, dl_cb, cmd) +end + +M.getGameHighScores = getGameHighScores + +-- Bots only. +-- Returns game high scores and some part of the score table around of the specified user in the game +-- @inline_message_id Inline message identifier +-- @user_id User identifier +local function getInlineGameHighScores(inline_message_id, user_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetInlineGameHighScores", + inline_message_id_ = inline_message_id, + user_id_ = user_id + }, dl_cb, cmd) +end + +M.getInlineGameHighScores = getInlineGameHighScores + +-- Deletes default reply markup from chat. +-- This method needs to be called after one-time keyboard or ForceReply reply markup has been used. +-- UpdateChatReplyMarkup will be send if reply markup will be changed +-- @chat_id Chat identifier +-- @message_id Message identifier of used keyboard +local function deleteChatReplyMarkup(chat_id, message_id, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteChatReplyMarkup", + chat_id_ = chat_id, + message_id_ = message_id + }, dl_cb, cmd) +end + +M.deleteChatReplyMarkup = deleteChatReplyMarkup + +-- Sends notification about user activity in a chat +-- @chat_id Chat identifier +-- @action Action description +-- action = Typing|Cancel|RecordVideo|UploadVideo|RecordVoice|UploadVoice|UploadPhoto|UploadDocument|GeoLocation|ChooseContact|StartPlayGame +local function sendChatAction(chat_id, action, progress, dl_cb, cmd) + tdcli_function ({ + ID = "SendChatAction", + chat_id_ = chat_id, + action_ = { + ID = "SendMessage" .. action .. "Action", + progress_ = progress or 100 + } + }, dl_cb, cmd) +end + +M.sendChatAction = sendChatAction + +-- Sends notification about screenshot taken in a chat. +-- Works only in secret chats +-- @chat_id Chat identifier +local function sendChatScreenshotTakenNotification(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "SendChatScreenshotTakenNotification", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.sendChatScreenshotTakenNotification = sendChatScreenshotTakenNotification + +-- Chat is opened by the user. +-- Many useful activities depends on chat being opened or closed. For example, in channels all updates are received only for opened chats +-- @chat_id Chat identifier +local function openChat(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "OpenChat", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.openChat = openChat + +-- Chat is closed by the user. +-- Many useful activities depends on chat being opened or closed. +-- @chat_id Chat identifier +local function closeChat(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "CloseChat", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.closeChat = closeChat + +-- Messages are viewed by the user. +-- Many useful activities depends on message being viewed. For example, marking messages as read, incrementing of view counter, updating of view counter, removing of deleted messages in channels +-- @chat_id Chat identifier +-- @message_ids Identifiers of viewed messages +local function viewMessages(chat_id, message_ids, dl_cb, cmd) + tdcli_function ({ + ID = "ViewMessages", + chat_id_ = chat_id, + message_ids_ = message_ids -- vector + }, dl_cb, cmd) +end + +M.viewMessages = viewMessages + +-- Message content is opened, for example the user has opened a photo, a video, a document, a location or a venue or have listened to an audio or a voice message +-- @chat_id Chat identifier of the message +-- @message_id Identifier of the message with opened content +local function openMessageContent(chat_id, message_id, dl_cb, cmd) + tdcli_function ({ + ID = "OpenMessageContent", + chat_id_ = chat_id, + message_id_ = message_id + }, dl_cb, cmd) +end + +M.openMessageContent = openMessageContent + +-- Returns existing chat corresponding to the given user +-- @user_id User identifier +local function createPrivateChat(user_id, dl_cb, cmd) + tdcli_function ({ + ID = "CreatePrivateChat", + user_id_ = user_id + }, dl_cb, cmd) +end + +M.createPrivateChat = createPrivateChat + +-- Returns existing chat corresponding to the known group +-- @group_id Group identifier +local function createGroupChat(group_id, dl_cb, cmd) + tdcli_function ({ + ID = "CreateGroupChat", + group_id_ = getChatId(group_id).ID + }, dl_cb, cmd) +end + +M.createGroupChat = createGroupChat + +-- Returns existing chat corresponding to the known channel +-- @channel_id Channel identifier +local function createChannelChat(channel_id, dl_cb, cmd) + tdcli_function ({ + ID = "CreateChannelChat", + channel_id_ = getChatId(channel_id).ID + }, dl_cb, cmd) +end + +M.createChannelChat = createChannelChat + +-- Returns existing chat corresponding to the known secret chat +-- @secret_chat_id SecretChat identifier +local function createSecretChat(secret_chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "CreateSecretChat", + secret_chat_id_ = secret_chat_id + }, dl_cb, cmd) +end + +M.createSecretChat = createSecretChat + +-- Creates new group chat and send corresponding messageGroupChatCreate, returns created chat +-- @user_ids Identifiers of users to add to the group +-- @title Title of new group chat, 0-255 characters +local function createNewGroupChat(user_ids, title, dl_cb, cmd) + tdcli_function ({ + ID = "CreateNewGroupChat", + user_ids_ = user_ids, -- vector + title_ = title + }, dl_cb, cmd) +end + +M.createNewGroupChat = createNewGroupChat + +-- Creates new channel chat and send corresponding messageChannelChatCreate, returns created chat +-- @title Title of new channel chat, 0-255 characters +-- @is_supergroup True, if supergroup chat should be created +-- @about Information about the channel, 0-255 characters +local function createNewChannelChat(title, is_supergroup, about, dl_cb, cmd) + tdcli_function ({ + ID = "CreateNewChannelChat", + title_ = title, + is_supergroup_ = is_supergroup, + about_ = about + }, dl_cb, cmd) +end + +M.createNewChannelChat = createNewChannelChat + +-- Creates new secret chat, returns created chat +-- @user_id Identifier of a user to create secret chat with +local function createNewSecretChat(user_id, dl_cb, cmd) + tdcli_function ({ + ID = "CreateNewSecretChat", + user_id_ = user_id + }, dl_cb, cmd) +end + +M.createNewSecretChat = createNewSecretChat + +-- Creates new channel supergroup chat from existing group chat and send corresponding messageChatMigrateTo and messageChatMigrateFrom. Deactivates group +-- @chat_id Group chat identifier +local function migrateGroupChatToChannelChat(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "MigrateGroupChatToChannelChat", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.migrateGroupChatToChannelChat = migrateGroupChatToChannelChat + +-- Changes chat title. +-- Title can't be changed for private chats. +-- Title will not change until change will be synchronized with the server. +-- Title will not be changed if application is killed before it can send request to the server. +-- There will be update about change of the title on success. Otherwise error will be returned +-- @chat_id Chat identifier +-- @title New title of a chat, 0-255 characters +local function changeChatTitle(chat_id, title, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeChatTitle", + chat_id_ = chat_id, + title_ = title + }, dl_cb, cmd) +end + +M.changeChatTitle = changeChatTitle + +-- Changes chat photo. +-- Photo can't be changed for private chats. +-- Photo will not change until change will be synchronized with the server. +-- Photo will not be changed if application is killed before it can send request to the server. +-- There will be update about change of the photo on success. Otherwise error will be returned +-- @chat_id Chat identifier +-- @photo New chat photo. You can use zero InputFileId to delete photo. Files accessible only by HTTP URL are not acceptable +local function changeChatPhoto(chat_id, photo, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeChatPhoto", + chat_id_ = chat_id, + photo_ = getInputFile(photo) + }, dl_cb, cmd) +end + +M.changeChatPhoto = changeChatPhoto + +-- Changes chat draft message +-- @chat_id Chat identifier +-- @draft_message New draft message, nullable +local function changeChatDraftMessage(chat_id, reply_to_message_id, text, disable_web_page_preview, clear_draft, parse_mode, dl_cb, cmd) + local TextParseMode = getParseMode(parse_mode) + + tdcli_function ({ + ID = "ChangeChatDraftMessage", + chat_id_ = chat_id, + draft_message_ = { + ID = "DraftMessage", + reply_to_message_id_ = reply_to_message_id, + input_message_text_ = { + ID = "InputMessageText", + text_ = text, + disable_web_page_preview_ = disable_web_page_preview, + clear_draft_ = clear_draft, + entities_ = {}, + parse_mode_ = TextParseMode, + }, + }, + }, dl_cb, cmd) +end + +M.changeChatDraftMessage = changeChatDraftMessage + +-- Adds new member to chat. +-- Members can't be added to private or secret chats. +-- Member will not be added until chat state will be synchronized with the server. +-- Member will not be added if application is killed before it can send request to the server +-- @chat_id Chat identifier +-- @user_id Identifier of the user to add +-- @forward_limit Number of previous messages from chat to forward to new member, ignored for channel chats +local function addChatMember(chat_id, user_id, forward_limit, dl_cb, cmd) + tdcli_function ({ + ID = "AddChatMember", + chat_id_ = chat_id, + user_id_ = user_id, + forward_limit_ = forward_limit or 50 + }, dl_cb, cmd) +end + +M.addChatMember = addChatMember + +-- Adds many new members to the chat. +-- Currently, available only for channels. +-- Can't be used to join the channel. +-- Member will not be added until chat state will be synchronized with the server. +-- Member will not be added if application is killed before it can send request to the server +-- @chat_id Chat identifier +-- @user_ids Identifiers of the users to add +local function addChatMembers(chat_id, user_ids, dl_cb, cmd) + tdcli_function ({ + ID = "AddChatMembers", + chat_id_ = chat_id, + user_ids_ = user_ids -- vector + }, dl_cb, cmd) +end + +M.addChatMembers = addChatMembers + +-- Changes status of the chat member, need appropriate privileges. +-- In channel chats, user will be added to chat members if he is yet not a member and there is less than 200 members in the channel. +-- Status will not be changed until chat state will be synchronized with the server. +-- Status will not be changed if application is killed before it can send request to the server +-- @chat_id Chat identifier +-- @user_id Identifier of the user to edit status, bots can be editors in the channel chats +-- @status New status of the member in the chat +-- status = Creator|Editor|Moderator|Member|Left|Kicked +local function changeChatMemberStatus(chat_id, user_id, status, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeChatMemberStatus", + chat_id_ = chat_id, + user_id_ = user_id, + status_ = { + ID = "ChatMemberStatus" .. status + }, + }, dl_cb, cmd) +end + +M.changeChatMemberStatus = changeChatMemberStatus + +-- Returns information about one participant of the chat +-- @chat_id Chat identifier +-- @user_id User identifier +local function getChatMember(chat_id, user_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetChatMember", + chat_id_ = chat_id, + user_id_ = user_id + }, dl_cb, cmd) +end + +M.getChatMember = getChatMember + +-- Asynchronously downloads file from cloud. +-- Updates updateFileProgress will notify about download progress. +-- Update updateFile will notify about successful download +-- @file_id Identifier of file to download +local function downloadFile(file_id, dl_cb, cmd) + tdcli_function ({ + ID = "DownloadFile", + file_id_ = file_id + }, dl_cb, cmd) +end + +M.downloadFile = downloadFile + +-- Stops file downloading. +-- If file already downloaded do nothing. +-- @file_id Identifier of file to cancel download +local function cancelDownloadFile(file_id, dl_cb, cmd) + tdcli_function ({ + ID = "CancelDownloadFile", + file_id_ = file_id + }, dl_cb, cmd) +end + +M.cancelDownloadFile = cancelDownloadFile + +-- Next part of a file was generated +-- @generation_id Identifier of the generation process +-- @ready Number of bytes already generated. Negative number means that generation has failed and should be terminated +local function setFileGenerationProgress(generation_id, ready, dl_cb, cmd) + tdcli_function ({ + ID = "SetFileGenerationProgress", + generation_id_ = generation_id, + ready_ = ready + }, dl_cb, cmd) +end + +M.setFileGenerationProgress = setFileGenerationProgress + +-- Finishes file generation +-- @generation_id Identifier of the generation process +local function finishFileGeneration(generation_id, dl_cb, cmd) + tdcli_function ({ + ID = "FinishFileGeneration", + generation_id_ = generation_id + }, dl_cb, cmd) +end + +M.finishFileGeneration = finishFileGeneration + +-- Generates new chat invite link, previously generated link is revoked. +-- Available for group and channel chats. +-- Only creator of the chat can export chat invite link +-- @chat_id Chat identifier +local function exportChatInviteLink(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "ExportChatInviteLink", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.exportChatInviteLink = exportChatInviteLink + +-- Checks chat invite link for validness and returns information about the corresponding chat +-- @invite_link Invite link to check. Should begin with "https://telegram.me/joinchat/" +local function checkChatInviteLink(link, dl_cb, cmd) + tdcli_function ({ + ID = "CheckChatInviteLink", + invite_link_ = link + }, dl_cb, cmd) +end + +M.checkChatInviteLink = checkChatInviteLink + +-- Imports chat invite link, adds current user to a chat if possible. +-- Member will not be added until chat state will be synchronized with the server. +-- Member will not be added if application is killed before it can send request to the server +-- @invite_link Invite link to import. Should begin with "https://telegram.me/joinchat/" +local function importChatInviteLink(invite_link, dl_cb, cmd) + tdcli_function ({ + ID = "ImportChatInviteLink", + invite_link_ = invite_link + }, dl_cb, cmd) +end + +M.importChatInviteLink = importChatInviteLink + +-- Adds user to black list +-- @user_id User identifier +local function blockUser(user_id, dl_cb, cmd) + tdcli_function ({ + ID = "BlockUser", + user_id_ = user_id + }, dl_cb, cmd) +end + +M.blockUser = blockUser + +-- Removes user from black list +-- @user_id User identifier +local function unblockUser(user_id, dl_cb, cmd) + tdcli_function ({ + ID = "UnblockUser", + user_id_ = user_id + }, dl_cb, cmd) +end + +M.unblockUser = unblockUser + +-- Returns users blocked by the current user +-- @offset Number of users to skip in result, must be non-negative +-- @limit Maximum number of users to return, can't be greater than 100 +local function getBlockedUsers(offset, limit, dl_cb, cmd) + tdcli_function ({ + ID = "GetBlockedUsers", + offset_ = offset, + limit_ = limit + }, dl_cb, cmd) +end + +M.getBlockedUsers = getBlockedUsers + +-- Adds new contacts/edits existing contacts, contacts user identifiers are ignored. +-- Returns list of corresponding users in the same order as input contacts. +-- If contact doesn't registered in Telegram, user with id == 0 will be returned +-- @contacts List of contacts to import/edit +local function importContacts(phone_number, first_name, last_name, user_id, dl_cb, cmd) + tdcli_function ({ + ID = "ImportContacts", + contacts_ = {[0] = { + phone_number_ = tostring(phone_number), + first_name_ = tostring(first_name), + last_name_ = tostring(last_name), + user_id_ = user_id + }, + }, + }, dl_cb, cmd) +end + +M.importContacts = importContacts + +-- Searches for specified query in the first name, last name and username of the known user contacts +-- @query Query to search for, can be empty to return all contacts +-- @limit Maximum number of users to be returned +local function searchContacts(query, limit, dl_cb, cmd) + tdcli_function ({ + ID = "SearchContacts", + query_ = query, + limit_ = limit + }, dl_cb, cmd) +end + +M.searchContacts = searchContacts + +-- Deletes users from contacts list +-- @user_ids Identifiers of users to be deleted +local function deleteContacts(user_ids, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteContacts", + user_ids_ = user_ids -- vector + }, dl_cb, cmd) +end + +M.deleteContacts = deleteContacts + +-- Returns profile photos of the user. +-- Result of this query can't be invalidated, so it must be used with care +-- @user_id User identifier +-- @offset Photos to skip, must be non-negative +-- @limit Maximum number of photos to be returned, can't be greater than 100 +local function getUserProfilePhotos(user_id, offset, limit, dl_cb, cmd) + tdcli_function ({ + ID = "GetUserProfilePhotos", + user_id_ = user_id, + offset_ = offset, + limit_ = limit + }, dl_cb, cmd) +end + +M.getUserProfilePhotos = getUserProfilePhotos + +-- Returns stickers corresponding to given emoji +-- @emoji String representation of emoji. If empty, returns all known stickers +local function getStickers(emoji, dl_cb, cmd) + tdcli_function ({ + ID = "GetStickers", + emoji_ = emoji + }, dl_cb, cmd) +end + +M.getStickers = getStickers + +-- Returns list of installed sticker sets without archived sticker sets +-- @is_masks Pass true to return masks, pass false to return stickers +local function getStickerSets(is_masks, dl_cb, cmd) + tdcli_function ({ + ID = "GetStickerSets", + is_masks_ = is_masks + }, dl_cb, cmd) +end + +M.getStickerSets = getStickerSets + +-- Returns list of archived sticker sets +-- @is_masks Pass true to return masks, pass false to return stickers +-- @offset_sticker_set_id Identifier of the sticker set from which return the result +-- @limit Maximum number of sticker sets to return +local function getArchivedStickerSets(is_masks, offset_sticker_set_id, limit, dl_cb, cmd) + tdcli_function ({ + ID = "GetArchivedStickerSets", + is_masks_ = is_masks, + offset_sticker_set_id_ = offset_sticker_set_id, + limit_ = limit + }, dl_cb, cmd) +end + +M.getArchivedStickerSets = getArchivedStickerSets + +-- Returns list of trending sticker sets +local function getTrendingStickerSets(dl_cb, cmd) + tdcli_function ({ + ID = "GetTrendingStickerSets" + }, dl_cb, cmd) +end + +M.getTrendingStickerSets = getTrendingStickerSets + +-- Returns list of sticker sets attached to a file, currently only photos and videos can have attached sticker sets +-- @file_id File identifier +local function getAttachedStickerSets(file_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetAttachedStickerSets", + file_id_ = file_id + }, dl_cb, cmd) +end + +M.getAttachedStickerSets = getAttachedStickerSets + +-- Returns information about sticker set by its identifier +-- @set_id Identifier of the sticker set +local function getStickerSet(set_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetStickerSet", + set_id_ = set_id + }, dl_cb, cmd) +end + +M.getStickerSet = getStickerSet + +-- Searches sticker set by its short name +-- @name Name of the sticker set +local function searchStickerSet(name, dl_cb, cmd) + tdcli_function ({ + ID = "SearchStickerSet", + name_ = name + }, dl_cb, cmd) +end + +M.searchStickerSet = searchStickerSet + +-- Installs/uninstalls or enables/archives sticker set. +-- Official sticker set can't be uninstalled, but it can be archived +-- @set_id Identifier of the sticker set +-- @is_installed New value of is_installed +-- @is_archived New value of is_archived +local function updateStickerSet(set_id, is_installed, is_archived, dl_cb, cmd) + tdcli_function ({ + ID = "UpdateStickerSet", + set_id_ = set_id, + is_installed_ = is_installed, + is_archived_ = is_archived + }, dl_cb, cmd) +end + +M.updateStickerSet = updateStickerSet + +-- Trending sticker sets are viewed by the user +-- @sticker_set_ids Identifiers of viewed trending sticker sets +local function viewTrendingStickerSets(sticker_set_ids, dl_cb, cmd) + tdcli_function ({ + ID = "ViewTrendingStickerSets", + sticker_set_ids_ = sticker_set_ids -- vector + }, dl_cb, cmd) +end + +M.viewTrendingStickerSets = viewTrendingStickerSets + +-- Changes the order of installed sticker sets +-- @is_masks Pass true to change masks order, pass false to change stickers order +-- @sticker_set_ids Identifiers of installed sticker sets in the new right order +local function reorderStickerSets(is_masks, sticker_set_ids, dl_cb, cmd) + tdcli_function ({ + ID = "ReorderStickerSets", + is_masks_ = is_masks, + sticker_set_ids_ = sticker_set_ids -- vector + }, dl_cb, cmd) +end + +M.reorderStickerSets = reorderStickerSets + +-- Returns list of recently used stickers +-- @is_attached Pass true to return stickers and masks recently attached to photo or video files, pass false to return recently sent stickers +local function getRecentStickers(is_attached, dl_cb, cmd) + tdcli_function ({ + ID = "GetRecentStickers", + is_attached_ = is_attached + }, dl_cb, cmd) +end + +M.getRecentStickers = getRecentStickers + +-- Manually adds new sticker to the list of recently used stickers. +-- New sticker is added to the beginning of the list. +-- If the sticker is already in the list, at first it is removed from the list +-- @is_attached Pass true to add the sticker to the list of stickers recently attached to photo or video files, pass false to add the sticker to the list of recently sent stickers +-- @sticker Sticker file to add +local function addRecentSticker(is_attached, sticker, dl_cb, cmd) + tdcli_function ({ + ID = "AddRecentSticker", + is_attached_ = is_attached, + sticker_ = getInputFile(sticker) + }, dl_cb, cmd) +end + +M.addRecentSticker = addRecentSticker + +-- Removes a sticker from the list of recently used stickers +-- @is_attached Pass true to remove the sticker from the list of stickers recently attached to photo or video files, pass false to remove the sticker from the list of recently sent stickers +-- @sticker Sticker file to delete +local function deleteRecentSticker(is_attached, sticker, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteRecentSticker", + is_attached_ = is_attached, + sticker_ = getInputFile(sticker) + }, dl_cb, cmd) +end + +M.deleteRecentSticker = deleteRecentSticker + +-- Clears list of recently used stickers +-- @is_attached Pass true to clear list of stickers recently attached to photo or video files, pass false to clear the list of recently sent stickers +local function clearRecentStickers(is_attached, dl_cb, cmd) + tdcli_function ({ + ID = "ClearRecentStickers", + is_attached_ = is_attached + }, dl_cb, cmd) +end + +M.clearRecentStickers = clearRecentStickers + +-- Returns emojis corresponding to a sticker +-- @sticker Sticker file identifier +local function getStickerEmojis(sticker, dl_cb, cmd) + tdcli_function ({ + ID = "GetStickerEmojis", + sticker_ = getInputFile(sticker) + }, dl_cb, cmd) +end + +M.getStickerEmojis = getStickerEmojis + +-- Returns saved animations +local function getSavedAnimations(dl_cb, cmd) + tdcli_function ({ + ID = "GetSavedAnimations", + }, dl_cb, cmd) +end + +M.getSavedAnimations = getSavedAnimations + +-- Manually adds new animation to the list of saved animations. +-- New animation is added to the beginning of the list. +-- If the animation is already in the list, at first it is removed from the list. +-- Only non-secret video animations with MIME type "video/mp4" can be added to the list +-- @animation Animation file to add. Only known to server animations (i. e. successfully sent via message) can be added to the list +local function addSavedAnimation(animation, dl_cb, cmd) + tdcli_function ({ + ID = "AddSavedAnimation", + animation_ = getInputFile(animation) + }, dl_cb, cmd) +end + +M.addSavedAnimation = addSavedAnimation + +-- Removes animation from the list of saved animations +-- @animation Animation file to delete +local function deleteSavedAnimation(animation, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteSavedAnimation", + animation_ = getInputFile(animation) + }, dl_cb, cmd) +end + +M.deleteSavedAnimation = deleteSavedAnimation + +-- Returns up to 20 recently used inline bots in the order of the last usage +local function getRecentInlineBots(dl_cb, cmd) + tdcli_function ({ + ID = "GetRecentInlineBots", + }, dl_cb, cmd) +end + +M.getRecentInlineBots = getRecentInlineBots + +-- Get web page preview by text of the message. +-- Do not call this function to often +-- @message_text Message text +local function getWebPagePreview(message_text, dl_cb, cmd) + tdcli_function ({ + ID = "GetWebPagePreview", + message_text_ = message_text + }, dl_cb, cmd) +end + +M.getWebPagePreview = getWebPagePreview + +-- Returns notification settings for a given scope +-- @scope Scope to return information about notification settings +-- scope = Chat(chat_id)|PrivateChats|GroupChats|AllChats| +local function getNotificationSettings(scope, chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetNotificationSettings", + scope_ = { + ID = 'NotificationSettingsFor' .. scope, + chat_id_ = chat_id or nil + }, + }, dl_cb, cmd) +end + +M.getNotificationSettings = getNotificationSettings + +-- Changes notification settings for a given scope +-- @scope Scope to change notification settings +-- @notification_settings New notification settings for given scope +-- scope = Chat(chat_id)|PrivateChats|GroupChats|AllChats| +local function setNotificationSettings(scope, chat_id, mute_for, show_preview, dl_cb, cmd) + tdcli_function ({ + ID = "SetNotificationSettings", + scope_ = { + ID = 'NotificationSettingsFor' .. scope, + chat_id_ = chat_id or nil + }, + notification_settings_ = { + ID = "NotificationSettings", + mute_for_ = mute_for, + sound_ = "default", + show_preview_ = show_preview + } + }, dl_cb, cmd) +end + +M.setNotificationSettings = setNotificationSettings + +-- Resets all notification settings to the default value. +-- By default the only muted chats are supergroups, sound is set to 'default' and message previews are showed +local function resetAllNotificationSettings(dl_cb, cmd) + tdcli_function ({ + ID = "ResetAllNotificationSettings" + }, dl_cb, cmd) +end + +M.resetAllNotificationSettings = resetAllNotificationSettings + +-- Uploads new profile photo for logged in user. +-- Photo will not change until change will be synchronized with the server. +-- Photo will not be changed if application is killed before it can send request to the server. +-- If something changes, updateUser will be sent +-- @photo_path Path to new profile photo +local function setProfilePhoto(photo_path, dl_cb, cmd) + tdcli_function ({ + ID = "SetProfilePhoto", + photo_path_ = photo_path + }, dl_cb, cmd) +end + +M.setProfilePhoto = setProfilePhoto + +-- Deletes profile photo. +-- If something changes, updateUser will be sent +-- @profile_photo_id Identifier of profile photo to delete +local function deleteProfilePhoto(profile_photo_id, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteProfilePhoto", + profile_photo_id_ = profile_photo_id + }, dl_cb, cmd) +end + +M.deleteProfilePhoto = deleteProfilePhoto + +-- Changes first and last names of logged in user. +-- If something changes, updateUser will be sent +-- @first_name New value of user first name, 1-255 characters +-- @last_name New value of optional user last name, 0-255 characters +local function changeName(first_name, last_name, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeName", + first_name_ = first_name, + last_name_ = last_name + }, dl_cb, cmd) +end + +M.changeName = changeName + +-- Changes about information of logged in user +-- @about New value of userFull.about, 0-255 characters +local function changeAbout(about, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeAbout", + about_ = about + }, dl_cb, cmd) +end + +M.changeAbout = changeAbout + +-- Changes username of logged in user. +-- If something changes, updateUser will be sent +-- @username New value of username. Use empty string to remove username +local function changeUsername(username, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeUsername", + username_ = username + }, dl_cb, cmd) +end + +M.changeUsername = changeUsername + +-- Changes user's phone number and sends authentication code to the new user's phone number. +-- Returns authStateWaitCode with information about sent code on success +-- @phone_number New user's phone number in any reasonable format +-- @allow_flash_call Pass True, if code can be sent via flash call to the specified phone number +-- @is_current_phone_number Pass true, if the phone number is used on the current device. Ignored if allow_flash_call is False +local function changePhoneNumber(phone_number, allow_flash_call, is_current_phone_number, dl_cb, cmd) + tdcli_function ({ + ID = "ChangePhoneNumber", + phone_number_ = phone_number, + allow_flash_call_ = allow_flash_call, + is_current_phone_number_ = is_current_phone_number + }, dl_cb, cmd) +end + +M.changePhoneNumber = changePhoneNumber + +-- Resends authentication code sent to change user's phone number. +-- Works only if in previously received authStateWaitCode next_code_type was not null. +-- Returns authStateWaitCode on success +local function resendChangePhoneNumberCode(dl_cb, cmd) + tdcli_function ({ + ID = "ResendChangePhoneNumberCode", + }, dl_cb, cmd) +end + +M.resendChangePhoneNumberCode = resendChangePhoneNumberCode + +-- Checks authentication code sent to change user's phone number. +-- Returns authStateOk on success +-- @code Verification code from SMS, voice call or flash call +local function checkChangePhoneNumberCode(code, dl_cb, cmd) + tdcli_function ({ + ID = "CheckChangePhoneNumberCode", + code_ = code + }, dl_cb, cmd) +end + +M.checkChangePhoneNumberCode = checkChangePhoneNumberCode + +-- Returns all active sessions of logged in user +local function getActiveSessions(dl_cb, cmd) + tdcli_function ({ + ID = "GetActiveSessions", + }, dl_cb, cmd) +end + +M.getActiveSessions = getActiveSessions + +-- Terminates another session of logged in user +-- @session_id Session identifier +local function terminateSession(session_id, dl_cb, cmd) + tdcli_function ({ + ID = "TerminateSession", + session_id_ = session_id + }, dl_cb, cmd) +end + +M.terminateSession = terminateSession + +-- Terminates all other sessions of logged in user +local function terminateAllOtherSessions(dl_cb, cmd) + tdcli_function ({ + ID = "TerminateAllOtherSessions", + }, dl_cb, cmd) +end + +M.terminateAllOtherSessions = terminateAllOtherSessions + +-- Gives or revokes all members of the group editor rights. +-- Needs creator privileges in the group +-- @group_id Identifier of the group +-- @anyone_can_edit New value of anyone_can_edit +local function toggleGroupEditors(group_id, anyone_can_edit, dl_cb, cmd) + tdcli_function ({ + ID = "ToggleGroupEditors", + group_id_ = getChatId(group_id).ID, + anyone_can_edit_ = anyone_can_edit + }, dl_cb, cmd) +end + +M.toggleGroupEditors = toggleGroupEditors + +-- Changes username of the channel. +-- Needs creator privileges in the channel +-- @channel_id Identifier of the channel +-- @username New value of username. Use empty string to remove username +local function changeChannelUsername(channel_id, username, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeChannelUsername", + channel_id_ = getChatId(channel_id).ID, + username_ = username + }, dl_cb, cmd) +end + +M.changeChannelUsername = changeChannelUsername + +-- Gives or revokes right to invite new members to all current members of the channel. +-- Needs creator privileges in the channel. +-- Available only for supergroups +-- @channel_id Identifier of the channel +-- @anyone_can_invite New value of anyone_can_invite +local function toggleChannelInvites(channel_id, anyone_can_invite, dl_cb, cmd) + tdcli_function ({ + ID = "ToggleChannelInvites", + channel_id_ = getChatId(channel_id).ID, + anyone_can_invite_ = anyone_can_invite + }, dl_cb, cmd) +end + +M.toggleChannelInvites = toggleChannelInvites + +-- Enables or disables sender signature on sent messages in the channel. +-- Needs creator privileges in the channel. +-- Not available for supergroups +-- @channel_id Identifier of the channel +-- @sign_messages New value of sign_messages +local function toggleChannelSignMessages(channel_id, sign_messages, dl_cb, cmd) + tdcli_function ({ + ID = "ToggleChannelSignMessages", + channel_id_ = getChatId(channel_id).ID, + sign_messages_ = sign_messages + }, dl_cb, cmd) +end + +M.toggleChannelSignMessages = toggleChannelSignMessages + +-- Changes information about the channel. +-- Needs creator privileges in the broadcast channel or editor privileges in the supergroup channel +-- @channel_id Identifier of the channel +-- @about New value of about, 0-255 characters +local function changeChannelAbout(channel_id, about, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeChannelAbout", + channel_id_ = getChatId(channel_id).ID, + about_ = about + }, dl_cb, cmd) +end + +M.changeChannelAbout = changeChannelAbout + +-- Pins a message in a supergroup channel chat. +-- Needs editor privileges in the channel +-- @channel_id Identifier of the channel +-- @message_id Identifier of the new pinned message +-- @disable_notification True, if there should be no notification about the pinned message +local function pinChannelMessage(channel_id, message_id, disable_notification, dl_cb, cmd) + tdcli_function ({ + ID = "PinChannelMessage", + channel_id_ = getChatId(channel_id).ID, + message_id_ = message_id, + disable_notification_ = disable_notification + }, dl_cb, cmd) +end + +M.pinChannelMessage = pinChannelMessage + +-- Removes pinned message in the supergroup channel. +-- Needs editor privileges in the channel +-- @channel_id Identifier of the channel +local function unpinChannelMessage(channel_id, dl_cb, cmd) + tdcli_function ({ + ID = "UnpinChannelMessage", + channel_id_ = getChatId(channel_id).ID + }, dl_cb, cmd) +end + +M.unpinChannelMessage = unpinChannelMessage + +-- Reports some supergroup channel messages from a user as spam messages +-- @channel_id Channel identifier +-- @user_id User identifier +-- @message_ids Identifiers of messages sent in the supergroup by the user, the list should be non-empty +local function reportChannelSpam(channel_id, user_id, message_ids, dl_cb, cmd) + tdcli_function ({ + ID = "ReportChannelSpam", + channel_id_ = getChatId(channel_id).ID, + user_id_ = user_id, + message_ids_ = message_ids -- vector + }, dl_cb, cmd) +end + +M.reportChannelSpam = reportChannelSpam + +-- Returns information about channel members or kicked from channel users. +-- Can be used only if channel_full->can_get_members == true +-- @channel_id Identifier of the channel +-- @filter Kind of channel users to return, defaults to channelMembersRecent +-- @offset Number of channel users to skip +-- @limit Maximum number of users be returned, can't be greater than 200 +-- filter = Recent|Administrators|Kicked|Bots +local function getChannelMembers(channel_id, offset, filter, limit, dl_cb, cmd) + if not limit or limit > 200 then + limit = 200 + end + + tdcli_function ({ + ID = "GetChannelMembers", + channel_id_ = getChatId(channel_id).ID, + filter_ = { + ID = "ChannelMembers" .. filter + }, + offset_ = offset, + limit_ = limit + }, dl_cb, cmd) +end + +M.getChannelMembers = getChannelMembers + +-- Deletes channel along with all messages in corresponding chat. +-- Releases channel username and removes all members. +-- Needs creator privileges in the channel. +-- Channels with more than 1000 members can't be deleted +-- @channel_id Identifier of the channel +local function deleteChannel(channel_id, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteChannel", + channel_id_ = getChatId(channel_id).ID + }, dl_cb, cmd) +end + +M.deleteChannel = deleteChannel + +-- Returns list of created public channels +local function getCreatedPublicChannels(dl_cb, cmd) + tdcli_function ({ + ID = "GetCreatedPublicChannels" + }, dl_cb, cmd) +end + +M.getCreatedPublicChannels = getCreatedPublicChannels + +-- Closes secret chat +-- @secret_chat_id Secret chat identifier +local function closeSecretChat(secret_chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "CloseSecretChat", + secret_chat_id_ = secret_chat_id + }, dl_cb, cmd) +end + +M.closeSecretChat = closeSecretChat + +-- Returns user that can be contacted to get support +local function getSupportUser(dl_cb, cmd) + tdcli_function ({ + ID = "GetSupportUser", + }, dl_cb, cmd) +end + +M.getSupportUser = getSupportUser + +-- Returns background wallpapers +local function getWallpapers(dl_cb, cmd) + tdcli_function ({ + ID = "GetWallpapers", + }, dl_cb, cmd) +end + +M.getWallpapers = getWallpapers + +-- Registers current used device for receiving push notifications +-- @device_token Device token +-- device_token = apns|gcm|mpns|simplePush|ubuntuPhone|blackberry +local function registerDevice(device_token, token, device_token_set, dl_cb, cmd) + local dToken = {ID = device_token .. 'DeviceToken', token_ = token} + + if device_token_set then + dToken = {ID = "DeviceTokenSet", token_ = device_token_set} -- tokens:vector<DeviceToken> + end + + tdcli_function ({ + ID = "RegisterDevice", + device_token_ = dToken + }, dl_cb, cmd) +end + +M.registerDevice = registerDevice + +-- Returns list of used device tokens +local function getDeviceTokens(dl_cb, cmd) + tdcli_function ({ + ID = "GetDeviceTokens", + }, dl_cb, cmd) +end + +M.getDeviceTokens = getDeviceTokens + +-- Changes privacy settings +-- @key Privacy key +-- @rules New privacy rules +-- @privacyKeyUserStatus Privacy key for managing visibility of the user status +-- @privacyKeyChatInvite Privacy key for managing ability of invitation of the user to chats +-- @privacyRuleAllowAll Rule to allow all users +-- @privacyRuleAllowContacts Rule to allow all user contacts +-- @privacyRuleAllowUsers Rule to allow specified users +-- @user_ids User identifiers +-- @privacyRuleDisallowAll Rule to disallow all users +-- @privacyRuleDisallowContacts Rule to disallow all user contacts +-- @privacyRuleDisallowUsers Rule to disallow all specified users +-- key = UserStatus|ChatInvite +-- rules = AllowAll|AllowContacts|AllowUsers(user_ids)|DisallowAll|DisallowContacts|DisallowUsers(user_ids) +local function setPrivacy(key, rule, allowed_user_ids, disallowed_user_ids, dl_cb, cmd) + local rules = {[0] = {ID = 'PrivacyRule' .. rule}} + + if allowed_user_ids then + rules = { + { + ID = 'PrivacyRule' .. rule + }, + [0] = { + ID = "PrivacyRuleAllowUsers", + user_ids_ = allowed_user_ids -- vector + }, + } + end + if disallowed_user_ids then + rules = { + { + ID = 'PrivacyRule' .. rule + }, + [0] = { + ID = "PrivacyRuleDisallowUsers", + user_ids_ = disallowed_user_ids -- vector + }, + } + end + if allowed_user_ids and disallowed_user_ids then + rules = { + { + ID = 'PrivacyRule' .. rule + }, + { + ID = "PrivacyRuleAllowUsers", + user_ids_ = allowed_user_ids + }, + [0] = { + ID = "PrivacyRuleDisallowUsers", + user_ids_ = disallowed_user_ids + }, + } + end + tdcli_function ({ + ID = "SetPrivacy", + key_ = { + ID = 'PrivacyKey' .. key + }, + rules_ = { + ID = "PrivacyRules", + rules_ = rules + }, + }, dl_cb, cmd) +end + +M.setPrivacy = setPrivacy + +-- Returns current privacy settings +-- @key Privacy key +-- key = UserStatus|ChatInvite +local function getPrivacy(key, dl_cb, cmd) + tdcli_function ({ + ID = "GetPrivacy", + key_ = { + ID = "PrivacyKey" .. key + }, + }, dl_cb, cmd) +end + +M.getPrivacy = getPrivacy + +-- Returns value of an option by its name. +-- See list of available options on https://core.telegram.org/tdlib/options +-- @name Name of the option +local function getOption(name, dl_cb, cmd) + tdcli_function ({ + ID = "GetOption", + name_ = name + }, dl_cb, cmd) +end + +M.getOption = getOption + +-- Sets value of an option. +-- See list of available options on https://core.telegram.org/tdlib/options. +-- Only writable options can be set +-- @name Name of the option +-- @value New value of the option +local function setOption(name, option, value, dl_cb, cmd) + tdcli_function ({ + ID = "SetOption", + name_ = name, + value_ = { + ID = 'Option' .. option, + value_ = value + }, + }, dl_cb, cmd) +end + +M.setOption = setOption + +-- Changes period of inactivity, after which the account of currently logged in user will be automatically deleted +-- @ttl New account TTL +local function changeAccountTtl(days, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeAccountTtl", + ttl_ = { + ID = "AccountTtl", + days_ = days + }, + }, dl_cb, cmd) +end + +M.changeAccountTtl = changeAccountTtl + +-- Returns period of inactivity, after which the account of currently logged in user will be automatically deleted +local function getAccountTtl(dl_cb, cmd) + tdcli_function ({ + ID = "GetAccountTtl", + }, dl_cb, cmd) +end + +M.getAccountTtl = getAccountTtl + +-- Deletes the account of currently logged in user, deleting from the server all information associated with it. +-- Account's phone number can be used to create new account, but only once in two weeks +-- @reason Optional reason of account deletion +local function deleteAccount(reason, dl_cb, cmd) + tdcli_function ({ + ID = "DeleteAccount", + reason_ = reason + }, dl_cb, cmd) +end + +M.deleteAccount = deleteAccount + +-- Returns current chat report spam state +-- @chat_id Chat identifier +local function getChatReportSpamState(chat_id, dl_cb, cmd) + tdcli_function ({ + ID = "GetChatReportSpamState", + chat_id_ = chat_id + }, dl_cb, cmd) +end + +M.getChatReportSpamState = getChatReportSpamState + +-- Reports chat as a spam chat or as not a spam chat. +-- Can be used only if ChatReportSpamState.can_report_spam is true. +-- After this request ChatReportSpamState.can_report_spam became false forever +-- @chat_id Chat identifier +-- @is_spam_chat If true, chat will be reported as a spam chat, otherwise it will be marked as not a spam chat +local function changeChatReportSpamState(chat_id, is_spam_chat, dl_cb, cmd) + tdcli_function ({ + ID = "ChangeChatReportSpamState", + chat_id_ = chat_id, + is_spam_chat_ = is_spam_chat + }, dl_cb, cmd) +end + +M.changeChatReportSpamState = changeChatReportSpamState + +-- Bots only. +-- Informs server about number of pending bot updates if they aren't processed for a long time +-- @pending_update_count Number of pending updates +-- @error_message Last error's message +local function setBotUpdatesStatus(pending_update_count, error_message, dl_cb, cmd) + tdcli_function ({ + ID = "SetBotUpdatesStatus", + pending_update_count_ = pending_update_count, + error_message_ = error_message + }, dl_cb, cmd) +end + +M.setBotUpdatesStatus = setBotUpdatesStatus + +-- Returns Ok after specified amount of the time passed +-- @seconds Number of seconds before that function returns +local function setAlarm(seconds, dl_cb, cmd) + tdcli_function ({ + ID = "SetAlarm", + seconds_ = seconds + }, dl_cb, cmd) +end + +M.setAlarm = setAlarm + +-- Text message +-- @text Text to send +-- @disable_notification Pass true, to disable notification about the message, doesn't works in secret chats +-- @from_background Pass true, if the message is sent from background +-- @reply_markup Bots only. Markup for replying to message +-- @disable_web_page_preview Pass true to disable rich preview for link in the message text +-- @clear_draft Pass true if chat draft message should be deleted +-- @entities Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. Non-bot users can't use TextUrl entities. Can't be used with non-null parse_mode +-- @parse_mode Text parse mode, nullable. Can't be used along with enitities +local function sendMessage(chat_id, reply_to_message_id, disable_notification, text, disable_web_page_preview, parse_mode) + local TextParseMode = getParseMode(parse_mode) + + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = 1, + reply_markup_ = nil, + input_message_content_ = { + ID = "InputMessageText", + text_ = text, + disable_web_page_preview_ = disable_web_page_preview, + clear_draft_ = 0, + entities_ = {}, + parse_mode_ = TextParseMode, + }, + }, dl_cb, nil) +end + +M.sendMessage = sendMessage + +-- Animation message +-- @animation Animation file to send +-- @thumb Animation thumb, if available +-- @width Width of the animation, may be replaced by the server +-- @height Height of the animation, may be replaced by the server +-- @caption Animation caption, 0-200 characters +local function sendAnimation(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, animation, width, height, caption, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageAnimation", + animation_ = getInputFile(animation), + --thumb_ = { + --ID = "InputThumb", + --path_ = path, + --width_ = width, + --height_ = height + --}, + width_ = width or '', + height_ = height or '', + caption_ = caption or '' + }, + }, dl_cb, cmd) +end + +M.sendAnimation = sendAnimation + +-- Audio message +-- @audio Audio file to send +-- @album_cover_thumb Thumb of the album's cover, if available +-- @duration Duration of audio in seconds, may be replaced by the server +-- @title Title of the audio, 0-64 characters, may be replaced by the server +-- @performer Performer of the audio, 0-64 characters, may be replaced by the server +-- @caption Audio caption, 0-200 characters +local function sendAudio(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, audio, duration, title, performer, caption, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageAudio", + audio_ = getInputFile(audio), + --album_cover_thumb_ = { + --ID = "InputThumb", + --path_ = path, + --width_ = width, + --height_ = height + --}, + duration_ = duration or '', + title_ = title or '', + performer_ = performer or '', + caption_ = caption or '' + }, + }, dl_cb, cmd) +end + +M.sendAudio = sendAudio + +-- Document message +-- @document Document to send +-- @thumb Document thumb, if available +-- @caption Document caption, 0-200 characters +local function sendDocument(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, document, caption, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageDocument", + document_ = getInputFile(document), + --thumb_ = { + --ID = "InputThumb", + --path_ = path, + --width_ = width, + --height_ = height + --}, + caption_ = caption + }, + }, dl_cb, cmd) +end + +M.sendDocument = sendDocument + +-- Photo message +-- @photo Photo to send +-- @caption Photo caption, 0-200 characters +local function sendPhoto(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, photo, caption, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessagePhoto", + photo_ = getInputFile(photo), + added_sticker_file_ids_ = {}, + width_ = 0, + height_ = 0, + caption_ = caption + }, + }, dl_cb, cmd) +end + +M.sendPhoto = sendPhoto + +-- Sticker message +-- @sticker Sticker to send +-- @thumb Sticker thumb, if available +local function sendSticker(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, sticker, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageSticker", + sticker_ = getInputFile(sticker), + --thumb_ = { + --ID = "InputThumb", + --path_ = path, + --width_ = width, + --height_ = height + --}, + }, + }, dl_cb, cmd) +end + +M.sendSticker = sendSticker + +-- Video message +-- @video Video to send +-- @thumb Video thumb, if available +-- @duration Duration of video in seconds +-- @width Video width +-- @height Video height +-- @caption Video caption, 0-200 characters +local function sendVideo(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, video, duration, width, height, caption, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageVideo", + video_ = getInputFile(video), + --thumb_ = { + --ID = "InputThumb", + --path_ = path, + --width_ = width, + --height_ = height + --}, + added_sticker_file_ids_ = {}, + duration_ = duration or '', + width_ = width or '', + height_ = height or '', + caption_ = caption or '' + }, + }, dl_cb, cmd) +end + +M.sendVideo = sendVideo + +-- Voice message +-- @voice Voice file to send +-- @duration Duration of voice in seconds +-- @waveform Waveform representation of the voice in 5-bit format +-- @caption Voice caption, 0-200 characters +local function sendVoice(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, voice, duration, waveform, caption, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageVoice", + voice_ = getInputFile(voice), + duration_ = duration or '', + waveform_ = waveform or '', + caption_ = caption or '' + }, + }, dl_cb, cmd) +end + +M.sendVoice = sendVoice + +-- Message with location +-- @latitude Latitude of location in degrees as defined by sender +-- @longitude Longitude of location in degrees as defined by sender +local function sendLocation(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, latitude, longitude, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageLocation", + location_ = { + ID = "Location", + latitude_ = latitude, + longitude_ = longitude + }, + }, + }, dl_cb, cmd) +end + +M.sendLocation = sendLocation + +-- Message with information about venue +-- @venue Venue to send +-- @latitude Latitude of location in degrees as defined by sender +-- @longitude Longitude of location in degrees as defined by sender +-- @title Venue name as defined by sender +-- @address Venue address as defined by sender +-- @provider Provider of venue database as defined by sender. Only "foursquare" need to be supported currently +-- @id Identifier of the venue in provider database as defined by sender +local function sendVenue(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, latitude, longitude, title, address, id, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageVenue", + venue_ = { + ID = "Venue", + location_ = { + ID = "Location", + latitude_ = latitude, + longitude_ = longitude + }, + title_ = title, + address_ = address, + provider_ = 'foursquare', + id_ = id + }, + }, + }, dl_cb, cmd) +end + +M.sendVenue = sendVenue + +-- User contact message +-- @contact Contact to send +-- @phone_number User's phone number +-- @first_name User first name, 1-255 characters +-- @last_name User last name +-- @user_id User identifier if known, 0 otherwise +local function sendContact(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, phone_number, first_name, last_name, user_id, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageContact", + contact_ = { + ID = "Contact", + phone_number_ = phone_number, + first_name_ = first_name, + last_name_ = last_name, + user_id_ = user_id + }, + }, + }, dl_cb, cmd) +end + +M.sendContact = sendContact + +-- Message with a game +-- @bot_user_id User identifier of a bot owned the game +-- @game_short_name Game short name +local function sendGame(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, bot_user_id, game_short_name, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageGame", + bot_user_id_ = bot_user_id, + game_short_name_ = game_short_name + }, + }, dl_cb, cmd) +end + +M.sendGame = sendGame + +-- Forwarded message +-- @from_chat_id Chat identifier of the message to forward +-- @message_id Identifier of the message to forward +local function sendForwarded(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, from_chat_id, message_id, dl_cb, cmd) + tdcli_function ({ + ID = "SendMessage", + chat_id_ = chat_id, + reply_to_message_id_ = reply_to_message_id, + disable_notification_ = disable_notification, + from_background_ = from_background, + reply_markup_ = reply_markup, + input_message_content_ = { + ID = "InputMessageForwarded", + from_chat_id_ = from_chat_id, + message_id_ = message_id + }, + }, dl_cb, cmd) +end + +M.sendForwarded = sendForwarded + +return M cli/tg/tgcli (Binary file not shown.) 0 comments on commit 3233fdf Comment on 3233fdf Leave a comment Comment Desktop version
rokath / Tcobs🗜 Compression with elimination of zeroes ⓿, optimized for data with a bit more 00 and FF bytes, as messages often carry 16, 32 or 64 bit numbers with small values.
BlockchainLabs / SpreadCoinSpreadCoin October 5, 2014 Introduction In proof-of-work cryptocurrencies new coins are generated by the network through the process of mining. One of the purposes of mining is to protect network from double spending attacks and history rewriting. Miners generate new blocks and check contents of the blocks generated by other peers for conformation to the network rules. However, many miners now delegate all the checking work crucial to cryptocurrency security to pools. This means that pool operators do not have any large hashing power but have control over generation of new blocks. This brings unnecessary centralization to otherwise decentralized system. Controlling more than 50% of mining power allows to perform double-spending attacks with 100% chance of success but even with less than 50% control it is possible to perform attacks which have chances to succeed1 . The core idea of SpreadCoin is to prevent creation of pools and thus make mining more decentralized and the whole system more secure. Pool Prevention In pooled mining miners perform only the work which is necessary to fulfill the proof-of-work requirements and pools take care of block generation and broadcasting and distribute reward among miners according to the shares they submit. In this scheme miner has two alternatives: 1. Solo mining. In this case miner cannot send shares to the pool because they will not be accepted. 2. Pooled mining. Miner’s shares will be accepted by the pool but in the case miner will actually generate a new block its reward will go to the pool which will redistribute it to all miners. This allows organization of pools because miners has no way to cheat and steal generated money. To prevent creation of pools we must remove this possibility so that if pool will be created than miner can mine in a pool, submit shares as usual and get reward for them but in the case of actually finding a block miner can send it directly to the network instead of the pool and get full reward for it. In SpreadCoin mining is organized in such way that miner must know the following things: 1. Private key corresponding to the coinbase transaction. 2. Whole block, not only its header. This ensures that miner can broadcast mined block and spend coins generated in that block. It may seem that it is necessary to know only the private key to spend coinbase transaction. If two conflicting transactions will appear on the network then the one that was broadcasted first will have much higher probability to be included in a block because each peer remembers and retransmits only the first one of the conflicting transactions. If both miner and pool know private key but only pool knows the content of the block than pool can generate and broadcast spending transaction earlier than miner. If both miner 1 Double-spending. Bitcoin Wiki. https://en.bitcoin.it/wiki/Double-spending and pool know content of the block than miner will be the first one who can broadcast block and spending transaction. To prove knowledge of the private key and whole block there are two new fields in the block header: MinerSignature and hashWholeBlock. MinerSignature is a digital signature of all fields of the block header except for the hashWholeBlock. Changing any information in the block requires regeneration of this signature which means that it is necessary to recalculate it during each iteration of the mining process. This implies that miner must be able to sign any arbitrary data. hashWholeBlock is a SHA-256 hash of the block data arranged as follows: Padding ensures that there is no incentive to mine empty blocks without transactions. Padding values are computed using simple algorithm which initializes last 32 bytes (8 uint32) with hashPrevBlock and then goes backward and computes remaining uint32 values using the following recursive formula: 𝐼𝑖 = 𝐼𝑖+3 ∙ 𝐼𝑖+7. This algorithm ensures that there is no efficient way to compute padding values on the fly during hash computation which otherwise could potentially give some advantage to mine empty blocks in certain computing environments. It is important that block is hashed twice. If it was hashed only once then pool could hash the beginning of the block and send resulting hash state to the miners. Each miner would then modify some information in the end of the block and recalculate the hash based on the known state without actual knowledge about what is contained in the beginning of the block. Appending block data to itself make it necessary to know the whole block to recalculate hashWholeBlock. Pool may detect and ban cheating miners. However, many miners may still prefer to cheat so that pool will be completely unusable for honest miners. Miners that have low probability of finding a block will get more profit by stealing reward for accidentally found block even if pool will ban them thereafter. Miners that have enough mining power to find blocks consistently can still connect to a pool and submit shares for some time but steal the first found block. This way they can get both reward for their shares and the actual mined block. Given all this it is expected that no one will create a pool. But even if someone will than it can be countered by releasing stealing miner software which many miners will switch to. Compact Transactions SpreadCoin as well as Bitcoin uses ECDSA signatures. Each address in Bitcoin is a hash of an ECDSA public key. To spend coins sent to an address it is necessary to provide public key matching to that hash and a signature. This results in 139 or 107 bytes for each transaction input script (scriptSig) depending on Block Padding MAX_BLOCK_SIZE Block Padding whether compact public key is used. However, it is possible to recover public key from the signature2 which means that it is not necessary to provide it in transaction input. Together with using compact representation of the signature3 it allows to reduce size of transaction input script from 139 or 107 bytes in Bitcoin to 67 bytes in SpreadCoin. Recovering public key has almost no extra CPU cost compared to the usual signature verification process used in Bitcoin. This is important because the CPU cost of ECDSA signature verification is a bottleneck for Bitcoin transaction processing. Usual output script (scriptPubKey) in Bitcoin looks as follows: OP_DUP OP_HASH160 5bd18804e4bb43a4bb8b6bc88408970bafaf4a38 OP_EQUALVERIFY OP_CHECKSIG In SpreadCoin the semantics of the OP_CHECKSIG instruction was changed to checking signature by hash of the public key (it recovers public key and compares its hash with the provided one). This results in a much simpler script in SpreadCoin: 5bd18804e4bb43a4bb8b6bc88408970bafaf4a38 OP_CHECKSIG This results in additional minor space saving because this script is 3 bytes smaller. Smooth Supply Block reward in Bitcoin is computed using the following formula: 𝑅ℎ = 𝑅0 ∙ 2 −⌊ ℎ 𝑝 ⌋ , where ℎ – block height, 𝑝 – reward halving period, 𝑅0 – initial reward, 𝑅ℎ – reward for block ℎ, ⌊ ⌋ – floor function. This method results in abrupt reward changes near halving points. SpreadCoin uses simple linear interpolation between halving points to make reward decrease much smother. This is achieved by modifying reward using the following formula: 𝑅ℎ ′ = 4 3 (𝑅ℎ − 𝑅ℎ ∙ ℎ mod 𝑝 2𝑝 ). SpreadCoin uses 𝑝 = 2 ∙ 106 as its reward halving period. 2 ECDSA Signatures allow recovery of the public key. Bitcoin Forum. https://bitcointalk.org/?topic=6430.0%29%3F 3 Why the signature is always 65 (1+32+32) bytes long? Bitcoin Stack Exchange. https://bitcoin.stackexchange.com/questions/12554/why-the-signature-is-always-65-13232-bytes-long | NO YEAR 2106 PROBLEM The time stamp field in the block header is now 64 bit instead of 32 bit (Bitcoin) so that much farther date times are possible (>Year 2106) Upcoming features that are in development and will be introduced over the next weeks and months: SERVICENODES A servicenode is a node which runs continuously (24/7) on a server and which provides services within the spreadcoin network. You have to pay a collateral to be able to install a servernode (in return your servicenode will earn a steady income). This collateral is determined by a free market price discovery. (No fix collateral. The price is allowed to fluctuate over time.) COMPETITIVE COLLATERAL Furthermore, to introduce a competitive nature to the servicenodes there will only ever be a limited number of allowed servicenodes worldwide. Since the collateral isn't set in stone, but the amount of servicenodes is fixed, the price of a servicenode will be determined by the participants themselves. It is expected that the price will vary widely over time, which exposes it to the same market forces that hashrate and currency value are exposed to too. SERVICE APPS There are a number of decentralized applications that will run on servicenodes. Most likely those apps will include: 1) "Spread the message" (an in-wallet encrypted messaging system, which allows you to send a message to an SPR address) 2) "Spread the Search" (A decentralized search engine that lets the servicenodes crawl and map the entire internet.) . SPREADX11 SpreadX11 is different from plain X11 by introducing a sophisticated pool prevention mechanism. With SpreadX11 every block header contains additional information (MinerSignature and hashWholeBlock). With the help of this information the protocol ensures that the miner of a new block is always also the first one to know the content of the whole block and the private key to spend the coinbase transaction. (contrary to pool mining where the pool operator is the first one to know those things) So when a miner finds a block, he must himself sign and transmit the block to the network (like solo mining), instead of having a pool handle this for him. This effectively prevents pools by making their rules non-enforceable, since any miner in any assumed pool can always just steal the block reward instead of following the rules set up by the pool. COMPACT TRANSACTIONS SpreadCoin uses a more compact representation for signatures in transactions. SpreadCoin as well as Bitcoin uses ECDSA signatures. While bitcoin keeps a copy of the public key of the corresponding signature around, SpreadCoin ommits this by recovering the public key on the fly directly from the signature. This way it is not necessary to keep the public key of every ECDSA signature in the blockchain, so this leads to *smaller transactions and hence a smaller blockchain (at the cost of a few CPU cycles more). (*reduction in size of transaction from 139 or 107 bytes in Bitcoin to 67 bytes in SpreadCoin.) SMOOTH HALVING Unlike Bitcoin, there are no abrupt reward halvings in SpreadCoin. Block reward is smoothly decreasing over time. UNIQUE DESIGN WITH IN-WALLET VANITYGEN One of the first apps to be built into the wallet is the vanity generator (or vanity gen) which allows anyone to create personalised payment addresses. The easy to use wallet lets you search through trillions of payment addresses allowing you to find one or multiple vanity addresses, which are then stored safely along with the private keys on your own computer - and nowhere else. Searching using the vanity gen is probabilistic, so the amount of time required to find your chosen address patterns depends on how complex the pattern is, the speed of your computer, and a little bit of luck. You can use the vanity gen for a bit of fun, to make your address standout from the crowd or to create a link to a brand, business or other organisation. You can even search for addresses that others might be willing to buy from you. SpreadCoin is a new cryptocurrency which is more decentralized than Bitcoin. It prevents centralization of hashing power in pools, which is one of the main concerns of Bitcoin security. SpreadCoin was fairly launched on 29 July 2014, 9:00 UTC with no premine.
SOYJUN / Application With Raw IP SocketsOverview For this assignment you will be developing an application that uses raw IP sockets to ‘walk’ around an ordered list of nodes (given as a command line argument at the ‘source’ node, which is the node at which the tour was initiated), in a manner similar to the IP SSRR (Strict Source and Record Route) option. At each node, the application pings the preceding node in the tour. However, unlike the ping code in Stevens, you will be sending the ping ICMP echo request messages through a SOCK_RAW-type PF_PACKET socket and implementing ARP functionality to find the Ethernet address of the target node. Finally, when the ‘walk’ is completed, the group of nodes visited on the tour will exchange multicast messages. Your code will consist of two process modules, a ‘Tour’ application module (which will implement all the functionality outlined above, except for ARP activity) and an ARP module. The following should prove to be useful reference material for the assignment: Sections 21.2, 21.3, 21.6 and 21.10, Chapter 21, on Multicasting. Sections 27.1 to 27.3, Chapter 27, on the IP SSRR option. Sections 28.1 to 28.5, Chapter 28, on raw sockets, the IP_HDRINCL socket option, and ping. Sections 15.5, Chapter 15, on Unix domain SOCK_STREAM sockets. Figure 29.14, p. 807, and the corresponding explanation on p. 806, on filling in an IP header when the IP_HDRINCL socket option is in effect. The Lecture Slides on ARP & RARP (especially Section 4.4, ARP Packet Format, and the Figure 4.3 it includes). The link http://www.pdbuchan.com/rawsock/rawsock.html contains useful code samples that use IP raw sockets and PF_PACKET sockets. Note, in partcular, the code “icmp4_ll.c” in Table 2 for building an echo request sent through a PF_PACKET SOCK_RAW socket. The VMware environment You will be using the same vm1 , . . . . . , vm10 nodes you used for Assignment 3. However, unlike Assignment 3, you should use only interfaces eth0 and their associated IP addresses and ignore the other Ethernet interfaces that nodes have (interfaces eth0 make vm1 , . . . . . , vm10 look as if they belong to the same Ethernet LAN segment IP network 130.245.156.0/24). Note that, apart from the primary IP addresses associated with interfaces eth0, some nodes might also have one or more alias IP addresses associated with their interface eth0. Tour application module specifications The application will create a total of four sockets: two IP raw sockets, a PF_PACKET socket and a UDP socket for multicasting. We shall call the two IP raw sockets the ‘rt ’ (‘route traversal’) and ‘pg ’ (‘ping’) sockets, respectively. The rt socket should have the IP_HDRINCL option set. You will only be receiving ICMP echo reply messages through the pg socket (and not sending echo requests), so it does not matter whether it has the IP_HDRINCL option set or not. The pg socket should have protocol value (i.e., protocol demultiplexing key in the IP header) IPPROTO_ICMP. The rt socket should have a protocol value that identifies the application - i.e., some value other than the IPPROTO_XXXX values in /usr/include/netinet/in.h. However, remember that you will all be running your code using the same root account on the vm1 , . . . . . , vm10 nodes. So if two of you happen to choose the same protocol value and happen to be running on the same vm node at the same time, your applications will receive each other’s IP packets. For that reason, try to choose a protocol value for your rt socket that is likely to be unique to yourself. The PF_PACKET socket should be of type SOCK_RAW (not SOCK_DGRAM). This socket should have a protocol value of ETH_P_IP = 0x0800 (IPv4). The UDP socket for multicasting will be discussed below. Note that, depending on how you choose to bind that socket, you might actually need to have two UDP sockets for multicast communication – see bottom of p. 576, Section 21.10. Your application will, of course, have to be running on every vm node that is included in the tour. When evoking the application on the source node, the user supplies a sequence of vm node names (not IP addresses) to be visited in order. This command line sequence starts with the next node to be visited from the source node (i.e., it does not start with the source node itself). The sequence can include any number of repeated visits to the same node. For example, suppose that the source node is vm3 and the executable is called badr_tour : [root@vm3/root]# badr_tour vm2 vm10 vm4 vm7 vm5 vm2 vm6 vm2 vm9 vm4 vm7 vm2 vm6 vm5 vm1 vm10 vm8 (but note that the tour does not necessarily have to visit every vm node; and the same node should not appear consequentively in the tour list – i.e., the next node on the tour cannot be the current node itself). The application turns the sequence into a list of IP addresses for source routing. It also adds the IP address of the source node itself to the beginning of the list. The list thus produced will be carried as the payload of an IP packet, not as a SSRR option in the packet header. It is our application which will ensure that every node in the sequence is visited in order, not the IP SSRR capability. The source node should also add to the list an IP multicast address and a port number of its choice. It should also join the multicast group at that address and port number on its UDP socket. The TTL for outgoing multicasts should be set to 1. The application then fills in the header of an IP packet, designating itself as the IP source, and the next node to be visited as the IP destination. The packet is sent out on the rt socket. Note that on Linux, all the fields of the packet header must be in network byte order (Stevens, Section 28.3, p. 737, the fourth bullet point). When filling in the packet header, you should explicitly fill in the identification field (recall that, with the IP_HDRINCL socket option, if the identification field is given value 0, then the kernel will set its value). Try to make sure that the value you choose is likely to be unique to yourself (for reasons similar to those explained with respect to the IPPROTO_XXXX in 1. above). When a node receives an IP packet on its rt socket, it should first check that the identification field carries the right value (this implies that you will hard code your choice of identification field value determined in item 2 above in your code). If the identification field value does not check out, the packet is ignored. For a valid packet : Print out a message along the lines of: <time> received source routing packet from <hostname> <time> is the current time in human-readable format (see lines 19 & 20 in Figure 1.9, p. 14, and the corresponding explanation on p. 14f.), and <hostname> is the host name corresponding to the source IP address in the header of the received packet. If this is the first time the node is visited, the application should use the multicast address and port number in the packet received to join the multicast group on its UDP socket. The TTL for outgoing multicasts should be set to 1. The application updates the list in the payload, so that the next node in the tour can easily identify what the next hop from itself will be when it receives the packet. How you do this I leave up to you. You could, for example, include as part of the payload a pointer field into the list of nodes to be visited. This pointer would then be updated to the next entry in the list as the packet progresses hop by hop (see Figure 27.1 and the associated explanation on pp. 711-712). Other solutions are, of course, possible. The application then fills in a new IP header, designating itself as the IP source, and the next node to be visited as the IP destination. The identification field should be set to the same value as in the received packet. The packet is sent out on the rt socket. The node should also initiate pinging to the preceding node in the tour (the IP address of which it should pick up from the header of the received packet). However, unlike the Stevens ping code, it will be using the SOCK_RAW-type PF_PACKET socket of item 1 above to send the ICMP echo request messages. Before it can send echo request messages, the application has to call on the ARP module you will implement to get the Ethernet address of this preceding / ‘target’ node; this call is made using the API function areq which you will also implement (see sections ARP module specifications & API specifications below). Note that ARP has to be evoked every time the application wants to send out an echo request message, and not just the first time. An echo request message has to be encapsulated in a properly-formulated IP packet, which is in turn encapsulated in a properly-formulated Ethernet frame transmitted out through the PF_PACKET socket ; otherwise, ICMP at the source node will not receive it. You will have to modify Stevens’ ping code accordingly, specifically, the send_v4 function. In particular, the Ethernet frame must have a value of ETH_P_IP = 0x0800 (IPv4 – see <linux/if_ether.h>) in the frame type / ‘length’ field ; and the encapsulated IP packet must have a value of IPPROTO_ICMP = 0x01 (ICMPv4 – see <netinet_in.h>) in its protocol field. You should also simplify the ping code in its entirety by stripping all the ‘indirection’ IPv4 / IPv6 dual-operability paraphernalia and making the code work just for IPv4. Also note that the functions host_serv and freeaddrinfo, together with the associated structure addrinfo (see Sections 11.6, 11.8 & 11.11), in Figures 27.3, 27.6 & 28.5 ( pp. 713, 716 & 744f., respectively) can be replaced by the function gethostbyname and associated structure hostent (see Section 11.3) where needed. Also, there is no ‘-v’ verbose option, so this too should be stripped from Stevens’ code. When a node is ready to start pinging, it first prints out a ‘PING’ message similar to lines 32-33 of Figure 28.5, p. 744. It then builds up ICMP echo request messages and sends them to the source node every 1 second through the PF_PACKET socket. It also reads incoming echo response messages off the pg socket, in response to which it prints out the same kind of output as the code of Figure 28.8, p. 748. If this node and its preceding node have been previously visited in that order during the tour, then pinging would have already been initiated from the one to the other in response to the first visit, and nothing further should nor need be done during second and subsequent visits. In light of the above, note that once a node initiates pinging, it needs to read from both its rt and pg sockets, necessitating the use of the select function. As will be clear from what follows below, the application will anyway be needing also to simultaneously monitor its UDP socket for incoming multicast datagrams. When the last node on the tour is reached, and if this is the first time it is visited, it joins the multicast group and starts pinging the preceding node (if it is not already doing so). After a few echo replies are received (five, say), it sends out the multicast message below on its UDP socket (i.e., the node should wait about five seconds before sending the multicast message) : <<<<< This is node vmi . Tour has ended . Group members please identify yourselves. >>>>> where vmi is the name (not IP address) of the node. The node should also print this message out on stdout preceded, on the same line, by the phrase: Node vmi . Sending: <then print out the message sent>. Each node vmj receiving this message should print out the message received preceded, on the same line, by the phrase: Node vmj . Received <then print out the message received>. Each such node in step a above should then immediately stop its pinging activity. The node should then send out the following multicast message: <<<<< Node vmj . I am a member of the group. >>>>> and print out this message preceded, on the same line, by the phrase: Node vmj . Sending: <then print out the message sent>. Each node receiving these second multicast messages (i.e., the messages that nodes – including itself – sent out in step c above) should print each such message out preceded, on the same line, by the phrase: Node vmk . Received: <then print out the message received>. Reading from the socket in step d above should be implemented with a 5-second timeout. When the timeout expires, the node should print out another message to the effect that it is terminating the Tour application, and gracefully exit its Tour process. Note that under Multicast specifications, the last node in the tour, which sends out the End of Tour message, should itself receive a copy of that message and, when it does, it should behave exactly as do the other nodes in steps a. – e. above. ARP module specifications Your executable is evoked with no command line arguments. Like the Tour module, it will be running on every vm node. It uses the get_hw_addrs function of Assignment 3 to explore its node’s interfaces and build a set of <IP address , HW address> matching pairs for all eth0 interface IP addresses (including alias IP addresses, if any). Write out to stdout in some appropriately clear format the address pairs found. The module creates two sockets: a PF_PACKET socket and a Unix domain socket. The PF_PACKET should be of type SOCK_RAW (not type SOCK_DGRAM) with a protocol value of your choice (but not one of the standard values defined in <linux/if_ether.h>) which is, hopefully, unique to yourself. This value effectively becomes the protocol value for your implementation of ARP. Because this protocol value will be carried in the frame type / ‘length’ field of the Ethernet frame header (see Figure 4.3 of the ARP & RARP handout), the value chosen should be not less than 1536 (0x600) so that it is not misinterpreted as the length of an Ethernet 802.3 frame. The Unix domain socket should be of type SOCK_STREAM (not SOCK_DGRAM). It is a listening socket bound to a ‘well-known’ sun_path file. This socket will be used to communicate with the function areq that is implemented in the Tour module (see the section API specifications below). In this context, areq will act as the client and the ARP module as the server. The ARP module then sits in an infinite loop, monitoring these two sockets. As ARP request messages arrive on the PF_PACKET socket, the module processes them, and responds with ARP reply messages as appropriate. The protocol builds a ‘cache’ of matching <IP address , HW address> pairs from the replies (and requests – see below) it receives. For simplicity, and unlike the real ARP, we shall not implement timing out mechanisms for these cache entries. A cache entry has five parts: (i) IP address ; (ii) HW address ; (iii) sll_ifindex (the interface to be used for reaching the matching pair <(i) , (ii)>) ; (iv) sll_hatype ; and (v) a Unix-domain connection-socket descriptor for a connected client (see the section API specifications below for the latter three). When an ARP reply is being entered in the cache, the ARP module uses the socket descriptor in (v) to send a reply to the client, closes the connection socket, and deletes the socket descriptor from the cache entry. Note that, like the real ARP, when an ARP request is received by a node, and if the request pertains to that receiving node, the sender’s (see Figure 4.3 of the ARP & RARP handout) <IP address, HW address> matching pair should be entered into the cache if it is not already there (together, of course, with (iii) sll_ifindex & (iv) sll_hatype), or updated if need be if such an entry already exists in the cache. If the ARP request received does not pertain to the node receiving it, but there is already an entry in that receiving node's cache for the sender’s <IP address, HW address> matching pair, that entry should be checked and updated if need be. If there is no such entry, no action is taken (in particular, and unlike the case above, no new entry should be made in the receiving node's cache of the sender’s <IP address, HW address> matching pair if such an entry does not already exist). ARP request and reply messages have the same format as Figure 4.3 of the ARP & RARP handout, but with an extra 2-byte identification field added at the beginning which you fill with a value chosen so that it has a high probability of being unique to yourself. This value is to be echoed in the reply message, and helps to act as a further filter in case some other student happens to have fortuitously chosen the same value as yourself for the protocol parameter of the ARP PF_PACKET. Values in the fields of our ARP messages must be in network byte order. You might find the system header file <linux/if_arp.h> useful for manipulating ARP request and reply messages, but remember that our version of these messages have an extra two-byte field as mentioned above. Your code should print out on stdout, in some appropriately clear format, the contents of the Ethernet frame header and ARP request message you send. As described in Section 4.4 of the ARP & RARP handout, the node that responds to the request should, in its reply message, swap the two sender addresses with the two target addresses, as well as, of course, echo back the extra identification field sent with the request. The protocol at this responding node should print out, in an appropriately clear format, both the request frame (header and ARP message) it receives and the reply frame it sends. Similarly, the node that sent the request should print out the reply frame it receives. Finally, recall that the node issuing the request sends out a broadcast Ethernet frame, but the responding node replies with a unicast frame. API specifications The API is for communication between the Tour process and the ARP process. It consists of a single function, areq, implemented in the Tour module. areq is called by send_v4 function of the application every time the latter want to send out an ICMP echo request message: int areq (struct sockaddr *IPaddr, socklen_t sockaddrlen, struct hwaddr *HWaddr); IPaddr contains the primary or alias IPaddress of a ‘target’ node on the LAN for which the corresponding hardware address is being requested. hwaddr is a new structure (and not a pre-existing type) modeled on the sockaddr_ll of PF_PACKET; you will have to declare it in your code. It is used to return the requested hardware address to the caller of areq : structure hwaddr { int sll_ifindex; /* Interface number */ unsigned short sll_hatype; /* Hardware type */ unsigned char sll_halen; /* Length of address */ unsigned char sll_addr[8]; /* Physical layer address */ }; areq creates a Unix domain socket of type SOCK_STREAM and connects to the ‘well-known’ sun_path file of the ARP listening socket. It sends the IP address from parameter IPaddr and the information in the three fields of parameter HWaddr to ARP. It then blocks on a read awaiting a reply from ARP. This read should be backed up by a timeout since it is possible that no reply is received for the request. If a timeout occurs, areq should close the socket and return to its caller indicating failure (through its int return value). Your application code should print out on stdout, in some appropriately clear format, a notification every time areq is called, giving the IP address for which a HW address is being sought. It should similarly print out the result when the call to areq returns (HW address returned, or failure). When the ARP module receives a request for a HW address from areq through its Unix domain listening socket, it first checks if the required HW address is already in the cache. If so, it can respond immediately to the areq and close the Unix domain connection socket. Else : it makes an ‘incomplete’ entry in the cache, consisting of parts (i), (iii), (iv) and (v) ; puts out an ARP request message on the network on its PF_PACKET socket; and starts monitoring the areq connection socket for readability – if the areq client closes the connection socket (this would occur in response to a timeout in areq), ARP deletes the corresponding incomplete entry from the cache (and ignores any subsequent ARP reply from the network if such is received). On the other hand, if ARP receives a reply from the network, it updates the incomplete cache entry, responds to areq, and closes the connection socket.
AaronYi / Gnustep BaseThe GNUstep Base Library is a library of general-purpose, non-graphical Objective C objects. For example, it includes classes for strings, object collections, byte streams, typed coders, invocations, notifications, notification dispatchers, moments in time, network ports, remote object messaging support (distributed objects), and event loops.
uvhw / Bitcoin FoundationBitcoin: A Peer-to-Peer Electronic Cash System Satoshi Nakamoto satoshin@gmx.com www.bitcoin.org Abstract. A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent double-spending. We propose a solution to the double-spending problem using a peer-to-peer network. The network timestamps transactions by hashing them into an ongoing chain of hash-based proof-of-work, forming a record that cannot be changed without redoing the proof-of-work. The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power. As long as a majority of CPU power is controlled by nodes that are not cooperating to attack the network, they'll generate the longest chain and outpace attackers. The network itself requires minimal structure. Messages are broadcast on a best effort basis, and nodes can leave and rejoin the network at will, accepting the longest proof-of-work chain as proof of what happened while they were gone. 1. Introduction Commerce on the Internet has come to rely almost exclusively on financial institutions serving as trusted third parties to process electronic payments. While the system works well enough for most transactions, it still suffers from the inherent weaknesses of the trust based model. Completely non-reversible transactions are not really possible, since financial institutions cannot avoid mediating disputes. The cost of mediation increases transaction costs, limiting the minimum practical transaction size and cutting off the possibility for small casual transactions, and there is a broader cost in the loss of ability to make non-reversible payments for non- reversible services. With the possibility of reversal, the need for trust spreads. Merchants must be wary of their customers, hassling them for more information than they would otherwise need. A certain percentage of fraud is accepted as unavoidable. These costs and payment uncertainties can be avoided in person by using physical currency, but no mechanism exists to make payments over a communications channel without a trusted party. What is needed is an electronic payment system based on cryptographic proof instead of trust, allowing any two willing parties to transact directly with each other without the need for a trusted third party. Transactions that are computationally impractical to reverse would protect sellers from fraud, and routine escrow mechanisms could easily be implemented to protect buyers. In this paper, we propose a solution to the double-spending problem using a peer-to-peer distributed timestamp server to generate computational proof of the chronological order of transactions. The system is secure as long as honest nodes collectively control more CPU power than any cooperating group of attacker nodes. 1 2. Transactions We define an electronic coin as a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership. Transaction Hash Transaction Hash Transaction Hash Owner 1's Public Key Owner 2's Public Key Owner 3's Public Key Owner 0's Signature Owner 1's Signature The problem of course is the payee can't verify that one of the owners did not double-spend the coin. A common solution is to introduce a trusted central authority, or mint, that checks every transaction for double spending. After each transaction, the coin must be returned to the mint to issue a new coin, and only coins issued directly from the mint are trusted not to be double-spent. The problem with this solution is that the fate of the entire money system depends on the company running the mint, with every transaction having to go through them, just like a bank. We need a way for the payee to know that the previous owners did not sign any earlier transactions. For our purposes, the earliest transaction is the one that counts, so we don't care about later attempts to double-spend. The only way to confirm the absence of a transaction is to be aware of all transactions. In the mint based model, the mint was aware of all transactions and decided which arrived first. To accomplish this without a trusted party, transactions must be publicly announced [1], and we need a system for participants to agree on a single history of the order in which they were received. The payee needs proof that at the time of each transaction, the majority of nodes agreed it was the first received. 3. Timestamp Server The solution we propose begins with a timestamp server. A timestamp server works by taking a hash of a block of items to be timestamped and widely publishing the hash, such as in a newspaper or Usenet post [2-5]. The timestamp proves that the data must have existed at the time, obviously, in order to get into the hash. Each timestamp includes the previous timestamp in its hash, forming a chain, with each additional timestamp reinforcing the ones before it. Hash Hash Owner 2's Signature Owner 1's Private Key Owner 2's Private Key Owner 3's Private Key Block Item Item ... 2 Block Item Item ... Verify Verify Sign Sign 4. Proof-of-Work To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proof- of-work system similar to Adam Back's Hashcash [6], rather than newspaper or Usenet posts. The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash. For our timestamp network, we implement the proof-of-work by incrementing a nonce in the block until a value is found that gives the block's hash the required zero bits. Once the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing all the blocks after it. The proof-of-work also solves the problem of determining representation in majority decision making. If the majority were based on one-IP-address-one-vote, it could be subverted by anyone able to allocate many IPs. Proof-of-work is essentially one-CPU-one-vote. The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it. If a majority of CPU power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of the block and all blocks after it and then catch up with and surpass the work of the honest nodes. We will show later that the probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added. To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour. If they're generated too fast, the difficulty increases. 5. Network The steps to run the network are as follows: 1) New transactions are broadcast to all nodes. 2) Each node collects new transactions into a block. 3) Each node works on finding a difficult proof-of-work for its block. 4) When a node finds a proof-of-work, it broadcasts the block to all nodes. 5) Nodes accept the block only if all transactions in it are valid and not already spent. 6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash. Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. The tie will be broken when the next proof- of-work is found and one branch becomes longer; the nodes that were working on the other branch will then switch to the longer one. 3 Block Nonce Tx Tx ... Block Nonce Tx Tx ... Prev Hash Prev Hash New transaction broadcasts do not necessarily need to reach all nodes. As long as they reach many nodes, they will get into a block before long. Block broadcasts are also tolerant of dropped messages. If a node does not receive a block, it will request it when it receives the next block and realizes it missed one. 6. Incentive By convention, the first transaction in a block is a special transaction that starts a new coin owned by the creator of the block. This adds an incentive for nodes to support the network, and provides a way to initially distribute coins into circulation, since there is no central authority to issue them. The steady addition of a constant of amount of new coins is analogous to gold miners expending resources to add gold to circulation. In our case, it is CPU time and electricity that is expended. The incentive can also be funded with transaction fees. If the output value of a transaction is less than its input value, the difference is a transaction fee that is added to the incentive value of the block containing the transaction. Once a predetermined number of coins have entered circulation, the incentive can transition entirely to transaction fees and be completely inflation free. The incentive may help encourage nodes to stay honest. If a greedy attacker is able to assemble more CPU power than all the honest nodes, he would have to choose between using it to defraud people by stealing back his payments, or using it to generate new coins. He ought to find it more profitable to play by the rules, such rules that favour him with more new coins than everyone else combined, than to undermine the system and the validity of his own wealth. 7. Reclaiming Disk Space Once the latest transaction in a coin is buried under enough blocks, the spent transactions before it can be discarded to save disk space. To facilitate this without breaking the block's hash, transactions are hashed in a Merkle Tree [7][2][5], with only the root included in the block's hash. Old blocks can then be compacted by stubbing off branches of the tree. The interior hashes do not need to be stored. Block Hash0 Hash1 Hash2 Hash3 Tx0 Tx1 Tx2 Tx3 Block Header (Block Hash) Prev Hash Nonce Root Hash Hash01 Hash23 Block Block Header (Block Hash) Prev Hash Nonce Root Hash Hash01 Hash23 Hash2 Hash3 Tx3 Transactions Hashed in a Merkle Tree After Pruning Tx0-2 from the Block A block header with no transactions would be about 80 bytes. If we suppose blocks are generated every 10 minutes, 80 bytes * 6 * 24 * 365 = 4.2MB per year. With computer systems typically selling with 2GB of RAM as of 2008, and Moore's Law predicting current growth of 1.2GB per year, storage should not be a problem even if the block headers must be kept in memory. 4 8. Simplified Payment Verification It is possible to verify payments without running a full network node. A user only needs to keep a copy of the block headers of the longest proof-of-work chain, which he can get by querying network nodes until he's convinced he has the longest chain, and obtain the Merkle branch linking the transaction to the block it's timestamped in. He can't check the transaction for himself, but by linking it to a place in the chain, he can see that a network node has accepted it, and blocks added after it further confirm the network has accepted it. Longest Proof-of-Work Chain Block Header Block Header Block Header Prev Hash Nonce Prev Hash Nonce Prev Hash Nonce Merkle Root Merkle Root Merkle Root Hash01 Hash23 Merkle Branch for Tx3 Hash2 Hash3 Tx3 As such, the verification is reliable as long as honest nodes control the network, but is more vulnerable if the network is overpowered by an attacker. While network nodes can verify transactions for themselves, the simplified method can be fooled by an attacker's fabricated transactions for as long as the attacker can continue to overpower the network. One strategy to protect against this would be to accept alerts from network nodes when they detect an invalid block, prompting the user's software to download the full block and alerted transactions to confirm the inconsistency. Businesses that receive frequent payments will probably still want to run their own nodes for more independent security and quicker verification. 9. Combining and Splitting Value Although it would be possible to handle coins individually, it would be unwieldy to make a separate transaction for every cent in a transfer. To allow value to be split and combined, transactions contain multiple inputs and outputs. Normally there will be either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and at most two outputs: one for the payment, and one returning the change, if any, back to the sender. It should be noted that fan-out, where a transaction depends on several transactions, and those transactions depend on many more, is not a problem here. There is never the need to extract a complete standalone copy of a transaction's history. 5 Transaction In Out In ... ... 10. Privacy The traditional banking model achieves a level of privacy by limiting access to information to the parties involved and the trusted third party. The necessity to announce all transactions publicly precludes this method, but privacy can still be maintained by breaking the flow of information in another place: by keeping public keys anonymous. The public can see that someone is sending an amount to someone else, but without information linking the transaction to anyone. This is similar to the level of information released by stock exchanges, where the time and size of individual trades, the "tape", is made public, but without telling who the parties were. Traditional Privacy Model Identities Transactions New Privacy Model Identities Transactions As an additional firewall, a new key pair should be used for each transaction to keep them from being linked to a common owner. Some linking is still unavoidable with multi-input transactions, which necessarily reveal that their inputs were owned by the same owner. The risk is that if the owner of a key is revealed, linking could reveal other transactions that belonged to the same owner. 11. Calculations We consider the scenario of an attacker trying to generate an alternate chain faster than the honest chain. Even if this is accomplished, it does not throw the system open to arbitrary changes, such as creating value out of thin air or taking money that never belonged to the attacker. Nodes are not going to accept an invalid transaction as payment, and honest nodes will never accept a block containing them. An attacker can only try to change one of his own transactions to take back money he recently spent. The race between the honest chain and an attacker chain can be characterized as a Binomial Random Walk. The success event is the honest chain being extended by one block, increasing its lead by +1, and the failure event is the attacker's chain being extended by one block, reducing the gap by -1. The probability of an attacker catching up from a given deficit is analogous to a Gambler's Ruin problem. Suppose a gambler with unlimited credit starts at a deficit and plays potentially an infinite number of trials to try to reach breakeven. We can calculate the probability he ever reaches breakeven, or that an attacker ever catches up with the honest chain, as follows [8]: p = probability an honest node finds the next block q = probability the attacker finds the next block qz = probability the attacker will ever catch up from z blocks behind Trusted Third Party q ={ 1 if p≤q} z q/pz if pq 6 Counterparty Public Public Given our assumption that p > q, the probability drops exponentially as the number of blocks the attacker has to catch up with increases. With the odds against him, if he doesn't make a lucky lunge forward early on, his chances become vanishingly small as he falls further behind. We now consider how long the recipient of a new transaction needs to wait before being sufficiently certain the sender can't change the transaction. We assume the sender is an attacker who wants to make the recipient believe he paid him for a while, then switch it to pay back to himself after some time has passed. The receiver will be alerted when that happens, but the sender hopes it will be too late. The receiver generates a new key pair and gives the public key to the sender shortly before signing. This prevents the sender from preparing a chain of blocks ahead of time by working on it continuously until he is lucky enough to get far enough ahead, then executing the transaction at that moment. Once the transaction is sent, the dishonest sender starts working in secret on a parallel chain containing an alternate version of his transaction. The recipient waits until the transaction has been added to a block and z blocks have been linked after it. He doesn't know the exact amount of progress the attacker has made, but assuming the honest blocks took the average expected time per block, the attacker's potential progress will be a Poisson distribution with expected value: = z qp To get the probability the attacker could still catch up now, we multiply the Poisson density for each amount of progress he could have made by the probability he could catch up from that point: ∞ ke−{q/pz−k ifk≤z} ∑k=0 k!⋅ 1 ifkz Rearranging to avoid summing the infinite tail of the distribution... z ke− z−k 1−∑k=0 k! 1−q/p Converting to C code... #include <math.h> double AttackerSuccessProbability(double q, int z) { double p = 1.0 - q; double lambda = z * (q / p); double sum = 1.0; int i, k; for (k = 0; k <= z; k++) { double poisson = exp(-lambda); for (i = 1; i <= k; i++) poisson *= lambda / i; sum -= poisson * (1 - pow(q / p, z - k)); } return sum; } 7 Running some results, we can see the probability drop off exponentially with z. q=0.1 z=0 P=1.0000000 z=1 P=0.2045873 z=2 P=0.0509779 z=3 P=0.0131722 z=4 P=0.0034552 z=5 P=0.0009137 z=6 P=0.0002428 z=7 P=0.0000647 z=8 P=0.0000173 z=9 P=0.0000046 z=10 P=0.0000012 q=0.3 z=0 P=1.0000000 z=5 P=0.1773523 z=10 P=0.0416605 z=15 P=0.0101008 z=20 P=0.0024804 z=25 P=0.0006132 z=30 P=0.0001522 z=35 P=0.0000379 z=40 P=0.0000095 z=45 P=0.0000024 z=50 P=0.0000006 Solving for P less than 0.1%... P < 0.001 q=0.10 z=5 q=0.15 z=8 q=0.20 z=11 q=0.25 z=15 q=0.30 z=24 q=0.35 z=41 q=0.40 z=89 q=0.45 z=340 12. Conclusion We have proposed a system for electronic transactions without relying on trust. We started with the usual framework of coins made from digital signatures, which provides strong control of ownership, but is incomplete without a way to prevent double-spending. To solve this, we proposed a peer-to-peer network using proof-of-work to record a public history of transactions that quickly becomes computationally impractical for an attacker to change if honest nodes control a majority of CPU power. The network is robust in its unstructured simplicity. Nodes work all at once with little coordination. They do not need to be identified, since messages are not routed to any particular place and only need to be delivered on a best effort basis. Nodes can leave and rejoin the network at will, accepting the proof-of-work chain as proof of what happened while they were gone. They vote with their CPU power, expressing their acceptance of valid blocks by working on extending them and rejecting invalid blocks by refusing to work on them. Any needed rules and incentives can be enforced with this consensus mechanism. 8 References [1] W. Dai, "b-money," http://www.weidai.com/bmoney.txt, 1998. [2] H. Massias, X.S. Avila, and J.-J. Quisquater, "Design of a secure timestamping service with minimal trust requirements," In 20th Symposium on Information Theory in the Benelux, May 1999. [3] S. Haber, W.S. Stornetta, "How to time-stamp a digital document," In Journal of Cryptology, vol 3, no 2, pages 99-111, 1991. [4] D. Bayer, S. Haber, W.S. Stornetta, "Improving the efficiency and reliability of digital time-stamping," In Sequences II: Methods in Communication, Security and Computer Science, pages 329-334, 1993. [5] S. Haber, W.S. Stornetta, "Secure names for bit-strings," In Proceedings of the 4th ACM Conference on Computer and Communications Security, pages 28-35, April 1997. [6] A. Back, "Hashcash - a denial of service counter-measure," http://www.hashcash.org/papers/hashcash.pdf, 2002. [7] R.C. Merkle, "Protocols for public key cryptosystems," In Proc. 1980 Symposium on Security and Privacy, IEEE Computer Society, pages 122-133, April 1980. [8] W. Feller, "An introduction to probability theory and its applications," 1957. 9
SOYJUN / Implement ODR ProtocolOverview For this assignment you will be developing and implementing : An On-Demand shortest-hop Routing (ODR) protocol for networks of fixed but arbitrary and unknown connectivity, using PF_PACKET sockets. The implementation is based on (a simplified version of) the AODV algorithm. Time client and server applications that send requests and replies to each other across the network using ODR. An API you will implement using Unix domain datagram sockets enables applications to communicate with the ODR mechanism running locally at their nodes. I shall be discussing the assignment in class on Wednesday, October 29, and Monday, November 3. The following should prove useful reference material for the assignment : Sections 15.1, 15.2, 15.4 & 15.6, Chapter 15, on Unix domain datagram sockets. PF_PACKET(7) from the Linux manual pages. You might find these notes made by a past CSE 533 student useful. Also, the following link http://www.pdbuchan.com/rawsock/rawsock.html contains useful code samples that use PF_PACKET sockets (as well as other code samples that use raw IP sockets which you do not need for this assignment, though you will be using these types of sockets for Assignment 4). Charles E. Perkins & Elizabeth M. Royer. “Ad-hoc On-Demand Distance Vector Routing.” Proceedings of the 2nd IEEE Workshop on Mobile Computing Systems and Applications, New Orleans, Louisiana, February 1999, pp. 90 - 100. The VMware environment minix.cs.stonybrook.edu is a Linux box running VMware. A cluster of ten Linux virtual machines, called vm1 through vm10, on which you can gain access as root and run your code have been created on minix. See VMware Environment Hosts for further details. VMware instructions takes you to a page that explains how to use the system. The ten virtual machines have been configured into a small virtual intranet of Ethernet LANs whose topology is (in principle) unknown to you. There is a course account cse533 on node minix, with home directory /users/cse533. In there, you will find a subdirectory Stevens/unpv13e , exactly as you are used to having on the cs system. You should develop your source code and makefiles for handing in accordingly. You will be handing in your source code on the minix node. Note that you do not need to link against the socket library (-lsocket) in Linux. The same is true for -lnsl and -lresolv. For example, take a look at how the LIBS variable is defined for Solaris, in /home/courses/cse533/Stevens/unpv13e_solaris2.10/Make.defines (on compserv1, say) : LIBS = ../libunp.a -lresolv -lsocket -lnsl -lpthread But if you take a look at Make.defines on minix (/users/cse533/Stevens/unpv13e/Make.defines) you will find only: LIBS = ../libunp.a -lpthread The nodes vm1 , . . . . . , vm10 are all multihomed : each has two (or more) interfaces. The interface ‘eth0 ’ should be completely ignored and is not to be used for this assignment (because it shows all ten nodes as if belonging to the same single Ethernet 192.168.1.0/24, rather than to an intranet composed of several Ethernets). Note that vm1 , . . . . . , vm10 are virtual machines, not real ones. One implication of this is that you will not be able to find out what their (virtual) IP addresses are by using nslookup and such. To find out these IP addresses, you need to look at the file /etc/hosts on minix. More to the point, invoking gethostbyname for a given vm will return to you only the (primary) IP address associated with the interface eth0 of that vm (which is the interface you will not be using). It will not return to you any other IP address for the node. Similarly, gethostbyaddr will return the vm node name only if you give it the (primary) IP address associated with the interface eth0 for the node. It will return nothing if you give it any other IP address for the node, even though the address is perfectly valid. Because of this, and because it will ease your task to be able to use gethostbyname and gethostbyaddr in a straightforward way, we shall adopt the (primary) IP addresses associated with interfaces eth0 as the ‘canonical’ IP addresses for the nodes (more on this below). Time client and server A time server runs on each of the ten vm machines. The client code should also be available on each vm so that it can be evoked at any of them. Normally, time clients/servers exchange request/reply messages using the TCP/UDP socket API that, effectively, enables them to receive service (indirectly, via the transport layer) from the local IP mechanism running at their nodes. You are to implement an API using Unix domain sockets to access the local ODR service directly (somewhat similar, in effect, to the way that raw sockets permit an application to access IP directly). Use Unix domain SOCK_DGRAM, rather than SOCK_STREAM, sockets (see Figures 15.5 & 15.6, pp. 418 - 419). API You need to implement a msg_send function that will be called by clients/servers to send requests/replies. The parameters of the function consist of : int giving the socket descriptor for write char* giving the ‘canonical’ IP address for the destination node, in presentation format int giving the destination ‘port’ number char* giving message to be sent int flag if set, force a route rediscovery to the destination node even if a non-‘stale’ route already exists (see below) msg_send will format these parameters into a single char sequence which is written to the Unix domain socket that a client/server process creates. The sequence will be read by the local ODR from a Unix domain socket that the ODR process creates for itself. Recall that the ‘canonical’ IP address for a vm node is the (primary) IP address associated with the eth0 interface for the node. It is what will be returned to you by a call to gethostbyname. Similarly, we need a msg_recv function which will do a (blocking) read on the application domain socket and return with : int giving socket descriptor for read char* giving message received char* giving ‘canonical’ IP address for the source node of message, in presentation format int* giving source ‘port’ number This information is written as a single char sequence by the ODR process to the domain socket that it creates for itself. It is read by msg_recv from the domain socket the client/server process creates, decomposed into the three components above, and returned to the caller of msg_recv. Also see the section below entitled ODR and the API. Client When a client is evoked at a node, it creates a domain datagram socket. The client should bind its socket to a ‘temporary’ (i.e., not ‘well-known’) sun_path name obtained from a call to tmpnam() (cf. line 10, Figure 15.6, p. 419) so that multiple clients may run at the same node. Note that tmpnam() is actually highly deprecated. You should use the mkstemp() function instead - look up the online man pages on minix (‘man mkstemp’) for details. As you run client code again and again during the development stage, the temporary files created by the calls to tmpnam / mkstemp start to proliferate since these files are not automatically removed when the client code terminates. You need to explicitly remove the file created by the client evocation by issuing a call to unlink() or to remove() in your client code just before the client code exits. See the online man pages on minix (‘man unlink’, ‘man remove’) for details. The client then enters an infinite loop repeating the steps below. The client prompts the user to choose one of vm1 , . . . . . , vm10 as a server node. Client msg_sends a 1 or 2 byte message to server and prints out on stdout the message client at node vm i1 sending request to server at vm i2 (In general, throughout this assignment, “trace” messages such as the one above should give the vm names and not IP addresses of the nodes.) Client then blocks in msg_recv awaiting response. This attempt to read from the domain socket should be backed up by a timeout in case no response ever comes. I leave it up to you whether you ‘wrap’ the call to msg_recv in a timeout, or you implement the timeout inside msg_recv itself. When the client receives a response it prints out on stdout the message client at node vm i1 : received from vm i2 <timestamp> If, on the other hand, the client times out, it should print out the message client at node vm i1 : timeout on response from vm i2 The client then retransmits the message out, setting the flag parameter in msg_send to force a route rediscovery, and prints out an appropriate message on stdout. This is done only once, when a timeout for a given message to the server occurs for the first time. Client repeats steps 1. - 3. Server The server creates a domain datagram socket. The server socket is assumed to have a (node-local) ‘well-known’ sun_path name which it binds to. This ‘well-known’ sun_path name is designated by a (network-wide) ‘well-known’ ‘port’ value. The time client uses this ‘port’ value to communicate with the server. The server enters an infinite sequence of calls to msg_recv followed by msg_send, awaiting client requests and responding to them. When it responds to a client request, it prints out on stdout the message server at node vm i1 responding to request from vm i2 ODR The ODR process runs on each of the ten vm machines. It is evoked with a single command line argument which gives a “staleness” time parameter, in seconds. It uses get_hw_addrs (available to you on minix in ~cse533/Asgn3_code) to obtain the index, and associated (unicast) IP and Ethernet addresses for each of the node’s interfaces, except for the eth0 and lo (loopback) interfaces, which should be ignored. In the subdirectory ~cse533/Asgn3_code (/users/cse533/Asgn3_code) on minix I am providing you with two functions, get_hw_addrs and prhwaddrs. These are analogous to the get_ifi_info_plus and prifinfo_plus of Assignment 2. Like get_ifi_info_plus, get_hw_addrs uses ioctl. get_hw_addrs gets the (primary) IP address, alias IP addresses (if any), HW address, and interface name and index value for each of the node's interfaces (including the loopback interface lo). prhwaddrs prints that information out. You should modify and use these functions as needed. Note that if an interface has no HW address associated with it (this is, typically, the case for the loopback interface lo for example), then ioctl returns get_hw_addrs a HW address which is the equivalent of 00:00:00:00:00:00 . get_hw_addrs stores this in the appropriate field of its data structures as it would with any HW address returned by ioctl, but when prhwaddrs comes across such an address, it prints a blank line instead of its usual ‘HWaddr = xx:xx:xx:xx:xx:xx’. The ODR process creates one or more PF_PACKET sockets. You will need to try out PF_PACKET sockets for yourselves and familiarize yourselves with how they behave. If, when you read from the socket and provide a sockaddr_ll structure, the kernel returns to you the index of the interface on which the incoming frame was received, then one socket will be enough. Otherwise, somewhat in the manner of Assignment 2, you shall have to create a PF_PACKET socket for every interface of interest (which are all the interfaces of the node, excluding interfaces lo and eth0 ), and bind a socket to each interface. Furthermore, if the kernel also returns to you the source Ethernet address of the frame in the sockaddr_ll structure, then you can make do with SOCK_DGRAM type PF_PACKET sockets; otherwise you shall have to use SOCK_RAW type sockets (although I would prefer you to use SOCK_RAW type sockets anyway, even if it turns out you can make do with SOCK_DGRAM type). The socket(s) should have a protocol value (no larger than 0xffff so that it fits in two bytes; this value is given as a network-byte-order parameter in the call(s) to function socket) that identifies your ODR protocol. The <linux/if_ether.h> include file (i.e., the file /usr/include/linux/if_ether.h) contains protocol values defined for the standard protocols typically found on an Ethernet LAN, as well as other values such as ETH_P_ALL. You should set protocol to a value of your choice which is not a <linux/if_ether.h> value, but which is, hopefully, unique to yourself. Remember that you will all be running your code using the same root account on the vm1 , . . . . . , vm10 nodes. So if two of you happen to choose the same protocol value and happen to be running on the same vm node at the same time, your applications will receive each other’s frames. For that reason, try to choose a protocol value for the socket(s) that is likely to be unique to yourself (something based on your Stony Brook student ID number, for example). This value effectively becomes the protocol value for your implementation of ODR, as opposed to some other cse 533 student's implementation. Because your value of protocol is to be carried in the frame type field of the Ethernet frame header, the value chosen should be not less than 1536 (0x600) so that it is not misinterpreted as the length of an Ethernet 802.3 frame. Note from the man pages for packet(7) that frames are passed to and from the socket without any processing in the frame content by the device driver on the other side of the socket, except for calculating and tagging on the 4-byte CRC trailer for outgoing frames, and stripping that trailer before delivering incoming frames to the socket. Nevertheless, if you write a frame that is less than 60 bytes, the necessary padding is automatically added by the device driver so that the frame that is actually transmitted out is the minimum Ethernet size of 64 bytes. When reading from the socket, however, any such padding that was introduced into a short frame at the sending node to bring it up to the minimum frame size is not stripped off - it is included in what you receive from the socket (thus, the minimum number of bytes you receive should never be less than 60). Also, you will have to build the frame header for outgoing frames yourselves (assuming you use SOCK_RAW type sockets). Bear in mind that the field values in that header have to be in network order. The ODR process also creates a domain datagram socket for communication with application processes at the node, and binds the socket to a ‘well known’ sun_path name for the ODR service. Because it is dealing with fixed topologies, ODR is, by and large, considerably simpler than AODV. In particular, discovered routes are relatively stable and there is no need for all the paraphernalia that goes with the possibility of routes changing (such as maintenance of active nodes in the routing tables and timeout mechanisms; timeouts on reverse links; lifetime field in the RREP messages; etc.) Nor will we be implementing source_sequence_#s (in the RREQ messages), and dest_sequence_# (in RREQ and RREP messages). In reality, we should (though we will not, for the sake of simplicity, be doing so) implement some sort of sequence number mechanism, or some alternative mechanism such as split-horizon for example, if we are to avoid possible scenarios of routing loops in a “count to infinity” context (I shall explain this point in class). However, we want ODR to discover shortest-hop paths, and we want it to do so in a reasonably efficient manner. This necessitates having one or two aspects of its operations work in a different, possibly slightly more complicated, way than AODV does. ODR has several basic responsibilities : Build and maintain a routing table. For each destination in the table, the routing table structure should include, at a minimum, the next-hop node (in the form of the Ethernet address for that node) and outgoing interface index, the number of hops to the destination, and a timestamp of when the the routing table entry was made or last “reconfirmed” / updated. Note that a destination node in the table is to be identified only by its ‘canonical’ IP address, and not by any other IP addresses the node has. Generate a RREQ in response to a time client calling msg_send for a destination for which ODR has no route (or for which a route exists, but msg_send has the flag parameter set or the route has gone ‘stale’ – see below), and ‘flood’ the RREQ out on all the node’s interfaces (except for the interface it came in on and, of course, the interfaces eth0 and lo). Flooding is done using an Ethernet broadcast destination address (0xff:ff:ff:ff:ff:ff) in the outgoing frame header. Note that a copy of the broadcast packet is supposed to / might be looped back to the node that sends it (see p. 535 in the Stevens textbook). ODR will have to take care not to treat these copies as new incoming RREQs. Also note that ODR at the client node increments the broadcast_id every time it issues a new RREQ for any destination node. When a RREQ is received, ODR has to generate a RREP if it is at the destination node, or if it is at an intermediate node that happens to have a route (which is not ‘stale’ – see below) to the destination. Otherwise, it must propagate the RREQ by flooding it out on all the node’s interfaces (except the interface the RREQ arrived on). Note that as it processes received RREQs, ODR should enter the ‘reverse’ route back to the source node into its routing table, or update an existing entry back to the source node if the RREQ received shows a shorter-hop route, or a route with the same number of hops but going through a different neighbour. The timestamp associated with the table entry should be updated whenever an existing route is either “reconfirmed” or updated. Obviously, if the node is going to generate a RREP, updating an existing entry back to the source node with a more efficient route, or a same-hops route using a different neighbour, should be done before the RREP is generated. Unlike AODV, when an intermediate node receives a RREQ for which it generates a RREP, it should nevertheless continue to flood the RREQ it received if the RREQ pertains to a source node whose existence it has heretofore been unaware of, or the RREQ gives it a more efficient route than it knew of back to the source node (the reason for continuing to flood the RREQ is so that other nodes in the intranet also become aware of the existence of the source node or of the potentially more optimal reverse route to it, and update their tables accordingly). However, since an RREP for this RREQ is being sent by our node, we do not want other nodes who receive the RREQ propagated by our node, and who might be in a position to do so, to also send RREPs. So we need to introduce a field in the RREQ message, not present in the AODV specifications, which acts like a “RREP already sent” field. Our node sets this field before further propagating the RREQ and nodes receiving an RREQ with this field set do not send RREPs in response, even if they are in a position to do so. ODR may, of course, receive multiple, distinct instances of the same RREQ (the combination of source_addr and broadcast_id uniquely identifies the RREQ). Such RREQs should not be flooded out unless they have a lower hop count than instances of that RREQ that had previously been received. By the same token, if ODR is in a position to send out a RREP, and has already done so for this, now repeating, RREQ , it should not send out another RREP unless the RREQ shows a more efficient, previously unknown, reverse route back to the source node. In other words, ODR should not generate essentially duplicative RREPs, nor generate RREPs to instances of RREQs that reflect reverse routes to the source that are not more efficient than what we already have. Relay RREPs received back to the source node (this is done using the ‘reverse’ route entered into the routing table when the corresponding RREQ was processed). At the same time, a ‘forward’ path to the destination is entered into the routing table. ODR could receive multiple, distinct RREPs for the same RREQ. The ‘forward’ route entered in the routing table should be updated to reflect the shortest-hop route to the destination, and RREPs reflecting suboptimal routes should not be relayed back to the source. In general, maintaining a route and its associated timestamp in the table in response to RREPs received is done in the same manner described above for RREQs. Forward time client/server messages along the next hop. (The following is important – you will lose points if you do not implement it.) Note that such application payload messages (especially if they are the initial request from the client to the server, rather than the server response back to the client) can be like “free” RREPs, enabling nodes along the path from source (client) to destination (server) node to build a reverse path back to the client node whose existence they were heretofore unaware of (or, possibly, to update an existing route with a more optimal one). Before it forwards an application payload message along the next hop, ODR at an intermediate node (and also at the final destination node) should use the message to update its routing table in this way. Thus, calls to msg_send by time servers should never cause ODR at the server node to initiate RREQs, since the receipt of a time client request implies that a route back to the client node should now exist in the routing table. The only exception to this is if the server node has a staleness parameter of zero (see below). A routing table entry has associated with it a timestamp that gives the time the entry was made into the table. When a client at a node calls msg_send, and if an entry for the destination node already exists in the routing table, ODR first checks that the routing information is not ‘stale’. A stale routing table entry is one that is older than the value defined by the staleness parameter given as a command line argument to the ODR process when it is executed. ODR deletes stale entries (as well as non-stale entries when the flag parameter in msg_send is set) and initiates a route rediscovery by issuing a RREQ for the destination node. This will force periodic updating of the routing tables to take care of failed nodes along the current path, Ethernet addresses that might have changed, and so on. Similarly, as RREQs propagate through the intranet, existing stale table entries at intermediate nodes are deleted and new route discoveries propagated. As noted above when discussing the processing of RREQs and RREPs, the associated timestamp for an existing table entry is updated in response to having the route either “reconfirmed” or updated (this applies to both reverse routes, by virtue of RREQs received, and to forward routes, by virtue of RREPs). Finally, note that a staleness parameter of 0 essentially indicates that the discovered route will be used only once, when first discovered, and then discarded. Effectively, an ODR with staleness parameter 0 maintains no real routing table at all ; instead, it forces route discoveries at every step of its operation. As a practical matter, ODR should be run with staleness parameter values that are considerably larger than the longest RTT on the intranet, otherwise performance will degrade considerably (and collapse entirely as the parameter values approach 0). Nevertheless, for robustness, we need to implement a mechanism by which an intermediate node that receives a RREP or application payload message for forwarding and finds that its relevant routing table entry has since gone stale, can intiate a RREQ to rediscover the route it needs. RREQ, RREP, and time client/server request/response messages will all have to be carried as encapsulated ODR protocol messages that form the data payload of Ethernet frames. So we need to design the structure of ODR protocol messages. The format should contain a type field (0 for RREQ, 1 for RREP, 2 for application payload ). The remaining fields in an ODR message will depend on what type it is. The fields needed for (our simplified versions of AODV’s) RREQ and RREP should be fairly clear to you, but keep in mind that you need to introduce two extra fields: The “RREP already sent” bit or field in RREQ messages, as mentioned above. A “forced discovery” bit or field in both RREQ and RREP messages: When a client application forces route rediscovery, this bit should be set in the RREQ issued by the client node ODR. Intermediate nodes that are not the destination node but which do have a route to the destination node should not respond with RREPs to an RREQ which has the forced discovery field set. Instead, they should continue to flood the RREQ so that it eventually reaches the destination node which will then respond with an RREP. The intermediate nodes relaying such an RREQ must update their ‘reverse’ route back to the source node accordingly, even if the new route is less efficient (i.e., has more hops) than the one they currently have in their routing table. The destination node responds to the RREQ with an RREP in which this field is also set. Intermediate nodes that receive such a forced discovery RREP must update their ‘forward’ route to the destination node accordingly, even if the new route is less efficient (i.e., has more hops) than the one they currently have in their routing table. This behaviour will cause a forced discovery RREQ to be responded to only by the destination node itself and not any other node, and will cause intermediate nodes to update their routing tables to both source and destination nodes in accordance with the latest routing information received, to cover the possibility that older routes are no longer valid because nodes and/or links along their paths have gone down. A type 2, application payload, message needs to contain the following type of information : type = 2 ‘canonical’ IP address of source node ‘port’ number of source application process (This, of course, is not a real port number in the TCP/UDP sense, but simply a value that ODR at the source node uses to designate the sun_path name for the source application’s domain socket.) ‘canonical’ IP address of destination node ‘port’ number of destination application process (This is passed to ODR by the application process at the source node when it calls msg_send. Its designates the sun_path name for an application’s domain socket at the destination node.) hop count (This starts at 0 and is incremented by 1 at each hop so that ODR can make use of the message to update its routing table, as discussed above.) number of bytes in application message The fields above essentially constitute a ‘header’ for the ODR message. Note that fields which you choose to have carry numeric values (rather than ascii characters, for example) must be in network byte order. ODR-defined numeric-valued fields in type 0, RREQ, and type 1, RREP, messages must, of course, also be in network byte order. Also note that only the ‘canonical’ IP addresses are used for the source and destination nodes in the ODR header. The same has to be true in the headers for type 0, RREQ, and type 1, RREP, messages. The general rule is that ODR messages only carry ‘canonical’ IP node addresses. The last field in the type 2 ODR message is essentially the data payload of the message. application message given in the call to msg_send An ODR protocol message is encapsulated as the data payload of an Ethernet frame whose header it fills in as follows : source address = Ethernet address of outgoing interface of the current node where ODR is processing the message. destination address = Ethernet broadcast address for type 0 messages; Ethernet address of next hop node for type 1 & 2 messages. protocol field = protocol value for the ODR PF_PACKET socket(s). Last but not least, whenever ODR writes an Ethernet frame out through its socket, it prints out on stdout the message ODR at node vm i1 : sending frame hdr src vm i1 dest addr ODR msg type n src vm i2 dest vm i3 where addr is in presentation format (i.e., hexadecimal xx:xx:xx:xx:xx:xx) and gives the destination Ethernet address in the outgoing frame header. Other nodes in the message should be identified by their vm name. A message should be printed out for each packet sent out on a distinct interface. ODR and the API When the ODR process first starts, it must construct a table in which it enters all well-known ‘port’ numbers and their corresponding sun_path names. These will constitute permanent entries in the table. Thereafter, whenever it reads a message off its domain socket, it must obtain the sun_path name for the peer process socket and check whether that name is entered in the table. If not, it must select an ‘ephemeral’ ‘port’ value by which to designate the peer sun_path name and enter the pair < port value , sun_path name > into the table. Such entries cannot be permanent otherwise the table will grow unboundedly in time, with entries surviving for ever, beyond the peer processes’ demise. We must associate a time_to_live field with a non-permanent table entry, and purge the entry if nothing is heard from the peer for that amount of time. Every time a peer process for which a non-permanent table entry exists communicates with ODR, its time_to_live value should be reinitialized. Note that when ODR writes to a peer, it is possible for the write to fail because the peer does not exist : it could be a ‘well-known’ service that is not running, or we could be in the interval between a process with a non-permanent table entry terminating and the expiration of its time_to_live value. Notes A proper implementation of ODR would probably require that RREQ and RREP messages be backed up by some kind of timeout and retransmission mechanism since the network transmission environment is not reliable. This would considerably complicate the implementation (because at any given moment, a node could have multiple RREQs that it has flooded out, but for which it has still not received RREPs; the situation is further complicated by the fact that not all intermediate nodes receiving and relaying RREQs necessarily lie on a path to the destination, and therefore should expect to receive RREPs), and, learning-wise, would not add much to the experience you should have gained from Assignment 2.
heru299 / Script Copy-? Print this help message and exit -alertnotify=<cmd> Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message) -assumevalid=<hex> If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: 0000000000000000000b9d2ec5a352ecba0592946514a92f14319dc2b367fc72, testnet: 000000000000006433d1efec504c53ca332b64963c425395515b01977bd7b3b0, signet: 0000002a1de0f46379358c1fd09906f7ac59adf3712323ed90eb59e4c183c020) -blockfilterindex=<type> Maintain an index of compact filters by block (default: 0, values: basic). If <type> is not supplied or if <type> = 1, indexes for all known types are enabled. -blocknotify=<cmd> Execute command when the best block changes (%s in cmd is replaced by block hash) -blockreconstructionextratxn=<n> Extra transactions to keep in memory for compact block reconstructions (default: 100) -blocksdir=<dir> Specify directory to hold blocks subdirectory for *.dat files (default: <datadir>) -blocksonly Whether to reject transactions from network peers. Automatic broadcast and rebroadcast of any transactions from inbound peers is disabled, unless the peer has the 'forcerelay' permission. RPC transactions are not affected. (default: 0) -conf=<file> Specify path to read-only configuration file. Relative paths will be prefixed by datadir location. (default: bitcoin.conf) -daemon Run in the background as a daemon and accept commands -datadir=<dir> Specify data directory -dbcache=<n> Maximum database cache size <n> MiB (4 to 16384, default: 450). In addition, unused mempool memory is shared for this cache (see -maxmempool). -debuglogfile=<file> Specify location of debug log file. Relative paths will be prefixed by a net-specific datadir location. (-nodebuglogfile to disable; default: debug.log) -includeconf=<file> Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line) -loadblock=<file> Imports blocks from external file on startup -maxmempool=<n> Keep the transaction memory pool below <n> megabytes (default: 300) -maxorphantx=<n> Keep at most <n> unconnectable transactions in memory (default: 100) -mempoolexpiry=<n> Do not keep transactions in the mempool longer than <n> hours (default: 336) -par=<n> Set the number of script verification threads (-8 to 15, 0 = auto, <0 = leave that many cores free, default: 0) -persistmempool Whether to save the mempool on shutdown and load on restart (default: 1) -pid=<file> Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: bitcoind.pid) -prune=<n> Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. Warning: Reverting this setting requires re-downloading the entire blockchain. (default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >=550 = automatically prune block files to stay under the specified target size in MiB) -reindex Rebuild chain state and block index from the blk*.dat files on disk -reindex-chainstate Rebuild chain state from the currently indexed blocks. When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead. -settings=<file> Specify path to dynamic settings data file. Can be disabled with -nosettings. File is written at runtime and not meant to be edited by users (use bitcoin.conf instead for custom settings). Relative paths will be prefixed by datadir location. (default: settings.json) -startupnotify=<cmd> Execute command on startup. -sysperms Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality) -txindex Maintain a full transaction index, used by the getrawtransaction rpc call (default: 0) -version Print version and exit Connection options: -addnode=<ip> Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info). This option can be specified multiple times to add multiple nodes. -asmap=<file> Specify asn mapping used for bucketing of the peers (default: ip_asn.map). Relative paths will be prefixed by the net-specific datadir location. -bantime=<n> Default duration (in seconds) of manually configured bans (default: 86400) -bind=<addr>[:<port>][=onion] Bind to given address and always listen on it (default: 0.0.0.0). Use [host]:port notation for IPv6. Append =onion to tag any incoming connections to that address and port as incoming Tor connections (default: 127.0.0.1:8334=onion, testnet: 127.0.0.1:18334=onion, signet: 127.0.0.1:38334=onion, regtest: 127.0.0.1:18445=onion) -connect=<ip> Connect only to the specified node; -noconnect disables automatic connections (the rules for this peer are the same as for -addnode). This option can be specified multiple times to connect to multiple nodes. -discover Discover own IP addresses (default: 1 when listening and no -externalip or -proxy) -dns Allow DNS lookups for -addnode, -seednode and -connect (default: 1) -dnsseed Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used) -externalip=<ip> Specify your own public address -forcednsseed Always query for peer addresses via DNS lookup (default: 0) -listen Accept connections from outside (default: 1 if no -proxy or -connect) -listenonion Automatically create Tor onion service (default: 1) -maxconnections=<n> Maintain at most <n> connections to peers (default: 125) -maxreceivebuffer=<n> Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000) -maxsendbuffer=<n> Maximum per-connection send buffer, <n>*1000 bytes (default: 1000) -maxtimeadjustment Maximum allowed median peer time offset adjustment. Local perspective of time may be influenced by peers forward or backward by this amount. (default: 4200 seconds) -maxuploadtarget=<n> Tries to keep outbound traffic under the given target (in MiB per 24h). Limit does not apply to peers with 'download' permission. 0 = no limit (default: 0) -networkactive Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command -onion=<ip:port> Use separate SOCKS5 proxy to reach peers via Tor onion services, set -noonion to disable (default: -proxy) -onlynet=<net> Make outgoing connections only through network <net> (ipv4, ipv6 or onion). Incoming connections are not affected by this option. This option can be specified multiple times to allow multiple networks. -peerblockfilters Serve compact block filters to peers per BIP 157 (default: 0) -peerbloomfilters Support filtering of blocks and transaction with bloom filters (default: 0) -permitbaremultisig Relay non-P2SH multisig (default: 1) -port=<port> Listen for connections on <port>. Nodes not using the default ports (default: 8333, testnet: 18333, signet: 38333, regtest: 18444) are unlikely to get incoming connections. -proxy=<ip:port> Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled) -proxyrandomize Randomize credentials for every proxy connection. This enables Tor stream isolation (default: 1) -seednode=<ip> Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes. -timeout=<n> Specify connection timeout in milliseconds (minimum: 1, default: 5000) -torcontrol=<ip>:<port> Tor control port to use if onion listening enabled (default: 127.0.0.1:9051) -torpassword=<pass> Tor control port password (default: empty) -upnp Use UPnP to map the listening port (default: 0) -whitebind=<[permissions@]addr> Bind to the given address and add permission flags to the peers connecting to it. Use [host]:port notation for IPv6. Allowed permissions: bloomfilter (allow requesting BIP37 filtered blocks and transactions), noban (do not ban for misbehavior; implies download), forcerelay (relay transactions that are already in the mempool; implies relay), relay (relay even in -blocksonly mode, and unlimited transaction announcements), mempool (allow requesting BIP35 mempool contents), download (allow getheaders during IBD, no disconnect after maxuploadtarget limit), addr (responses to GETADDR avoid hitting the cache and contain random records with the most up-to-date info). Specify multiple permissions separated by commas (default: download,noban,mempool,relay). Can be specified multiple times. -whitelist=<[permissions@]IP address or network> Add permission flags to the peers connecting from the given IP address (e.g. 1.2.3.4) or CIDR-notated network (e.g. 1.2.3.0/24). Uses the same permissions as -whitebind. Can be specified multiple times. Wallet options: -addresstype What type of addresses to use ("legacy", "p2sh-segwit", or "bech32", default: "bech32") -avoidpartialspends Group outputs by address, selecting all or none, instead of selecting on a per-output basis. Privacy is improved as an address is only used once (unless someone sends to it after spending from it), but may result in slightly higher fees as suboptimal coin selection may result due to the added limitation (default: 0 (always enabled for wallets with "avoid_reuse" enabled)) -changetype What type of change to use ("legacy", "p2sh-segwit", or "bech32"). Default is same as -addresstype, except when -addresstype=p2sh-segwit a native segwit output is used when sending to a native segwit address) -disablewallet Do not load the wallet and disable wallet RPC calls -discardfee=<amt> The fee rate (in BTC/kB) that indicates your tolerance for discarding change by adding it to the fee (default: 0.0001). Note: An output is discarded if it is dust at this rate, but we will always discard up to the dust relay fee and a discard fee above that is limited by the fee estimate for the longest target -fallbackfee=<amt> A fee rate (in BTC/kB) that will be used when fee estimation has insufficient data. 0 to entirely disable the fallbackfee feature. (default: 0.00) -keypool=<n> Set key pool size to <n> (default: 1000). Warning: Smaller sizes may increase the risk of losing funds when restoring from an old backup, if none of the addresses in the original keypool have been used. -maxapsfee=<n> Spend up to this amount in additional (absolute) fees (in BTC) if it allows the use of partial spend avoidance (default: 0.00) -mintxfee=<amt> Fees (in BTC/kB) smaller than this are considered zero fee for transaction creation (default: 0.00001) -paytxfee=<amt> Fee (in BTC/kB) to add to transactions you send (default: 0.00) -rescan Rescan the block chain for missing wallet transactions on startup -spendzeroconfchange Spend unconfirmed change when sending transactions (default: 1) -txconfirmtarget=<n> If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: 6) -wallet=<path> Specify wallet path to load at startup. Can be used multiple times to load multiple wallets. Path is to a directory containing wallet data and log files. If the path is not absolute, it is interpreted relative to <walletdir>. This only loads existing wallets and does not create new ones. For backwards compatibility this also accepts names of existing top-level data files in <walletdir>. -walletbroadcast Make the wallet broadcast transactions (default: 1) -walletdir=<dir> Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>) -walletnotify=<cmd> Execute command when a wallet transaction changes. %s in cmd is replaced by TxID and %w is replaced by wallet name. %w is not currently implemented on windows. On systems where %w is supported, it should NOT be quoted because this would break shell escaping used to invoke the command. -walletrbf Send transactions with full-RBF opt-in enabled (RPC only, default: 0) ZeroMQ notification options: -zmqpubhashblock=<address> Enable publish hash block in <address> -zmqpubhashblockhwm=<n> Set publish hash block outbound message high water mark (default: 1000) -zmqpubhashtx=<address> Enable publish hash transaction in <address> -zmqpubhashtxhwm=<n> Set publish hash transaction outbound message high water mark (default: 1000) -zmqpubrawblock=<address> Enable publish raw block in <address> -zmqpubrawblockhwm=<n> Set publish raw block outbound message high water mark (default: 1000) -zmqpubrawtx=<address> Enable publish raw transaction in <address> -zmqpubrawtxhwm=<n> Set publish raw transaction outbound message high water mark (default: 1000) -zmqpubsequence=<address> Enable publish hash block and tx sequence in <address> -zmqpubsequencehwm=<n> Set publish hash sequence message high water mark (default: 1000) Debugging/Testing options: -debug=<category> Output debugging information (default: -nodebug, supplying <category> is optional). If <category> is not supplied or if <category> = 1, output all debugging information. <category> can be: net, tor, mempool, http, bench, zmq, walletdb, rpc, estimatefee, addrman, selectcoins, reindex, cmpctblock, rand, prune, proxy, mempoolrej, libevent, coindb, qt, leveldb, validation. -debugexclude=<category> Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except one or more specified categories. -help-debug Print help message with debugging options and exit -logips Include IP addresses in debug output (default: 0) -logthreadnames Prepend debug output with name of the originating thread (only available on platforms supporting thread_local) (default: 0) -logtimestamps Prepend debug output with timestamp (default: 1) -maxtxfee=<amt> Maximum total fees (in BTC) to use in a single wallet transaction; setting this too low may abort large transactions (default: 0.10) -printtoconsole Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile) -shrinkdebugfile Shrink debug.log file on client startup (default: 1 when no -debug) -uacomment=<cmt> Append comment to the user agent string Chain selection options: -chain=<chain> Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest -signet Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter -signetchallenge Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge) -signetseednode Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s)) -testnet Use the test chain. Equivalent to -chain=test. Node relay options: -bytespersigop Equivalent bytes per sigop in transactions for relay and mining (default: 20) -datacarrier Relay and mine data carrier transactions (default: 1) -datacarriersize Maximum size of data in data carrier transactions we relay and mine (default: 83) -minrelaytxfee=<amt> Fees (in BTC/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: 0.00001) -whitelistforcerelay Add 'forcerelay' permission to whitelisted inbound peers with default permissions. This will relay transactions even if the transactions were already in the mempool. (default: 0) -whitelistrelay Add 'relay' permission to whitelisted inbound peers with default permissions. This will accept relayed transactions even when not relaying transactions (default: 1) Block creation options: -blockmaxweight=<n> Set maximum BIP141 block weight (default: 3996000) -blockmintxfee=<amt> Set lowest fee rate (in BTC/kB) for transactions to be included in block creation. (default: 0.00001) RPC server options: -rest Accept public REST requests (default: 0) -rpcallowip=<ip> Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times -rpcauth=<userpw> Username and HMAC-SHA-256 hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcauth. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times -rpcbind=<addr>[:port] Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost) -rpccookiefile=<loc> Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir) -rpcpassword=<pw> Password for JSON-RPC connections -rpcport=<port> Listen for JSON-RPC connections on <port> (default: 8332, testnet: 18332, signet: 38332, regtest: 18443) -rpcserialversion Sets the serialization of raw transaction or block hex returned in non-verbose mode, non-segwit(0) or segwit(1) (default: 1) -rpcthreads=<n> Set the number of threads to service RPC calls (default: 4) -rpcuser=<user> Username for JSON-RPC connections -rpcwhitelist=<whitelist> Set a whitelist to filter incoming RPC calls for a specific user. The field <whitelist> comes in the format: <USERNAME>:<rpc 1>,<rpc 2>,...,<rpc n>. If multiple whitelists are set for a given user, they are set-intersected. See -rpcwhitelistdefault documentation for information on default whitelist behavior. -rpcwhitelistdefault Sets default behavior for rpc whitelisting. Unless rpcwhitelistdefault is set to 0, if any -rpcwhitelist is set, the rpc server acts as if all rpc users are subject to empty-unless-otherwise-specified whitelists. If rpcwhitelistdefault is set to 1 and no -rpcwhitelist is set, rpc server acts as if all rpc users are subject to empty whitelists. -server Accept command line and JSON-RPC commands ~ $
SE-Design / FAQ.mdNetSaver Pro ======== Please scroll down if you want to ask a question, request a feature or report a bug. Frequently Asked Questions (FAQ) -------------------------------- <a name="FAQ0"></a> **(0) How do I use NetSaver Pro?** * Enable the firewall using the switch in the action bar * Allow/deny Wi-Fi/mobile internet access using the icons along the right side of the application list You can use the settings menu to change from blacklist mode (allow all in *Settings* but block unwanted applications in list) to whitelist mode (block all in *Settings* but allow favorite applications in list). * Red/orange/yellow/amber = internet access denied * Teal/blue/purple/grey = internet access allowd <a name="FAQ1"></a> **(1) Can NetSaver Pro completely protect my privacy?** No - nothing can completely protect your privacy. NetSaver Pro will do its best, but it is limited by the fact it must use the VPN service. This is the trade-off required to make a firewall which does not require root access. The firewall can only start when Android "allows" it to start, so it will not offer protection during early boot-up (although your network may not be loaded at that time). It will, however, be much better than nothing, especially if you are not rebooting often. If you want to protect yourself more, you can (at least in theory) disable Wi-Fi and mobile data before rebooting, and only enable them on reboot, after the firewall service has started (and the small key icon is visible in the status bar). Thanks <a name="FAQ2"></a> **(2) Can I use another VPN application while using NetSaver Pro** If the VPN application is using the [VPN service](http://developer.android.com/reference/android/net/VpnService.html), then no, because NetSaver Pro needs to use this service. Android allows only one application at a time to use this service. <a name="FAQ3"></a> **(3) Can I use NetSaver Pro on any Android version?** No, the minimum required Android version is 4.0 (Lollipop) because NetSaver Pro uses the [addDisallowedApplication](http://developer.android.com/reference/android/net/VpnService.Builder.html#addDisallowedApplication(java.lang.String)) method. <a name="FAQ4"></a> **(4) Will NetSaver Pro use extra battery power?** If you didn't enable IP filtering, probably not. However, the network speed graph notification will use extra battery power. This is why the notification is shown only when the screen is on. You can decrease the update frequency using the settings to reduce the battery usage. <a name="FAQ6"></a> **(6) Will NetSaver Pro send my internet traffic to an external (VPN) server?** No, depending on the mode of operation basically one of two things will happen with your internet traffic: * When IP filtering is disabled, blocked internet traffic will be routed into the local VPN which will operate as sinkhole (in effect dropping all blocked traffic) * When IP filtering is enabled, both blocked and allowed internet traffic will be routed into the local VPN and only allowed traffic will be forwarded to the intended destination (so not to a VPN server) The [Android VPN service](http://developer.android.com/reference/android/net/VpnService.html) is being used to locally route all internet traffic to NetGuard so no root is required to build a firewall application. NetSaver Pro is unlike all other no-root firewalls applications. <a name="FAQ7"></a> **(7) Why are applications without internet permission shown?** Internet permission can be granted with each application update without user consent. By showing all applications, NetGuard allows you to control internet access even *before* such an update occurs. <a name="FAQ8"></a> **(8) What do I need to enable for the Google Play™ store app to work?** You need 3 packages (applications) enabled (use search in NetGuard to find them quickly): * com.android.vending (Play store) * com.google.android.gms (Play services) * com.android.providers.downloads (Download manager) Since the Google Play™ store app has a tendency to check for updates or even download them all by itself (even if no account is associated), one can keep it in check by enabling "*Allow when device in use*" for all 3 of these packages. Click on the down arrow on the left side of an application name and check that option, but leave the network icons set to red (hence blocked).The little human icon will appear for those packages. Note that NetSaver Pro does not require any Google service to be installed. <a name="FAQ9"></a> **(9) Why is the VPN service being restarted?** The VPN service will be restarted when you turn the screen on or off and when connectivity changes (Wi-Fi, mobile) to apply the rules with the conditions '*Allow when screen is on*' and '*Block when roaming*'. See [here](http://forum.xda-developers.com/showpost.php?p=65723629&postcount=1788) for more details. <a name="FAQ10"></a> **(10) Will you provide a Tasker plug-in?** If disabling NetSaver Pro is allowed to Tasker, any application can disabled NetSaver Pro too. Allowing to disable a security application from other applications is not a good idea. <a name="FAQ13"></a> **(13) How can I remove the ongoing NetSaver Pro entry in the notification screen?** * Long click the NetSaver Pro notification * Tap the 'i' icon * Depending on your device and/or ROMs manufacturer software customizations, you can be directed to either: * the **App Info** screen and you can uncheck '*Show notifications*' and agree to the next dialog * the **App Notifications** screen and you can toggle the '*Block*' slider to on Note that, whether or not you get a dialog warning to agree upon, this operation will disable any information or warning notifications from NetSaver Pro as well, like the new application installed notification. To read about the need for the notification in the first place, see [question 24](#FAQ24). Some Android versions display an additional notification, which might include a key icon. This notification can unfortunately not be removed. <a name="FAQ14"></a> **(14) Why can't I select OK to approve the VPN connection request?** There might be another (invisible) application on top of the VPN connection request dialog. Some known (screen dimming) applications which can cause this are *Lux Brightness*, *Night Mode* and *Twilight*. To avoid this problem, at least temporary, close all applications and/or services which may be running in the background. <a name="FAQ15"></a> **(15) Why won't you support the F-Droid builds?** Because F-Droid doesn't support reproducible builds. Read [here](https://blog.torproject.org/blog/deterministic-builds-part-one-cyberwar-and-global-compromise) why this is important. Another reason is that F-Droid builds are more often than not outdated, leaving users with an old version with known bugs. <a name="FAQ16"></a> **(16) Why are some applications shown dimmed?** Disabled applications and applications without internet permission are shown dimmed. <a name="FAQ17"></a> **(17) Why is NetSaver Pro so much memory?** It isn't, NetSaver Pro doesn't allocate any memory, except a little for displaying the user interface elements. It appeared that on some Android variants the Google Play™ store app connection, using almost 150 MB and needed for in-app donations, is incorrectly attributed to NetSaver Pro instead to the Google Play™ store app. <a name="FAQ18"></a> **(18) Why can't I findNetSaver Pro in the Google Play™ store app?** NetSaver Pro requires at least Android 4.0, so it is not available in the Google Play™ store app for devices running older Android versions. <a name="FAQ19"></a> **(19) Why does aplication XYZ still have internet access?** If you block internet access for an application, there is no way around it. However, applications could access the internet through other applications. Google Play services is handling push messages for most applications for example. You can prevent this by blocking internet access for the other application as well. Note that some applications keep trying to access the internet, which is done by sending a connection request packet. This packet goes into the VPN sinkhole when internet access for the application is blocked. This packet consists of less than 100 bytes and is counted by Android as outgoing traffic and will be visible in the speed graph notification as well. <a name="FAQ20"></a> **(20) Can I Greenify/hibernate NetGuard?** No. [Greenifying](https://play.google.com/store/apps/details?id=com.oasisfeng.greenify) or otherwise hibernating NetGuard will result in rules not being applied when connectivity changes from Wi-Fi/mobile, screen on/off and roaming/not roaming. <a name="FAQ21"></a> **(21) Does doze mode affect NNetSaver Pro?** I am not sure, because the [doze mode documentation](http://developer.android.com/training/monitoring-device-state/doze-standby.html) is not clear if the [Android VPN service](http://developer.android.com/reference/android/net/VpnService.html) will be affected. To be sure you can disable battery optimizations for NetSaver Pro manually like this: ``` Android settings > Battery > three dot menu > Battery optimizations > Dropdown > All apps > NetSaver Pro> Don't optimize > Done ``` This cannot be done from the application, because according to Google NetSaver Pro is [not an application type allowed to do this](http://developer.android.com/training/monitoring-device-state/doze-standby.html#whitelisting-cases). <a name="FAQ22"></a> **(22) Can I tether / use Wi-Fi calling while using NetGuard?** Yes, but this needs to be enabled in the settings. If it works depends on your Android version, because some Android versions have a bug preventing tethering and the VPN service to work together. Some devices hibernate Wi-Fi preventing tethering to work when the screen is off. This behavior can be disabled in the Android enhanced/advanced Wi-Fi settings. <a name="FAQ24"></a> **(24) Can you remove the notification from the status bar?** Android can kill background services at any time. This can only be prevented by turning a background service into a foreground service. Android requires an ongoing notification for all foreground services to make you aware of potential battery usage (see [question 4](#FAQ4)). So, the notification cannot be removed without causing instability. However, the notification is being marked as low priority, which should result in moving it to the bottom of the list. The key icon and/or the VPN running notification, which is shown by Android and not by NetGuard, can unfortunately not be removed. The [Google documentation](http://developer.android.com/reference/android/net/VpnService.html) says: "*A system-managed notification is shown during the lifetime of a VPN connection*". <a name="FAQ25"></a> **(25) Can you add a 'select all'?** There is no need for a select all function, because you can switch from black list to white list mode using the settings. See also [question 0](#FAQ0). <a name="FAQ27"></a> **(27) How do I read the blocked traffic log?** The columns have the following meaning: 1. Time (tap on a log entry to see the date) 1. Application icon (tap on a log entry to see the application name) 1. Application UID 1. Wi-Fi / mobile connection, green=allowed, red=blocked 1. Interactive state (screen on or off) 1. Protocol (see below) and packet flags (see below) 1. Source and destination port (tap on a log entry to lookup a destination port) 1. Source and destination IPv4 or IPv6 address (tap on a log entry to lookup a destination IP address) 1. Organization name owning the IP address (need to be enabled through the menu) Protocols: * ICMP * IGMP * ESP (IPSec) * TCP * UDP * Number = one of the protocols in [this list](https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers) * 4 = IPv4 * 6 = IPv6 Packet flags: * S = SYN * A = ACK * P = PSH * F = FIN * R = RST For a detailed explanation see [here](https://en.wikipedia.org/wiki/Transmission_Control_Protocol). <a name="FAQ28"></a> **(28) Why is Google connectivity services allowed internet access by default?** The Google connectivity services system application checks if the current network is really connected to the internet. This is probably done by briefly connecting to some Google server. If this is not the case, there will be an '!' in the Wi-Fi or mobile icon in the system status bar. Recent Android versions seem not to switch connectivity from mobile to Wi-Fi when the Wi-Fi network is not really connected, even though there is a connection to the Wi-Fi network (or the other way around). On Android 6.0 and later you might get a notification asking you if you want to keep this connection on or not. To prevent a bad user experience there is a predefined rule to default allow the Google connectivity services. <a name="FAQ29"></a> **(29) Why do I get 'The item you requested is not available for purchase'?** You can only purchase pro feature when you installed NetSaver Pro from the Play store. <a name="FAQ30"></a> **(30) Can I also run AFWall+ on the same device?** Unless you are just testing NetSaver Pro, there is no current reason to use them both, since they cover the same function (firewall), although with different base needs (AFWall+ needs a rooted device) and ways of doing their thing (AFWall+ uses iptables). Also you need to keep per applicaton access rules _always_ in sync, else the application will not be able to access the network, hence bringing another level of complexity when setting and assuring things work out. Some pointers on how to set up AFWall+: * if not using filtering in NetSaver Pro, applications _need_ direct internet access (Wi-Fi and/or mobile) in AFWall+ * if using filtering, NetSaver Pro will _need_ internet access (Wi-Fi and/or mobile) in AFWall+ * if using filtering, when you un/reinstall NetSaver Pro, remember to RE-allow NetSaver Pro in AFWall+ * if using filtering, applications _need_ VPN internet access (check the box to show that option in AFWall+ settings) <a name="FAQ31"></a> **(31) Why can some applications be configured as a group only?** For a lot of purposes, including network access, Android groups applications on UID and not on package/application name. Especially system applications often have the same UID, despite having a different package and application name, these are set up like this by the ROM manufacturer at build time. These applications can only be allowed/blocked access to the internet as a group. <a name="FAQ32"></a> **(32) Why is the battery/network usage of NetSaver Pro so high?** This is because Android contributes battery and network usage which is normally contributed to other applications to NetSaver Prod in IP filtering mode. The total battery usage is slightly higher when IP filtering mode is enabled. IP filtering mode is always enabled on Android version before 5.0 and optionally enabled on later Android versions. <a name="FAQ33"></a> **(33) Can you add profiles?** Profiles are inconvenient because they need to be operated manually. Conditions like '*When screen is on*' are on the other hand convenient because they work automatic. Therefore profiles will not be added, but you are welcome to propose new conditions, however they need to be generally usable to be included. As a workaround you can use the export/import function to apply specific settings in specific circumstances. <a name="FAQ34"></a> **(34) Can you add the condition 'when on foreground'?** Recent Android versions do not allow an application to query if other applications are in the foreground or background anymore, so this cannot be added. You can use the condition '*when screen is on*' instead. <a name="FAQ35"></a> **(35) Why does the VPN not start?** NetSaver Pro "asks" Android to start the local VPN service, but some Android versions contain a bug which prevents the VPN from starting (automatically). Sometimes this is caused by updating NetSaver Pro. Unfortunately this cannot be fixed from NetSaver Pro. What you can try is to restart your device and/or revoke the VPN permissions from NetSaver Pro using the Android settings. Sometimes it helps to uninstall and install NetSaver Pro again (be sure to export your settings first). <a name="FAQ36"></a> **(36) Can you add PIN or password protection?** Since turning off the VPN service using the Android settings cannot be prevented, there is little use in adding PIN or password protection. <a name="FAQ37"></a> **(37) Why are the pro features so expensive?** The right question is "*why are there so many taxes and fees*": * VAT: 25% (depending on your country) * Google fee: 30% * Income tax: 50% So, what is left for the developer is just a fraction of what you pay. Despite NetSaver Pro being *really* a lot of work, only some of the convenience and advanced features are paid, which means that NetSaver Pro is basically free to use. Also note that most free applications will appear not to be sustainable in the end, whereas NetSaver Pro is properly maintained and supported. <br />
amir2510 / Script<!DOCTYPE html> <html lang="en" dir="ltr" data-cast-api-enabled="true"> <head><meta name="viewport" content="width=device-width, initial-scale=1"><style name="www-roboto" >@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/WxrXJa0C3KdtC7lMafG4dRTbgVql8nDJpwnrE27mub0.woff2)format('woff2');unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;}@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/OpXUqTo0UgQQhGj_SFdLWBTbgVql8nDJpwnrE27mub0.woff2)format('woff2');unicode-range:U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/1hZf02POANh32k2VkgEoUBTbgVql8nDJpwnrE27mub0.woff2)format('woff2');unicode-range:U+1F00-1FFF;}@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/cDKhRaXnQTOVbaoxwdOr9xTbgVql8nDJpwnrE27mub0.woff2)format('woff2');unicode-range:U+0370-03FF;}@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/K23cxWVTrIFD6DJsEVi07RTbgVql8nDJpwnrE27mub0.woff2)format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+1EA0-1EF9,U+20AB;}@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/vSzulfKSK0LLjjfeaxcREhTbgVql8nDJpwnrE27mub0.woff2)format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;}@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/vPcynSL0qHq_6dX7lKVByfesZW2xOQ-xsNqO47m55DA.woff2)format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/OLffGBTaF0XFOW1gnuHF0TTOQ_MqJVwkKsUn0wKzc2I.woff2)format('woff2');unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/OLffGBTaF0XFOW1gnuHF0TUj_cnvWIuuBMVgbX098Mw.woff2)format('woff2');unicode-range:U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/OLffGBTaF0XFOW1gnuHF0UbcKLIaa1LC45dFaAfauRA.woff2)format('woff2');unicode-range:U+1F00-1FFF;}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/OLffGBTaF0XFOW1gnuHF0Wo_sUJ8uO4YLWRInS22T3Y.woff2)format('woff2');unicode-range:U+0370-03FF;}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/OLffGBTaF0XFOW1gnuHF0b6up8jxqWt8HVA3mDhkV_0.woff2)format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+1EA0-1EF9,U+20AB;}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/OLffGBTaF0XFOW1gnuHF0SYE0-AqJ3nfInTTiDXDjU4.woff2)format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/OLffGBTaF0XFOW1gnuHF0Y4P5ICox8Kq3LLUNMylGO4.woff2)format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/ZLqKeelYbATG60EpZBSDyxJtnKITppOI_IvcXXDNrsc.woff2)format('woff2');unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/oHi30kwQWvpCWqAhzHcCSBJtnKITppOI_IvcXXDNrsc.woff2)format('woff2');unicode-range:U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/rGvHdJnr2l75qb0YND9NyBJtnKITppOI_IvcXXDNrsc.woff2)format('woff2');unicode-range:U+1F00-1FFF;}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/mx9Uck6uB63VIKFYnEMXrRJtnKITppOI_IvcXXDNrsc.woff2)format('woff2');unicode-range:U+0370-03FF;}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/mbmhprMH69Zi6eEPBYVFhRJtnKITppOI_IvcXXDNrsc.woff2)format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+1EA0-1EF9,U+20AB;}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/oOeFwZNlrTefzLYmlVV1UBJtnKITppOI_IvcXXDNrsc.woff2)format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/RxZJdnzeo3R5zSexge8UUVtXRa8TVwTICgirnJhmVJw.woff2)format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2)format('woff2');unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2)format('woff2');unicode-range:U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/-2n2p-_Y08sg57CNWQfKNvesZW2xOQ-xsNqO47m55DA.woff2)format('woff2');unicode-range:U+1F00-1FFF;}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/u0TOpm082MNkS5K0Q4rhqvesZW2xOQ-xsNqO47m55DA.woff2)format('woff2');unicode-range:U+0370-03FF;}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/NdF9MtnOpLzo-noMoG0miPesZW2xOQ-xsNqO47m55DA.woff2)format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+1EA0-1EF9,U+20AB;}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/Fcx7Wwv8OzT71A3E1XOAjvesZW2xOQ-xsNqO47m55DA.woff2)format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/CWB0XYA8bzo0kSThX0UTuA.woff2)format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}</style><script name="www-roboto" >if (document.fonts && document.fonts.load) {document.fonts.load("400 10pt Roboto", "");document.fonts.load("500 10pt Roboto", "");}</script> <link rel="stylesheet" href="/yts/cssbin/www-player-webp-vfl-cDqNB.css" name="www-player"> <style>html {overflow: hidden; }body {font: 12px Roboto, Arial, sans-serif;background-color: #000;color: #fff;height: 100%;width: 100%;overflow: hidden;position: absolute;margin: 0;padding: 0;}#player {width: 100%;height: 100%;}h1 {text-align: center;color: #fff;}.hid {display: none;}h3 {margin-top: 6px;margin-bottom: 3px;}.player-unavailable {position: absolute;top: 0;left: 0;right: 0;bottom: 0;padding: 25px;font-size: 13px;background: url(/img/meh7.png) 50% 65% no-repeat;}.player-unavailable .message {text-align: left; margin: 0 -5px 15px;padding: 0 5px 14px;border-bottom: 1px solid #888;font-size: 19px;font-weight: normal;}.player-unavailable a {color: #167ac6;text-decoration: none;}.yt-embed-thumbnail {background-size: cover;background-position: center;background-repeat: no-repeat;height: 100%;}.ytp-lightweight {position: absolute;top: 0;left: 0;width: 100%;height: 100%;}.exp-invert-logo #header:before, .exp-invert-logo .ypc-join-family-header .logo, .exp-invert-logo #footer-logo .footer-logo-icon, .exp-invert-logo #yt-masthead #logo-container .logo, .exp-invert-logo #masthead #logo-container, .exp-invert-logo .admin-masthead-logo a, .exp-invert-logo #yt-sidebar-styleguide-logo #logo { background: no-repeat url(/yts/img/ringo/hitchhiker/logo_small_2x-vfl4_cFqn.png); background-size: 100px 30px; } .exp-invert-logo #yt-masthead #logo-container .logo-red { background: no-repeat url(/yts/img/ringo/hitchhiker/logo_youtube_red_2x-vflOSHA_n.png); background-size: 132px 30px; } @media only screen and (min-width: 0px) and (max-width: 498px), only screen and (min-width: 499px) and (max-width: 704px) { .exp-invert-logo.exp-responsive #yt-masthead #logo-container { background: no-repeat url(/yts/img/ringo/hitchhiker/yt_play_logo_2x-vflXx5Pg3.png); background-size: 40px 28px; } } .guide-sort-container {display: none}</style><script >var ytcsi = {gt: function(n) {n = (n || '') + 'data_';return ytcsi[n] || (ytcsi[n] = {tick: {},info: {}});},now: window.performance && window.performance.timing &&window.performance.now ? function() {return window.performance.timing.navigationStart + window.performance.now();} : function() {return (new Date()).getTime();},tick: function(l, t, n) {ticks = ytcsi.gt(n).tick;var v = t || ytcsi.now();if (ticks[l]) {ticks['_' + l] = (ticks['_' + l] || [ticks[l]]);ticks['_' + l].push(v);}ticks[l] = v;},info: function(k, v, n) {ytcsi.gt(n).info[k] = v;},setStart: function(s, t, n) {ytcsi.info('yt_sts', s, n);ytcsi.tick('_start', t, n);}};(function(w, d) {ytcsi.setStart('dhs', w.performance ? w.performance.timing.responseStart : null);var isPrerender = (d.visibilityState || d.webkitVisibilityState) == 'prerender';var vName = (!d.visibilityState && d.webkitVisibilityState)? 'webkitvisibilitychange' : 'visibilitychange';if (isPrerender) {ytcsi.info('prerender', 1);var startTick = function() {ytcsi.setStart('dhs');d.removeEventListener(vName, startTick);};d.addEventListener(vName, startTick, false);}if (d.addEventListener) {d.addEventListener(vName, function() {ytcsi.tick('vc');}, false);}var slt = function(el, t) {setTimeout(function() {var n = ytcsi.now();el.loadTime = n;if (el.slt) {el.slt();}}, t);};w.__ytRIL = function(el) {if (!el.getAttribute('data-thumb')) {if (w.requestAnimationFrame) {w.requestAnimationFrame(function() {slt(el, 0);});} else {slt(el, 16);}}};})(window, document);</script><script >var ytcfg = {d: function() {return (window.yt && yt.config_) || ytcfg.data_ || (ytcfg.data_ = {});},get: function(k, o) {return (k in ytcfg.d()) ? ytcfg.d()[k] : o;},set: function() {var a = arguments;if (a.length > 1) {ytcfg.d()[a[0]] = a[1];} else {for (var k in a[0]) {ytcfg.d()[k] = a[0][k];}}}};</script> <script src="/yts/jsbin/www-embed-player-vflZppemJ/www-embed-player.js" type="text/javascript" name="www-embed-player/www-embed-player" ></script> <script src="/yts/jsbin/player-vfl8swg2e/en_GB/base.js" name="player/base" ></script> <title>Mally Mall, Jeremih, E-40 - Physical (Official Video) - YouTube</title> <link rel="canonical" href="https://www.youtube.com/watch?v=H9hrWLoz4RY"> </head> <body id="" class="date-20180216 en_GB ltr exp-invert-logo exp-responsive exp-search-big-thumbs site-center-aligned site-as-giant-card webkit webkit-537" dir="ltr"> <div id="player"></div><script >yt.setConfig({'EVENT_ID': "K16LWsCyBpWtWNqfv5gJ",'VIDEO_ID': "dRnrjyJV25I",'WIDGET_ID': 1,'ENABLE_JS_API': true,'POST_MESSAGE_ORIGIN': "https:\/\/tpc.googlesyndication.com",'BG_P': "dKWCz0dJDGki1+aB6rEnSGwmv+9XPiK2qX6c9O49vH2H0oP6yHQnDc2jfcDRI4fOtn5z3MnYZrBxBRXkd+TdhA2OwGuXTf8HDao2K\/0vBKBTtyJy3r+E8D2tYR1SaCS5cExqv\/Dw+JgWW\/kxgvV0XtIXqM5UV6rPzNXmE+mn4caFiB19sw2O+\/gCQI59YsIOG\/8o0cb\/edRP6aYZxom7ksBYk5lTe\/\/\/2C954\/lulZU8pVE9ZBc0M7WVdXUZPI0NgoQyJINxqMr7p8iJKP\/+aR8pgIlzfLh5gLu+RMoqk6i6CyYhTFTheQDfZ21k278AgLkcIRW4Yq7UooRZ8Fb86agmieUCjv6AKLQiqg11IRa84HKRv33RlvfsL6ermUsRWYpL0yVUrFht00iTtb1VtsFMZkpvD6fmty9q1BCjm53qYCfjOuSPwG2fZ+m8Sdr6Aai+IHolOInvPNg+18KzDN7hjaGV7g0hznpIoBpkVj7zKpwptiMRzugjDl6xPoghiDr4a7zjnQ7ircIeOhgG0OXPZjRH7N94LVz\/wuef+qvx5PscMuUdwJKFi6Dm6JkybadQkCL\/\/U0IHAKyWnQwC68F4CgYXtq29Xh4Ujy83zNQO6F+e3G\/g2Az\/IO65EsKNBP4Rc5OCZOWfnKQa9oAvK\/D06qFz9A3C9rH0EOAmsI9w5T0etHWI30Q+owKsWKYcpZB0JgPL2jLU1hTIp5ouNWHKITADwxd6YDrQcSK8iBrrx4+bf7aVNhecUz4umnYKHOtRNutgzpSkSLGhtSZG8TipNWmpFCpo7TqZpmaBWnpMmX1\/g8oDJ0tsWM\/7u6+9LcylSwRoKgKx+1mxUG8mLmmgNQLdE+yirZcalCqPs+LbKMaINE+S4E8tglicM11Zg7Ducvf3aKr9IqenBoHFp+nlwgD2ayalI1dgJvjWWyhlI8uvAkxVvAklwqEwGUTdW4\/NsjXwr0CkaeJxJncijP5n9GzCqrRtVqbDJ9rKkgQVV5VNPCxZZ6uzzhGYHr4hC8Xc5ftLNATZW2r5nIGCroRDGVY9o3rDVD2tvwVUo03ygnEv0zBLvUagENw3pM69nsc2sDyWq8\/GWOUurRzEsczAJjAb6wZXpbhvUwhf3iJbLyZYh0XF44l4qsP8Fb+ImoSDewfvAEY8eIYTjoCO849Dlm8h2Uv90SBXmh9QYDHRnxAgh5TnULFpKJMAcZIXDc2TBmtO3v4TURF4RAoNXJDkhcfnbN2mcwE+6Wa5ZhQR1VDz5FGkAVQEwlTSuTlsWtAI\/gbLIwqA+jQlr8WRcmAJIVI+gEMbHWlp51LGKLzDfO\/+Z+IUexPVj52oZRBUY4kIS7ow8MaLVywLk4v6cI3BWKeU25Dff1l6mu8aHMyS8xPi+YAVtmY8D2e3MZ8omEDo0rxC41cPn7vYs\/7PYXid8J7wQKg0Y5TElOSBqnY3pkwiXpCxZPKRQyo7gQyVgvQ6A2\/2hDvg9p6iGcSvH0xLZQc+0FiMH67ckl8bY+mdqWO24ssbgZsxCM5AXByTejsaLAPVpFqCXjfCDMB3UYtyj0YVSdSZCgygWy9d+4LOEjSdHAHoudrD43xZoj0DlOVoCnusmLr7jZqkR5j236XY\/UjIcwU+5eXB0FHzUlRwy+odtDeLEYwckulfYGEOqY1HderHonc5mfBjrilgL4tz+P9kqXkp4NICKFTATG35nw2ySgI2GYX7oNbJF7cKeRlzV7m9vD+lC6YLPASKC+W4X6m8gGOdCWXB5m2OZmU+RXOwCP9Y9D3mbqF1OIw+iaqLPU5bhZSH\/LWj3EDNiANdEHh\/AiapjnWFqwt\/sGqF+LhTKFSqaKIdjCmC21L4bUineXi9mO5UzzYedgSpMvDbefRkcS7B84zrzplctujC+n+TOXzFmXqo2RlxulytuPLkwwinaMCkqsRSj2Ivx+h6NylzuXn6ir3ql71I262HZ9FEOr2eZDBxyJFAVFJekqKcTcto3pO1P1sHjKw4iEaXaMKJjACbe9StSsN\/MbihfBRkjGseUdja0hvLhyWKr8SZyTKmRzYPuCyu12947GgHwRKk6AV45FZ41ggD4KT8nIlo0+i3A0v5u9W\/BH0BOpMeVDbPkf5Y1l+jnIwcswJQCEnRLXqVBMBXIT8KtdFKJr7vaSKHd7Zny5w3aL6GWPZQH3jFwSn4+8YB+PWjRrRNJeQBY2NLzW7BSPaSRzdp\/NDx8mTxVDbB7rWdzdd7+D4VEzWEY2vtf2jAKOOdX+CCk+7ek3IMe8+ioOxkfo5EBygEYfuvOQPuBrFsZM4liU\/Rk4uFTS91PoreCuAJThzOGMxW7Elx8GSI9U9tHUHOs2hcnBqhqd4LTz5pbR2ZCxztC0AzWts1i\/bInebZATIXzKPdGw5OUVi9P6fJYt3vi4zhzyvpRp5M1RGzsPgedDp16yHaFXR+nGfWqRfOAqFFVnjz0e06mbZ3M5cZyIepsyiN45iHdM5\/YfZCj9Bk1Rru134h6CJPRIBOVG1ya\/Yhs6OQ6MZj5QyUgLxjdYpm65HYLt+Qy8nYFth9QLbMR32P2gEf7Kc88zo4Tcc3H0AqKTZ02QEUiD7wfc0ZVIPqtGhiHYGIPEEhhIkdyQlBJKsNtjMg1Zoq8y8agKmRaKY1CHp4+GaDVKUIInFNR\/Ge5S5TeYXJVJ0hFqLO1E52U3hUxcBq90iKQq2tzfXhCZy+D9zD7zh1qEPGxpkdU4gaSACwqUbWBTocVB0bQn0VNDKQpVxggIXItmg7gTHYOThV7eMpYHO8sRxgPhsBnKsjU2xuXud57bcooCQrPc19bIDN3FiXqJJ4OkfLC9IV2OcTqOUeVMDIvX84sXPfvMPT63veg3nQcSD0aaZeIkX8p2Uepg9pwZQrkbdviR0D0RSzbem2B1IOml7t2YhantgBJ0JXyjCM6PiEoVuQ4J20gmrEy4va+CEdBWEfUWiQNxwTFPE1h9GxSX5VwaUqQ\/AUZ4ytahxxxTY8ff6dv1PvfGPI4MuWjhhCRzP50nrHdFOPNCPRkXeVsQ4bNM17+SYwdaxCpL0u0AcaURx5TawNUG1hgaxyhZVLwrGUlDPoYtA1tPZU7O8m+uSCkaw\/xHZn+aNjTZ4Dxct00uCS1j2qpWQ1ZR1bx5MLeh5z\/W8ukJ1+OV157+wHIBDai6YZlWhQdfHWdd+mEoxNtPwUMdj\/bVTnz4uBZub3tx+6tu0okS53Nni2SPGzu751R2J1wwVC44nzpyVlW386xdFwSu4bcaKt94VRZdgn3mpfAF2oTMll8WZJ9E\/tGv58g24GCnNRbAtqmWPoPttpYKGdKaS4\/zwsZSKoWxMi6tRcIOko7MR0KBW4dbOvX3RldaMyImkJJJPL5o0pHLH+W5S6MJnT\/u4HK8203BFaYVunqveCrslHmpR+Oeag33htt94xJsJcek1VSyxnLEboOn9sBDQw\/go4zs3+PZVZH4uw3UBn1CRl70Z9cL1jF4CA+oe2l03+gNkhvIiW9sCJcu8Ozl9nb4Mz3Rn+b2XIYOHgX\/o0BEKDt9zLB9r03G2u2JKvYIjF\/fF8Gg0\/IKDc8J4+VTGucVfg9IWuRvDcYOyYzYVroAuWqDGKrUf6OSVlaUJzgy9+++5a5FZnEBiWKoUIBvjqYCtM24H5ks\/nnF6LYRFbgkfWjcH0W8Tu4QkXfgHwwc2W0JVS1M199+bqwHDuxsfmqja5LvIl07rq87eAZx5a09ch2Yal1XziQunDUm+h5X+itXULQKuDjpqlD2KyUDKOHWjctHPMgRXAK+ax+G4QNEoDXrgBshfX0BoFIpX\/guICgq\/QGHLZXRRLNiYuKJjCYxxhSvOnCoyN6wMs7AwKOXlXIKegFxhXqMiiM9C+ulzbVCnjn6+l57bufyWQCTPWw70WOdEry4MjGIUgtKZ6L8Jv3FxkzcFpWHB4QkLl3OrIXYT\/N17pJx68cbz1Va75PxJBw2F5KMm\/vfcfYmvIAvtePWpliVgZzvRVYeDrV\/JaTyRbh+o070qo6w86dBgtNJymcw2gjmcoKUBcF2vBJZihZ2KwW+tZ4omGgi58Lh+q+w2Fx6rkqQ9bK\/Vc+kQrKn0cYmHO0BwTAyS3\/LDCxVa79DT+43VjSsFmugX8DcYt51oNO+j\/WTFkwXsu73125M0I0rZqxuGwM4qgO+fSeTMi6fuQI\/mRKtZhSZhy6wrAb3tnGQZw+cGTxHCRoLwPznPcer5VnFcMMTKeETrVM4UFQJcQsQIp6EKfItWvW+5HDZ2O5BmzgPNJMbWp0aaQVztYdWoDprwRqfUGINsz1058pv9o\/Eq7GWDBE8i\/iYCjrQ6cPAA0KVWPaSlxECl\/9JxQIQYTzwhE87p5wrT\/jGVsq3IJr22cPiICTszRkQKsIngStCc9uT\/\/LycjGd\/CFjcg51EBy8aR6qHFFBmky4N77R86h6+8xOAk2YrUyiQpi31o69Gn3ib3BtuypTCdZAsJjcOngAJebbQKFQ6OsPMtLFkm9cjhgR7xecsOkilAFgnwnuWDHK4Q2m8RlcOFyyUw\/\/qBnNQ+p+B42sQPq67Y5VpY5A1TOlpYysaoZRQtxZjtI46cnGpjQSoeagHDe8cOgDgiAVLqmFxC3MAddLfmcbIc8NgY2vFtO3rUoEozkdx6hzgejo+7i0eExw620IftK+DvckUPt3NaRKaElahNKfQX31HG83zVSKYy1IXxx+UQm8L9dFcR84Z2AbKTdiKEjjtEOJiLxMNxCeGD+61GJ6eA7FFMRniqLvFy55MyICpP987sryPV\/intEEoJwdWTMLQ\/s\/8nm+psajYvGjxWeeJk5DIEd9bv+K7E9jtHXO4apeOgPNbTZULQPQG3C0k5vDbo0k6v3hafR+\/bvXhisFyRZsK2OMAN2dwJpi4LzMSYpOZjxzJFPbgEH2kNL1Ep6AJ9dPwZ8QdSvGivUP1LN6EnP5AxOBGaMOSipLAJU7znt7pZ14HngVBnNruk5jzyYNArQiKuBxx8x13l8vvRClutKaDDhjimfQAK3zXWfONmF2+48XjLRjI0Zm0ma9JfyaHG+ZS88c+qA0f1xdJK+CGxCaZFuNwzZ2dvFzrr3fEDgmGufsHLxwOBhLvVs0OSkHl\/JKsHKbV0uMNZuMnyeoadxgb0Q3IlBZLoyMRxVzHNC+TL2KtWmr5tRMBK9MajSWUdNe+4ittuE8CoOTo1NzEO5vGabBa2cs424y3+dquj3uob96RsvAzl6FyFlORPFgfJS0EGDpICtxN5KgwN0qlRJvFwNo24OXcmjqPniSJbvhRrJWaWZwiM+edRsJ+fyHsbKA2owE44YRUKlzguTcTw1osxoyJXIkMgFMiIz52z8oIHL4ceW5Df0Rwf\/zcMOXVtFHrdo2AkseFLN3uemO+t6wSn3NF\/lyCTL6q0t7+lrYVT7lpL3PYiR\/s2HDGNu9BSAQcK8Irrvj5ivDEH21zey5JgWelb9QEZJeyNwdVWyK2JqXuCzVLGAJVO9q+m2\/ibClLJRdrAk0fqVXB9fNcvlyrtsl3ftTrbuDBgg73AFvEO1dLor+g8XjSWka1sVYKlx6QsxwGQbAixMn3zxoCAvRp2HC9ZHNxAQ0WpbhvT\/aFRhLS1xyt9NYKYsHl7DLh9ft2tTn0N6L02w9cmPRlVMJvt8wqyW11DsG+l5OyDJscu5163QExZp7pC1PyLtg\/9OKhFG3LP2tEljXThZWeBkKo5hCRqSKsi016m+X3jc7J134Bm4Jb5jHwD8RtCetfol4SXRmWsg1yZLB2R8Qs99cSCHU9GhP589RTogpxHvMOMRRHwuqXceHbY+7hctY5vfYPGyWlMppNujj1FR0AIUmSF7swpLE5oeyQAGBqTEUrEaS24i5Q9Xlm5145pZN10KjwxNsMG5lGYM7yUtUarEP4Eh29VS7Pah8I1ukhVun0han96x6TduEZ5DWA6LXIrGSvexbGpG34PSN793+QL3KcItqLMnzQAQgrkjyoAcyy8hxPGC39CUZg2SSUZfxkazvKH3OoGcIlPTjiqRwoQ+cjU3tMmW8vL5TOH407DhHMOwuH8KKlWhIFmfvz6RHn260xkui0yCn7okCWkldYuaJ0bfalVQN1tEgCkAHgDISCJ4T59eOR5fImjbpJRKTrSDSMvzoWM1CBMAEuWJ\/cRWS1GxF3YrDeZX9W21qe3XnhnvGZec\/\/6IsXa4qTPkj0alIWuTDHBntZRM3\/HmVCzgqT2CDzQAyh9nDwtIzhcMRLbJd\/aCJmvI3Y+S+VSzUPzMlr2Mgiye6ynZzaPPZH\/XwbpbHntIOrxMCd878PdAs6S4ZYhkRP2VN54mpeBWOrEAvUKgvW9gwqQnMy4dDlBY27bDlD+qc6zoLicoxp1m00gFJsfzxM0+e4i3UzbkjjmBC5NJ+FTNzome2Xtad9R3cVUF5ruaysclUJfj+pPrdpm\/bBzJLg3+C2UuE1ayjipn0zfnpn0ZF3fyOFCoGXvSBwtlY+PxaU31Rrl1uMHemCaeAaKGr2+\/A07ri7vtaR2uF8eq\/IIPhAfax8F52FgoIFVmf1e\/634XbKJ40RcULwX3+T94aYCu07DRglf+wS1OAOIyYf3SmT1GQCZosHSZQsrnwO\/VuLvKxcMrjtNXQP1pdPLn0jogbx4FwHv5oQ1fTYmXljAPVKArZomA8iS5fO115VXU7ca7lhgkTVaALvX1CXLNIAu0mU+aSnam+iuYLrZyJMD\/ZWGkq8GPaFzxp00A3zVmwEENnOOCC8OLRBie0GSVQljNdy5uy\/61FyrnGwUbScu6WxgSbWl45mu0pJ1sdQl6u7jAZvnPBFFhfcSbINTzpr1BgD69cyRJDGqTctiuzFHGi2N+ODnS+iVQW0k5xNYYoh3yo4DThyyDjv+XplyCDkoehs1nZILTlI5big5pKl\/XW+3ngfPG7\/Ey5Mf2aRSjolhaZqA\/aNCxy3em7JsRpRkYa97pJlsc1\/Vq3RmUrCouBtMo5IWnn\/wS7thIHYP7UxsWL6J\/4j4wS+cTQ\/cG0CPX6fSUyJZPATaBarQPL1VRo7CnyzYHibdS0+SVrWtO3X1lbvY7a0j7i6WzSFP\/Z1L4bVI+5i5scx7dANXGieCkD2Ds7zryVmAxMoHGgNRwgJQEpprEi0b\/5JyHWcBPPt4QIYsAzXyTv+BQj4HPTmCwDFLok1qHvu4j2ifAGoAaTYfmdJiJmvJWoJyZEgjinJQ+c+eEjAwCEK6gRigee9giqH\/0EpC2CF+qRFYJ0O+MlPDqpUjpcruCVhgkWWk8hZxUz02lb5m3b4iQhLRawk+uM2Q+V7st2emmPcEoZ977FQYq878CBB41tCoEj1FGTI1xux8YCKoiri2Z45\/lpsyN1TTsnyhp8Cu5fbYg7G+vgqN3KngpddGVtg3oOfaaK6nCpSeoW33PnVQfRKvHlG035ukF+zng5b2QKjpvJiEoVuWwz",'BG_IU': "\/\/www.google.com\/js\/bg\/IOA8y9bJh23yzX_Xx1Lzdpvil-FmhhSrkRF2am8kUAc.js",'XSRF_TOKEN': 'QUFFLUhqbndabm03VVIyaE54RkZXamNJZEJpbk5VZnZMd3xBQ3Jtc0traFhNZm4tT3h5aTlMVk53MGw1Y2l1aktWYklXQlRFX0tfZUdFNXctMlQ2N19DdnM3NnFQT21EQzJpUFc1ZzBRMl9BQjB5V2w4RzJlcE11NTlZUkxEaGs2ekJ1SkJMX2VEdHdHclJfSVZzS1ZjaUlhWk1BcFR6SHk1cFAxeVRNR3J1V0dNZ1BKamtGeFk2Qnhpd2hTM0xDWFRlX2c=','XSRF_FIELD_NAME': 'session_token','EURL': "https:\/\/tpc.googlesyndication.com\/safeframe\/1-0-14\/html\/container.html"});yt.setConfig({APIARY_HOST: "",INNERTUBE_API_KEY: "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8",INNERTUBE_CONTEXT_CLIENT_VERSION: "20180215",XHR_APIARY_HOST: "youtubei.youtube.com",INNERTUBE_API_VERSION: "v1",INNERTUBE_CONTEXT_CLIENT_NAME: 56,GAPI_HINT_PARAMS: "m;\/_\/scs\/abc-static\/_\/js\/k=gapi.gapi.en.HtLvrA_npCQ.O\/m=__features__\/am=AAE\/rt=j\/d=1\/rs=AHpOoo8wHQU_A1WtgGgcOpQEfGjHuD8e-g",APIARY_HOST_FIRSTPARTY: "",'VISITOR_DATA': "Cgt1NFBiOHktb3hScw%3D%3D",'DELEGATED_SESSION_ID': null,'GAPI_HOST': "https:\/\/apis.google.com",'GAPI_LOCALE': "en_GB",'INNERTUBE_CONTEXT_HL': "en-GB",'INNERTUBE_CONTEXT_GL': "MA",'XHR_APIARY_HOST': "youtubei.youtube.com"});ytcfg.set("ROOT_VE_TYPE", 16623);ytcfg.set("EVENT_ID", "K16LWsCyBpWtWNqfv5gJ");yt.setConfig({'PLAYER_CONFIG': {"assets":{"css":"\/yts\/cssbin\/player-vflWsxn7B\/www-player-webp.css","js":"\/yts\/jsbin\/player-vfl8swg2e\/en_GB\/base.js"},"attrs":{"height":"100%","id":"video-player","width":"100%"},"args":{"iurlhq720_webp":"https:\/\/i.ytimg.com\/vi_webp\/dRnrjyJV25I\/hq720.webp","avg_rating":4.8042813456,"cr":"MA","el":"detailpage","user_display_image":"https:\/\/lh4.googleusercontent.com\/-PPVxqpJidSc\/AAAAAAAAAAI\/AAAAAAAAAW8\/8wD5R1-5bCQ\/photo.jpg","profile_picture":"https:\/\/yt3.ggpht.com\/--7rnjwnIDQw\/AAAAAAAAAAI\/AAAAAAAAAAA\/3GRM5B1PXjs\/s68-c-k-no-mo-rj-c0xffffff\/photo.jpg","vq":"tiny","iurl":"https:\/\/i.ytimg.com\/vi\/dRnrjyJV25I\/hqdefault.jpg","fflags":"html5_default_ad_gain=0.5\u0026mweb_muted_autoplay_animation=shrink\u0026player_external_control_on_classic_desktop=true\u0026html5_tight_max_buffer_allowed_impaired_time=0.0\u0026html5_msi_error_fallback=true\u0026html5_minimum_readahead_seconds=0.0\u0026html5_stall_pctile=true\u0026html5_use_adaptive_live_readahead=true\u0026flex_theater_mode=true\u0026html5_ignore_bad_bitrates=true\u0026html5_sticky_disables_variability=true\u0026html5_live_abr_head_miss_fraction=0.0\u0026html5_min_readbehind_secs=0\u0026enable_live_state_auth=true\u0026html5_break_deadlocks=true\u0026enable_bulleit_lidar_integration=true\u0026html5_mweb_client_cap=true\u0026player_destroy_old_version=true\u0026disable_max_adsense_channel_limit=true\u0026html5_enable_bandwidth_estimation_type=true\u0026embed_show_watchlater_login=true\u0026html5_parse_inline_fallback_host=true\u0026allow_live_autoplay=true\u0026sdk_ad_prefetch_time_seconds=-1\u0026stop_using_ima_sdk_gpt_request_activity=true\u0026html5_background_quality_cap=360\u0026enable_spherical_ps4=true\u0026html5_serverside_biscotti_id_wait_ms=1000\u0026html5_use_has_subfragmented_fmp4=true\u0026limit_of_rebuffering_event_on_html5=1000\u0026html5_bandwidth_window_size=0\u0026vss_dni_delayping=0\u0026html5_vp9_live_blacklist_edge=true\u0026web_player_api_logging_fraction=0.01\u0026fixed_padding_skip_button=true\u0026html5_hopeless_mode_request_size_secs=15\u0026html5_player_autonav_logging=true\u0026sdk_wrapper_levels_allowed=0\u0026html5_live_normal_latency_bandwidth_window=0.0\u0026html5_composite_stall=true\u0026html5_new_peg_to_live_v2=true\u0026show_thumbnail_behind_ypc_offer_module=true\u0026enable_afv_div_reset_in_kevlar=true\u0026html5_min_buffer_to_resume=6\u0026html5_el_migration=true\u0026html5_quality_cap_min_age_secs=0\u0026playready_on_borg=true\u0026html5_max_buffer_duration=0\u0026html5_live_low_latency_bandwidth_window=0.0\u0026html5_progressive_signature_reload=true\u0026html5_suspended_state=true\u0026variable_load_timeout_ms=0\u0026html5_report_conn=true\u0026html5_incremental_parser_buffer_duration_secs=1.5\u0026html5_disable_urgent_upgrade_for_quality=true\u0026html5_strip_emsg=true\u0026html5_start_off_live=0\u0026html5_ad_stats_bearer=true\u0026html5_streaming_xhr_progress_includes_latest=true\u0026html5_manifestless_no_redundant_seek_to_head=true\u0026html5_maximum_readahead_seconds=0.0\u0026html5_drm_generate_request_delay=0\u0026spacecast_uniplayer_decorate_manifest=true\u0026use_new_style=true\u0026live_readahead_seconds_multiplier=0.8\u0026mweb_playsinline=true\u0026html5_enable_embedded_player_visibility_signals=true\u0026html5_video_tbd_min_kb=0\u0026disable_set_awesome_html5=true\u0026html5_new_autoplay_redux=true\u0026enable_prefetch_for_postrolls=true\u0026dynamic_ad_break_pause_threshold_sec=0\u0026html5_preload_size_excludes_metadata=true\u0026html5_mobile_perf_cap_240=true\u0026html5_subsegment_readahead_min_buffer_health_secs=0.25\u0026ad_video_end_renderer_duration_milliseconds=7000\u0026html5_hls_initial_bitrate=0\u0026mpu_visible_threshold_count=2\u0026html5_disable_preserve_reference=true\u0026html5_live_4k_more_buffer=true\u0026html5_suspend_manifest_on_pause=true\u0026html5_enable_mesh_projection=true\u0026html5_incremental_parser_coalesce_slice_buffers=true\u0026mweb_muted_autoplay=true\u0026send_html5_api_stats_ads_abandon=true\u0026uniplayer_dbp=true\u0026dash_manifest_version=5\u0026mweb_enable_skippables_on_iphone=true\u0026html5_platform_minimum_readahead_seconds=0.0\u0026html5_disable_non_contiguous=true\u0026html5_live_abr_repredict_fraction=0.0\u0026html5_disable_move_pssh_to_moov=true\u0026show_thumbnail_on_standard=true\u0026html5_ultra_low_latency_streaming_responses=true\u0026html5_adjust_effective_request_size=true\u0026html5_restrict_streaming_xhr_on_sqless_requests=true\u0026youtubei_for_web=true\u0026html5_ad_no_buffer_abort_after_skippable=true\u0026interaction_click_on_gel_web=true\u0026html5_disable_webgl_antialias=true\u0026autoplay_time=10000\u0026html5_stale_dash_manifest_retry_factor=1.0\u0026html5_widevine_robustness_strings=true\u0026web_embedded_player_service=true\u0026html5_max_headm_for_streaming_xhr=0\u0026kevlar_allow_multistep_video_init=true\u0026deprecate_get_video_metadata=true\u0026html5_enable_ms_playready_hd=true\u0026html5_qoe_unstarted_in_initialization=true\u0026lightweight_watch_video_swf=true\u0026disable_mweb_iphone_ad_click_handling_functionality=true\u0026live_fresca_v2=true\u0026mweb_cougar_big_controls=true\u0026html5_serverside_call_server_on_biscotti_timeout=true\u0026html5_request_sizing_multiplier=0.8\u0026disable_set_awesome_mweb=true\u0026html5_live_probe_primary_host=true\u0026html5_connect_timeout_secs=7.0\u0026html5_min_readbehind_cap_secs=0\u0026player_unified_fullscreen_transitions=true\u0026html5_qoe_intercept=\u0026postroll_notify_time_seconds=5\u0026mweb_cougar_ads_backend=true\u0026html5_allowable_liveness_drift_chunks=2\u0026html5_suspend_loader=true\u0026html5_stop_video_in_cancel_playback=true\u0026html5_live_only_disable_loader=true\u0026live_chunk_readahead=3\u0026html5_prefer_server_bwe3=true\u0026disable_new_pause_state3=true\u0026html5_get_video_info_timeout_ms=0\u0026html5_new_fallback=true\u0026legacy_autoplay_flag=true\u0026html5_post_interrupt_readahead=20\u0026fix_gpt_pos_params=true\u0026persist_text_on_preview_button=true\u0026forced_brand_precap_duration_ms=2000\u0026html5_min_startup_smooth_target=10.0\u0026dynamic_ad_break_seek_threshold_sec=0\u0026html5_min_secs_over_max_bytes=true\u0026disable_client_side_midroll_freq_capping=true\u0026html5_subsegment_readahead_timeout_secs=2.0\u0026html5_ignore_public_setPlaybackQuality=true\u0026html5_vp9_live_whitelist=true\u0026html5_subsegment_readahead_min_buffer_health_secs_on_timeout=0.1\u0026html5_variability_discount=0.5\u0026html5_subsegment_readahead_progress_timeout_fraction=0.8\u0026html5_request_size_min_secs=0.0\u0026fast_autonav_in_background=true\u0026website_actions_throttle_percentage=1.0\u0026html5_streaming_xhr_optimize_lengthless_mp4=true\u0026disable_trusted_ad_domains_player_check=true\u0026html5_live_pin_to_tail=true\u0026mweb_autonav=true\u0026use_fast_fade_in_0s=true\u0026html5_jumbo_ull_subsegment_readahead_target=1.0\u0026html5_error_reload_cooldown_ms=30000\u0026html5_deadzone_multiplier=1.0\u0026html5_min_secs_between_format_selections=8.0\u0026html5_streaming_xhr_buffer_mdat=true\u0026html5_get_video_info_promiseajax=true\u0026html5_subsegment_readahead_always_delay_appends=true\u0026skip_restore_on_abandon_in_bulleit=true\u0026html5_license_constraint_delay=5000\u0026html5_max_av_sync_drift=50\u0026html5_manifestless_accurate_sliceinfo=true\u0026html5_repredict_interval_secs=0.0\u0026html5_new_e2e_latency_tracking=true\u0026html5_subsegment_readahead_tail_margin_secs=0.2\u0026disable_indisplay_adunit_on_embedded=true\u0026playready_first_play_expiration=-1\u0026html5_max_buffer_health_for_downgrade=15\u0026html5_throttle_rate=0.0\u0026html5_aspect_from_adaptive_format=true\u0026html5_live_ultra_low_latency_bandwidth_window=0.0\u0026tvhtml5_background_su=true\u0026html5_elbow_tracking_tweaks=true\u0026mweb_cougar=true\u0026html5_min_upgrade_health=0\u0026html5_adunit_from_adformat=true\u0026html5_serverside_call_server_on_biscotti_error=true\u0026web_player_disable_flash_playerproxy=true\u0026disable_reporting_html5_no_vast_ads_as_error=true\u0026html5_env_data_update_app_only=true\u0026html5_incremental_parser_buffer_extra_bytes=16384\u0026web_player_edge_autohide_killswitch2=true\u0026html5_reselect_bandwidth_factor=3.0\u0026web_player_tabindex_killswitch=true\u0026html5_reattach_resource_after_timeout_limit=0\u0026html5_subsegment_readahead_target_buffer_health_secs=0.5\u0026html5_throttle_burst_secs=15.0\u0026html5_fludd_suspend=true\u0026html5_tight_max_buffer_allowed_bandwidth_stddevs=0.0\u0026safari_enable_spherical=true\u0026html5_observe_live_start_seconds=true\u0026call_release_video_in_bulleit=true\u0026html5_variability_full_discount_thresh=3.0\u0026html5_pipeline_manifestless=true\u0026use_new_skip_icon=true\u0026html5_spherical_bicubic_mode=1\u0026html5_aux_pctile=true\u0026ad_duration_threshold_for_showing_endcap_seconds=15\u0026html5_subsegment_readahead_controlled_by_buffer_health=true\u0026html5_always_enable_timeouts=true\u0026doubleclick_gpt_retagging=true\u0026use_forced_linebreak_preskip_text=true\u0026midroll_notify_time_seconds=5\u0026max_resolution_for_white_noise=360\u0026html5_no_shadow_env_data_redux=true\u0026html5_default_quality_cap=0\u0026html5_max_readahead_bandwidth_cap=0\u0026use_html5_player_event_timeout=true\u0026html5_sticky_ignore_capped=true\u0026enable_mesh_ps4=true\u0026king_crimson_player_redux=true\u0026mweb_autonav_paddles=true\u0026html5_deferred_source_buffer_creation=true\u0026html5_live_disable_dg_pacing=true\u0026desktop_cleanup_companion_on_instream_begin=true\u0026html5_pipeline_ultra_low_latency=true\u0026html5_disable_audio_slicing=true\u0026html5_clearance_fix=true\u0026show_countdown_on_bumper=true\u0026segment_volume_reporting=true\u0026www_for_videostats=true\u0026html5_pause_video_fix=true\u0026html5_sticky_reduces_discount_by=0.0\u0026html5_request_size_max_secs=31\u0026mweb_playsinline_webview=true\u0026html5_background_cap_idle_secs=60\u0026html5_nnr_downgrade_adjacency=true\u0026html5_variability_no_discount_thresh=1.0\u0026html5_local_max_byterate_lookahead=15\u0026website_actions_cta_redesign=true\u0026html5_readahead_ratelimit=3000\u0026html5_nnr_downgrade_count=4\u0026html5_defer_background_errors=true","ucid":"UCCLZfZNgKxUQsCbPod7iVpw","channel_path":"\/channel\/UCCLZfZNgKxUQsCbPod7iVpw","iurlhq_webp":"https:\/\/i.ytimg.com\/vi_webp\/dRnrjyJV25I\/hqdefault.webp","cosver":"6.1","iurlmaxres":"https:\/\/i.ytimg.com\/vi\/dRnrjyJV25I\/maxresdefault.jpg","enablejsapi":"1","rel":"0","author":"EMPIRE","eventid":"K16LWsCyBpWtWNqfv5gJ","short_view_count_text":"549K views • 15 comments","innertube_api_key":"AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8","embed_config":"{}","iurlmq_webp":"htt