text:
// Type definitions for D3JS d3-time module 1.0
// Project: https://github.com/d3/d3-time/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// Last module patch version validated against: 1.0.4

// ---------------------------------------------------------------
// Interfaces
// ---------------------------------------------------------------

/**
 * A D3 Time Interval
 */
export interface TimeInterval {
    /**
     * Returns a new date representing the latest interval boundary date before or equal to date.
     * This function is an alias for "TimeInterval.floor(date)". For example, timeYear(date) and timeYear.floor(date) are equivalent.
     *
     * For example, timeDay(date) typically returns 12:00 AM local time on the given date.
     *
     * This function is idempotent: if the specified date is already floored to the current interval, a new date with an identical time is returned.
     * Furthermore, the returned date is the minimum expressible value of the associated interval, such that interval.floor(interval.floor(date) - 1) returns the preceeding interval boundary date.
     *
     * Note that the == and === operators do not compare by value with Date objects, and thus you cannot use them to tell whether the specified date has already been floored. Instead, coerce to a number and then compare.
     *
     * This is more reliable than testing whether the time is 12:00 AM, as in some time zones midnight may not exist due to daylight saving.
     *
     * @param date A date object.
     */
    (date: Date): Date;

    /**
     * Returns a new date representing the latest interval boundary date before or equal to date.
     *
     * For example, timeDay.floor(date) typically returns 12:00 AM local time on the given date.
     *
     * This method is idempotent: if the specified date is already floored to the current interval, a new date with an identical time is returned.
     * Furthermore, the returned date is the minimum expressible value of the associated interval, such that interval.floor(interval.floor(date) - 1) returns the preceeding interval boundary date.
     *
     * Note that the == and === operators do not compare by value with Date objects, and thus you cannot use them to tell whether the specified date has already been floored. Instead, coerce to a number and then compare.
     *
     * This is more reliable than testing whether the time is 12:00 AM, as in some time zones midnight may not exist due to daylight saving.
     *
     * @param date A date object.
     */
    floor(date: Date): Date;

    /**
     * Returns a new date representing the closest interval boundary date to date.
     *
     * For example, timeDay.round(date) typically returns 12:00 AM local time on the given date if it is on or before noon,
     * and 12:00 AM of the following day if it is after noon.
     *
     * This method is idempotent: if the specified date is already rounded to the current interval, a new date with an identical time is returned.
     *
     * @param date A date object.
     */
    round(date: Date): Date;

    /**
     * Returns a new date representing the earliest interval boundary date after or equal to date.
     *
     * For example, timeDay.ceil(date) typically returns 12:00 AM local time on the date following the given date.
     *
     * This method is idempotent: if the specified date is already ceilinged to the current interval, a new date with an identical time is returned. Furthermore,
     * the returned date is the maximum expressible value of the associated interval, such that interval.ceil(interval.ceil(date) + 1) returns the following interval boundary date.
     *
     * @param date A date object.
     */
    ceil(date: Date): Date;

    /**
     * Returns a new date equal to date plus step intervals.
     *
     * If step is not specified it defaults to 1.
     *
     * This method does not round the specified date to the interval. For example, if date is today at 5:34 PM,
     * then timeDay.offset(date, 1) returns 5:34 PM tomorrow (even if daylight saving changes!).
     *
     * @param date A date object.
     * @param step An optional number of steps to apply when calculating the offset date. If step is negative, then the returned date will be before the specified date;
     * if step is zero, then a copy of the specified date is returned; if step is not an integer, it is floored.
     */
    offset(date: Date, step?: number): Date;

    /**
     * Returns an array of dates representing every interval boundary after or equal to start (inclusive) and before stop (exclusive).
     *
     * If step is specified, then every step-th boundary will be returned; for example, for the timeDay interval a step of 2 will return every other day.
     * If step is not an integer, it is floored.
     *
     * The first date in the returned array is the earliest boundary after or equal to start; subsequent dates are offset by step intervals and floored.
     * Thus, two overlapping ranges may be inconsistent.
     *
     * To make ranges consistent when a step is specified, use CountableInterval.every instead.
     *
     * @param start A start date object for the range.
     * @param stop A stop date object for the range.
     * @param step An optional number of steps to apply when calculating the dates in the range.
     */
    range(start: Date, stop: Date, step?: number): Date[];

    /**
     * Returns a new interval that is a filtered subset of this interval using the specified test function.
     *
     * @param test A test function which is passed a date and should return true if and only if the specified date should be considered part of the interval.
     */
    filter(test: (date: Date) => boolean): TimeInterval;
}

/**
 * A D3 Countable Time Interval
 */
export interface CountableTimeInterval extends TimeInterval {
    /**
     * Returns the number of interval boundaries after start (exclusive) and before or equal to end (inclusive).
     *
     * Note that this behavior is slightly different than interval.range,
     * because its purpose is to return the zero-based number of the specified end date relative to the specified start date.
     *
     * @param start A start date object.
     * @param start An end date object.
     */
    count(start: Date, end: Date): number;
    /**
     * Returns a filtered view of this interval representing every stepth date.
     *
     * The meaning of step is dependent on this interval's parent interval as defined by the field function.
     *
     * For example, timeMinute.every(15) returns an interval representing every fifteen minutes,
     * starting on the hour: :00, :15, :30, :45, etc. Note that for some intervals, the resulting dates may not be uniformly-spaced;
     * timeDay's parent interval is timeMonth, and thus the interval number resets at the start of each month.
     *
     * If step is not valid, returns null. If step is one, returns this interval.
     *
     * This method can be used in conjunction with interval.range to ensure that two overlapping ranges are consistent.
     *
     * @param step Number of steps.
     */
    every(step: number): TimeInterval | null;
}

// ---------------------------------------------------------------
// Custom (Countable)Interval Factories
// ---------------------------------------------------------------

/**
 * Constructs a new custom interval given the specified floor and offset functions.
 *
 * The returned custom interval is not countable, i.e. does not exposee the methods "count(..)" and "every(...)".
 *
 * @param floor A floor function which takes a single date as an argument and rounds it down to the nearest interval boundary.
 * @param offset An offset function which takes a date and an integer step as arguments and advances the specified date by the specified number of boundaries; the step may be positive, negative or zero.
 */
export function timeInterval(
    floor: (date: Date) => void,
    offset: (date: Date, step: number) => void,
): TimeInterval;
/**
 * Constructs a new custom interval given the specified floor, offset and count functions.
 *
 * The returned custom interval is countable and exposes the methods "count(..)" and "every(...)".
 *
 * Note: due to an internal optimization, the specified count function must not invoke interval.count on other time intervals.
 *
 * @param floor A floor function which takes a single date as an argument and rounds it down to the nearest interval boundary.
 * @param offset An offset function which takes a date and an integer step as arguments and advances the specified date by the specified number of boundaries; the step may be positive, negative or zero.
 * @param count A count function which takes a start date and an end date, already floored to the current interval, and returns the number of boundaries between the start (exclusive) and end (inclusive).
 * Note: due to an internal optimization, the specified count function must not invoke interval.count on other time intervals.
 * @param field An optional field function which takes a date, already floored to the current interval, and returns the field value of the specified date,
 * corresponding to the number of boundaries between this date (exclusive) and the latest previous parent boundary.
 * For example, for the timeDay interval, this returns the number of days since the start of the month. If a field function is not specified,
 * it defaults to counting the number of interval boundaries since the UNIX epoch of January 1, 1970 UTC. The field function defines the behavior of interval.every.
 */
export function timeInterval(
    floor: (date: Date) => void,
    offset: (date: Date, step: number) => void,
    count: (start: Date, end: Date) => number,
    field?: (date: Date) => number
): CountableTimeInterval;

// ---------------------------------------------------------------
// Built-In Factories and Date Array Creators
// ---------------------------------------------------------------

// local time ----------------------------------------------------------

/**
 * Milliseconds Interval in Local Time; the shortest available time unit.
 */
export var timeMillisecond: CountableTimeInterval;

/**
 * This is a convenience alias for timeMillisecond.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeMilliseconds(start: Date, stop: Date, step?: number): Date[];

/**
 * Seconds Interval in Local Time; seconds (e.g., 01:23:45.0000 AM); 1,000 milliseconds.
 */
export var timeSecond: CountableTimeInterval;

/**
 * This is a convenience alias for timeSecond.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeSeconds(start: Date, stop: Date, step?: number): Date[];

/**
 * Minutes Interval in Local Time; minutes (e.g., 01:02:00 AM); 60 seconds. Note that ECMAScript ignores leap seconds.
 */
export var timeMinute: CountableTimeInterval;

/**
 * This is a convenience alias for timeMinute.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeMinutes(start: Date, stop: Date, step?: number): Date[];

/**
 * Hours Interval in Local Time; Hours (e.g., 01:00 AM); 60 minutes.
 *
 * Note that advancing time by one hour in local time can return the same hour or skip an hour due to daylight saving.
 */
export var timeHour: CountableTimeInterval;

/**
 * This is a convenience alias for timeHour.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeHours(start: Date, stop: Date, step?: number): Date[];

/**
 * Days Interval in Local Time; days (e.g., February 7, 2012 at 12:00 AM); typically 24 hours.
 * Days in local time may range from 23 to 25 hours due to daylight saving.
 */
export var timeDay: CountableTimeInterval;

/**
 * This is a convenience alias for timeDay.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeDays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval in Local Time. Alias for sunday; 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeWeek: CountableTimeInterval;

/**
 * This is a convenience alias for timeWeek.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeWeeks(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Sunday-based weeks in Local Time (e.g., February 5, 2012 at 12:00 AM).
 * 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeSunday: CountableTimeInterval;

/**
 * This is a convenience alias for timeSunday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeSundays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Monday-based weeks in Local Time (e.g., February 6, 2012 at 12:00 AM).
 * 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeMonday: CountableTimeInterval;

/**
 * This is a convenience alias for timeMonday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeMondays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Tuesday-based weeks in Local Time (e.g., February 7, 2012 at 12:00 AM).
 * 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeTuesday: CountableTimeInterval;

/**
 * This is a convenience alias for timeTuesday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeTuesdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Wednesday-based weeks in Local Time (e.g., February 8, 2012 at 12:00 AM).
 * 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeWednesday: CountableTimeInterval;

/**
 * This is a convenience alias for timeWednesday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeWednesdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Thursday-based weeks in Local Time (e.g., February 9, 2012 at 12:00 AM).
 * 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeThursday: CountableTimeInterval;

/**
 * This is a convenience alias for timeThursday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeThursdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Friday-based weeks in Local Time (e.g., February 10, 2012 at 12:00 AM).
 * 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeFriday: CountableTimeInterval;

/**
 * This is a convenience alias for timeFriday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeFridays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Saturday-based weeks in Local Time (e.g., February 11, 2012 at 12:00 AM).
 * 7 days and typically 168 hours.
 *
 * Weeks in local time may range from 167 to 169 hours due on daylight saving.
 */
export var timeSaturday: CountableTimeInterval;

/**
 * This is a convenience alias for timeSaturday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeSaturdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Month Interval in Local Time; months (e.g., February 1, 2012 at 12:00 AM); ranges from 28 to 31 days.
 */
export var timeMonth: CountableTimeInterval;

/**
 * This is a convenience alias for timeMonth.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeMonths(start: Date, stop: Date, step?: number): Date[];

/**
 * Year Interval in Local Time; years (e.g., January 1, 2012 at 12:00 AM); ranges from 365 to 366 days.
 */
export var timeYear: CountableTimeInterval;

/**
 * This is a convenience alias for timeYear.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function timeYears(start: Date, stop: Date, step?: number): Date[];

// utc Universal Coordinated Time ----------------------------------------------------------

/**
 * Milliseconds Interval in Univarsal Coordinated Time (UTC); the shortest available time unit.
 */
export var utcMillisecond: CountableTimeInterval;

/**
 * This is a convenience alias for utcMilliesecond.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcMilliseconds(start: Date, stop: Date, step?: number): Date[];

/**
 * Seconds Interval in Univarsal Coordinated Time (UTC); seconds (e.g., 01:23:45.0000 AM); 1,000 milliseconds.
 */
export var utcSecond: CountableTimeInterval;

/**
 * This is a convenience alias for utcSecond.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcSeconds(start: Date, stop: Date, step?: number): Date[];

/**
 * Minutes Interval in Univarsal Coordinated Time (UTC); minutes (e.g., 01:02:00 AM); 60 seconds. Note that ECMAScript ignores leap seconds.
 */
export var utcMinute: CountableTimeInterval;

/**
 * This is a convenience alias for utcMinute.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcMinutes(start: Date, stop: Date, step?: number): Date[];

/**
 * Hours Interval in Univarsal Coordinated Time (UTC); Hours (e.g., 01:00 AM); 60 minutes.
 */
export var utcHour: CountableTimeInterval;

/**
 * This is a convenience alias for utcHour.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcHours(start: Date, stop: Date, step?: number): Date[];

/**
 * Days Interval in Univarsal Coordinated Time (UTC); days (e.g., February 7, 2012 at 12:00 AM); 24 hours.
 */
export var utcDay: CountableTimeInterval;

/**
 * This is a convenience alias for utcDay.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcDays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval in Local Time. Alias for sunday; 7 days and 168 hours.
 *
 */
export var utcWeek: CountableTimeInterval;

/**
 * This is a convenience alias for utcWeek.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcWeeks(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Sunday-based weeks in Univarsal Coordinated Time (UTC) (e.g., February 5, 2012 at 12:00 AM).
 * 7 days and 168 hours.
 */
export var utcSunday: CountableTimeInterval;

/**
 * This is a convenience alias for utcSunday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcSundays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Monday-based weeks in Univarsal Coordinated Time (UTC) (e.g., February 6, 2012 at 12:00 AM).
 * 7 days and 168 hours.
 */
export var utcMonday: CountableTimeInterval;

/**
 * This is a convenience alias for utcMonday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcMondays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Tuesday-based weeks in Univarsal Coordinated Time (UTC) (e.g., February 7, 2012 at 12:00 AM).
 * 7 days and 168 hours.
 */
export var utcTuesday: CountableTimeInterval;

/**
 * This is a convenience alias for utcTuesday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcTuesdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Wednesday-based weeks in Univarsal Coordinated Time (UTC) (e.g., February 8, 2012 at 12:00 AM).
 * 7 days and 168 hours.
 */
export var utcWednesday: CountableTimeInterval;

/**
 * This is a convenience alias for utcWednesday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcWednesdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Thursday-based weeks in Univarsal Coordinated Time (UTC) (e.g., February 9, 2012 at 12:00 AM).
 * 7 days and 168 hours.
 */
export var utcThursday: CountableTimeInterval;

/**
 * This is a convenience alias for utcThursday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcThursdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Friday-based weeks in Univarsal Coordinated Time (UTC) (e.g., February 10, 2012 at 12:00 AM).
 * 7 days and 168 hours.
 */
export var utcFriday: CountableTimeInterval;

/**
 * This is a convenience alias for utcFriday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcFridays(start: Date, stop: Date, step?: number): Date[];

/**
 * Week Interval for Saturday-based weeks in Univarsal Coordinated Time (UTC) (e.g., February 11, 2012 at 12:00 AM).
 * 7 days and 168 hours.
 */
export var utcSaturday: CountableTimeInterval;

/**
 * This is a convenience alias for utcSaturday.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcSaturdays(start: Date, stop: Date, step?: number): Date[];

/**
 * Month Interval in Univarsal Coordinated Time (UTC); months (e.g., February 1, 2012 at 12:00 AM); ranges from 28 to 31 days.
 */
export var utcMonth: CountableTimeInterval;

/**
 * This is a convenience alias for utcMonth.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcMonths(start: Date, stop: Date, step?: number): Date[];

/**
 * Year Interval in Univarsal Coordinated Time (UTC); years (e.g., January 1, 2012 at 12:00 AM); ranges from 365 to 366 days.
 */
export var utcYear: CountableTimeInterval;

/**
 * This is a convenience alias for utcYear.range(...).
 *
 * @param start A start date object for the range.
 * @param stop A stop date object for the range.
 * @param step An optional number of steps to apply when calculating the dates in the range.
 */
export function utcYears(start: Date, stop: Date, step?: number): Date[];


text:
<!DOCTYPE html>

  <base href="/">

  <meta charset="utf-8">
  <meta name="viewport"
        content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

  <title>Ben Lindsey Design</title>

  <link rel="icon"
        type="image/png"
        href="favicon-16x16.png"
        sizes="16x16">
  <link rel="icon"
        type="image/png"
        href="favicon-32x32.png"
        sizes="32x32">

  <link href="http://benlindseydesign.com/apple-touch-icon.png"
        rel="apple-touch-icon">
  <link href="http://benlindseydesign.com/apple-touch-icon-76x76.png"
        rel="apple-touch-icon"
        sizes="76x76">
  <link href="http://benlindseydesign.com/apple-touch-icon-120x120.png"
        rel="apple-touch-icon"
        sizes="120x120">
  <link href="http://benlindseydesign.com/apple-touch-icon-152x152.png"
        rel="apple-touch-icon"
        sizes="152x152">

  <link href="styles/lib.css"
        rel="stylesheet">
  <link href="styles/main.css"
        rel="stylesheet">

      This site is currently under construction

      <bld-logo-circle></bld-logo-circle>
      <bld-nav-bar current-state="{{routeState.stateName}}"></bld-nav-bar>

    <bld-footer></bld-footer>

redpajama_set_name: RedPajamaGithub


text:
	#include <amcodec/amports/amstream.h>
#else
	// Flags copied from 'include/linux/amlogic/amports/amvstream.h' at https://github.com/codesnake/linux-amlogic
	#define AMSTREAM_IOC_MAGIC   'S'
	#define AMSTREAM_IOC_GET_VIDEO_DISABLE   _IOR(AMSTREAM_IOC_MAGIC,   0x48, unsigned long)
#endif

AmlogicGrabber::AmlogicGrabber(const unsigned width, const unsigned height)
	: _width(std::max(160u, width))    // Minimum required width or height is 160
	, _height(std::max(160u, height))
	, _amlogicCaptureDev(-1)
	, _log(Logger::getInstance("AMLOGICGRABBER"))
{
	Debug(_log, "constructed(%d x %d)",_width,_height);
}

AmlogicGrabber::~AmlogicGrabber()
{
	if (_amlogicCaptureDev != -1)
	{
		if (close(_amlogicCaptureDev) == -1)
		{
			Error(_log, "Failed to close device (%d - %s)", errno, strerror(errno));
		}
		_amlogicCaptureDev = -1;
	}
}

void AmlogicGrabber::setVideoMode(const VideoMode videoMode)
{
	switch (videoMode) {
	case VIDEO_3DSBS:
		//vc_dispmanx_rect_set(&_rectangle, 0, 0, _width/2, _height);
		break;
	case VIDEO_3DTAB:
		//vc_dispmanx_rect_set(&_rectangle, 0, 0, _width, _height/2);
		break;
	case VIDEO_2D:
	default:
		//vc_dispmanx_rect_set(&_rectangle, 0, 0, _width, _height);
		break;
	}
}

bool AmlogicGrabber::isVideoPlaying()
{
	const std::string videoDevice = "/dev/amvideo";

	// Open the video device
	int video_fd = open(videoDevice.c_str(), O_RDONLY);
	if (video_fd < 0)
	{
		Error(_log, "Failed to open video device(%s): %d - %s", videoDevice.c_str(), errno, strerror(errno));
		return false;
	}

	// Check the video disabled flag
	int videoDisabled;
	if (ioctl(video_fd, AMSTREAM_IOC_GET_VIDEO_DISABLE, &videoDisabled) == -1)
	{
		Error(_log, "Failed to retrieve video state from device: %d - %s", errno, strerror(errno));
		close(video_fd);
		return false;
	}

	// Make sure to close the device after use
	close(video_fd);

	return videoDisabled == 0;
}

int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
{
	// resize the given image if needed
	if (image.width() != _width || image.height() != _height)
	{
		image.resize(_width, _height);
	}

	// Make sure video is playing, else there is nothing to grab
	if (!isVideoPlaying())
	{
		return -1;
	}

	// If the device is not open, attempt to open it
	if (_amlogicCaptureDev == -1)
	{
		_amlogicCaptureDev = open("/dev/amvideocap0", O_RDONLY, 0);

		// If the device is still not open, there is something wrong
		if (_amlogicCaptureDev == -1)
		{
			Error(_log,"Failed to open the AMLOGIC device (%d - %s):", errno, strerror(errno));
			return -1;
		}
	}

	if (ioctl(_amlogicCaptureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_WIDTH,  _width)  == -1 ||
		ioctl(_amlogicCaptureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_HEIGHT, _height) == -1)
	{
		// Failed to configure frame width
		Error(_log,"Failed to configure capture size (%d - %s)", errno, strerror(errno));
		close(_amlogicCaptureDev);
		_amlogicCaptureDev = -1;
		return -1;
	}

	// Read the snapshot into the memory
	void * image_ptr = image.memptr();
	const ssize_t bytesToRead = _width * _height * sizeof(ColorBgr);

	const ssize_t bytesRead   = pread(_amlogicCaptureDev, image_ptr, bytesToRead, 0);
	if (bytesRead == -1)
	{
		Error(_log,"Read of device failed: %d - %s", errno, strerror(errno));
		close(_amlogicCaptureDev);
		_amlogicCaptureDev = -1;
		return -1;
	}
	else if (bytesToRead != bytesRead)
	{
		// Read of snapshot failed
		Error(_log,"Capture failed to grab entire image [bytesToRead(%d) != bytesRead(%d)]", bytesToRead, bytesRead);
		close(_amlogicCaptureDev);
		_amlogicCaptureDev = -1;
		return -1;
	}

	// For now we always close the device now and again
	static int readCnt = 0;
	++readCnt;
	if (readCnt > 20)
	{
		close(_amlogicCaptureDev);
		_amlogicCaptureDev = -1;
		readCnt = 0;
	}
	return 0;
}


text:
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define("mouseTracker", [], factory);
	else if(typeof exports === 'object')
		exports["mouseTracker"] = factory();
	else
		root["mouseTracker"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;
/******/
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports) {

	'use strict';

	Object.defineProperty(exports, "__esModule", {
	    value: true
	});

	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

	var MouseTracker = function () {
	    function MouseTracker() {
	        _classCallCheck(this, MouseTracker);
	    }

	    _createClass(MouseTracker, [{
	        key: 'createPage',
	        value: function createPage(name) {
	            //Creo la pagina
	            var page = new Page(name);
	            return page;
	        }
	    }, {
	        key: 'createAnalysisWrapper',
	        value: function createAnalysisWrapper(page, eventContainer) {
	            //Creo il wrapper su cui abilito gli analytics
	            var analysisWrapper = new AnalysisWrapper(page, eventContainer);
	            return analysisWrapper;
	        }
	    }, {
	        key: 'getMouseEvents',
	        value: function getMouseEvents(page) {
	            var cached = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

	            for (var _len = arguments.length, wrappers = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
	                wrappers[_key - 2] = arguments[_key];
	            }

	            return page.sendAllRegisteredData(cached, wrappers);
	        }
	    }, {
	        key: 'getMouseMovementEvents',
	        value: function getMouseMovementEvents(page) {
	            var cached = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

	            for (var _len2 = arguments.length, wrappers = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
	                wrappers[_key2 - 2] = arguments[_key2];
	            }

	            return page.sendRegisteredMouseMovement(cached, wrappers);
	        }
	    }, {
	        key: 'getMouseClickEvents',
	        value: function getMouseClickEvents(page) {
	            var cached = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

	            for (var _len3 = arguments.length, wrappers = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
	                wrappers[_key3 - 2] = arguments[_key3];
	            }

	            //array di wrapper in input
	            return page.sendRegisteredClick(cached, wrappers);
	        }
	    }, {
	        key: 'addListener',
	        value: function addListener(wrapper) {
	            for (var _len4 = arguments.length, listeners = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
	                listeners[_key4 - 1] = arguments[_key4];
	            }

	            listeners.forEach(function (listener) {
	                switch (listener) {
	                    case 'click':
	                        wrapper.addClickListener();
	                        break;
	                    case 'mouseMovement':
	                        wrapper.addMouseMoveListener();
	                        break;
	                    default:
	                        console.error('listener ' + listener + ' is not available');
	                }
	            });
	        }
	    }, {
	        key: 'addAllListeners',
	        value: function addAllListeners(wrapper) {
	            wrapper.addClickListener();
	            wrapper.addMouseMoveListener();
	        }
	    }]);

	    return MouseTracker;
	}();

	exports.default = MouseTracker;

	var Inspector = function () {
	    function Inspector() {
	        _classCallCheck(this, Inspector);
	    }

	    _createClass(Inspector, null, [{
	        key: 'findElementSelected',
	        value: function findElementSelected(eventContainerElement, event) {
	            //prendo la distanza del path dell'elemento e la distanza del path container
	            var pathDistanceElementSelected = Inspector.searchPathElementDistance(event);
	            var pathElementDistanceContainer = Inspector.searchPathElementContainerDistance(event, eventContainerElement);
	            var element = null;

	            for (var i = pathDistanceElementSelected; i < pathElementDistanceContainer; i++) {
	                //Ciclo fino a trovare il primo elemento che si vuole analizzare -> lo riconosciamo attraverso l'attributo mouseTracker
	                if (event.path[i].attributes.mouseTracker !== undefined) {
	                    element = event.path[i];
	                    break;
	                }
	            }
	            if (element === null) return eventContainerElement;
	            return element;
	        } //CLICK EVENT

	    }, {
	        key: 'searchPathElementDistance',
	        value: function searchPathElementDistance(node) {
	            var tagAnalyticsElement = node.toElement.attributes.mouseTracker;
	            // se l'elemento cliccato non ha tag analytics vado a prendermi il tagAnalytics del prima padre disponibile
	            if (node.toElement.attributes.mouseTracker === undefined) {
	                tagAnalyticsElement = Inspector.searchFirtFatherAnalyticsTag(node);
	            }

	            for (var i = 0; i < node.path.length; i++) {
	                if (node.path[i].attributes.mouseTracker !== undefined) {
	                    if (node.path[i].attributes.mouseTracker === tagAnalyticsElement) {
	                        return i;
	                    }
	                }
	            }
	            return -1;
	        }
	    }, {
	        key: 'searchPathElementContainerDistance',
	        value: function searchPathElementContainerDistance(node, eventContainerElement) {
	            for (var i = 0; i < node.path.length; i++) {
	                if (node.path[i].id === eventContainerElement.id) {
	                    return i;
	                }
	            }
	            return -1;
	        }
	    }, {
	        key: 'searchFirtFatherAnalyticsTag',
	        value: function searchFirtFatherAnalyticsTag(node) {
	            //  vado a prendermi il tagAnalytics del prima padre disponibile
	            var tagAnalyticsElement = void 0;
	            var nodeToFind = node;
	            var find = false;
	            while (!find) {
	                if (nodeToFind.toElement.parentNode.attributes.mouseTracker !== undefined) {
	                    tagAnalyticsElement = nodeToFind.toElement.parentNode.attributes.mouseTracker;
	                    find = true;
	                } else {
	                    nodeToFind = nodeToFind.toElement.parentNode;
	                }
	            }
	            return tagAnalyticsElement;
	        }
	    }, {
	        key: 'containerIsInWrapperList',
	        value: function containerIsInWrapperList(valueKey, myArray) {
	            for (var i = 0; i < myArray.length; i++) {
	                if (myArray[i].name === valueKey) {
	                    return true;
	                }
	            }
	            return false;
	        }
	    }, {
	        key: 'getBrowser',
	        value: function getBrowser() {
	            if ((navigator.userAgent.indexOf('Opera') || navigator.userAgent.indexOf('OPR')) !== -1) return 'Opera';else if (navigator.userAgent.indexOf('Chrome') !== -1) return 'Chrome';else if (navigator.userAgent.indexOf('Safari') !== -1) return 'Safari';else if (navigator.userAgent.indexOf('Firefox') !== -1) return 'Firefox';else if (navigator.userAgent.indexOf('MSIE') !== -1 || !!document.documentMode == true) //IF IE > 10
	                return 'IE';else return 'unknown';
	        }
	    }]);

	    return Inspector;
	}();

	var Page = function () {
	    function Page(name) {
	        _classCallCheck(this, Page);

	        this.name = name;
	        this.width = window.innerWidth;
	        this.height = window.innerHeight;
	        this.browser = Inspector.getBrowser();
	        this.containers = []; //container all'interno della pagina
	    }

	    _createClass(Page, [{
	        key: 'setHeight',
	        value: function setHeight(height) {
	            this.height = height;
	        }
	    }, {
	        key: 'setWidth',
	        value: function setWidth(width) {
	            this.width = width;
	        }
	    }, {
	        key: 'addContainer',
	        value: function addContainer(container) {
	            //container di tipo AnalysisWrapper
	            this.containers.push(container);
	        }
	    }, {
	        key: 'sendAllRegisteredData',
	        value: function sendAllRegisteredData(cached, wrappers) {
	            var data = Sender.sendJsonAllData(this.containers, wrappers);
	            if (!cached) this.emptyContainersTracementList(wrappers);
	            return data;
	        }
	    }, {
	        key: 'sendRegisteredClick',
	        value: function sendRegisteredClick(cached, wrappers) {
	            var clickData = Sender.sendJsonClickData(this.containers, wrappers);
	            if (!cached) this.emptyClickContainers(wrappers);
	            return clickData;
	        }
	    }, {
	        key: 'sendRegisteredMouseMovement',
	        value: function sendRegisteredMouseMovement(cached, wrappers) {
	            var mouseMovementData = Sender.sendJsonMouseMovementsData(this.containers, wrappers);
	            if (!cached) this.emptyMouseMovementContainers(wrappers);
	            return mouseMovementData;
	        }
	    }, {
	        key: 'emptyContainersTracementList',
	        value: function emptyContainersTracementList(wrappers) {
	            this.containers.forEach(function (container) {
	                if (Inspector.containerIsInWrapperList(container.name, wrappers) || wrappers.length == 0) {
	                    container.clickListener.clearList();
	                    container.mouseMovementListener.clearList();
	                }
	            });
	        }
	    }, {
	        key: 'emptyClickContainers',
	        value: function emptyClickContainers(wrappers) {
	            this.containers.forEach(function (container) {
	                if (Inspector.containerIsInWrapperList(container.name, wrappers) || wrappers.length == 0) container.clickListener.clearList();
	            });
	        }
	    }, {
	        key: 'emptyMouseMovementContainers',
	        value: function emptyMouseMovementContainers(wrappers) {
	            this.containers.forEach(function (container) {
	                if (Inspector.containerIsInWrapperList(container.name, wrappers) || wrappers.length == 0) container.mouseMovementListener.clearList();
	            });
	        }
	    }]);

	    return Page;
	}();

	var ClickListener = function () {
	    function ClickListener(wrapper) {
	        var _this = this;

	        _classCallCheck(this, ClickListener);

	        this.clickList = [];
	        this.wrapper = wrapper;
	        this.wrapper.element.addEventListener('click', function (evt) {
	            return _this.registerClick(evt);
	        });
	    }

	    _createClass(ClickListener, [{
	        key: 'registerClick',
	        value: function registerClick(event) {
	            this.wrapper.page.setHeight(window.innerHeight); // prendo altezza corrente della pagina browser
	            this.wrapper.page.setWidth(window.innerWidth); // prendo larghezza corrente della pagina browser
	            var click = new Click(this.wrapper, event); //con this gli passo l'oggetto AnalysisWrapper
	            //click.showInfo();
	            this.clickList.push(click);
	        }
	    }, {
	        key: 'clearList',
	        value: function clearList() {
	            this.clickList.length = 0;
	        }
	    }, {
	        key: 'getClickList',
	        value: function getClickList() {
	            return this.clickList;
	        }
	    }]);

	    return ClickListener;
	}();

	var MouseMovementListener = function () {
	    function MouseMovementListener(wrapper) {
	        _classCallCheck(this, MouseMovementListener);

	        this.movements = [];
	        this.wrapper = wrapper;
	        this.addListener();
	    }

	    _createClass(MouseMovementListener, [{
	        key: 'addListener',
	        value: function addListener() {
	            this.mouseIsOver = false;
	            var self = this;
	            //verifico se il mouse è sopra il wrapper per la registrazione della posizione
	            this.wrapper.element.onmouseover = function () {
	                self.mouseIsOver = true;
	            };
	            this.wrapper.element.onmouseout = function () {
	                self.mouseIsOver = false;
	            };
	            //Vado a prendermi le coordinate del mouse ad ogni movimento del mouse nella pagina
	            this.wrapper.element.addEventListener('mousemove', function (event) {
	                window.mouseX = event.clientX;
	                window.mouseY = event.clientY;
	            });
	            //Registro la posizione del mouse solo ogni mezzo secondo
	            window.setInterval(function (event) {
	                if (self.mouseIsOver) {
	                    self.registerMouseMovement(event);
	                }
	            }, 500);
	        }
	    }, {
	        key: 'registerMouseMovement',
	        value: function registerMouseMovement(event) {
	            this.wrapper.page.setHeight(window.innerHeight); // prendo altezza corrente della pagina browser
	            this.wrapper.page.setWidth(window.innerWidth); // prendo larghezza corrente della pagina browser
	            var movement = new MouseMovement(this.wrapper, window.mouseX, window.mouseY); //con this gli passo l'oggetto AnalysisWrapper
	            // movement.showInfo();
	            this.movements.push(movement);
	        }
	    }, {
	        key: 'clearList',
	        value: function clearList() {
	            this.movements.length = 0;
	        }
	    }, {
	        key: 'getList',
	        value: function getList() {
	            return this.movements;
	        }
	    }]);

	    return MouseMovementListener;
	}();

	var AnalysisWrapper = function () {
	    /*
	        CONTIENE LE DUE LISTE DI EVENTI : CLICK, MOVEMENT
	    */

	    function AnalysisWrapper(page, wrapperName) {
	        _classCallCheck(this, AnalysisWrapper);

	        //page di tipo Page
	        this.page = page;
	        this.name = wrapperName;
	        this.element = document.getElementById(wrapperName);
	        this.page.addContainer(this);
	    }

	    _createClass(AnalysisWrapper, [{
	        key: 'addClickListener',
	        value: function addClickListener() {
	            this.clickListener = new ClickListener(this);
	        }
	    }, {
	        key: 'addMouseMoveListener',
	        value: function addMouseMoveListener() {
	            this.mouseMovementListener = new MouseMovementListener(this);
	        }
	    }]);

	    return AnalysisWrapper;
	}();

	var Click = function () {
	    function Click(wrapperElement, event) {
	        _classCallCheck(this, Click);

	        this.wrapperElement = wrapperElement;
	        this.dateTime = Date.now();
	        this.x = event.x + window.pageXOffset;
	        this.y = event.y + window.pageYOffset;
	        this.selectedElement = Inspector.findElementSelected(this.wrapperElement.element, event);
	        this.nameSelectedElement = this.selectedElement.attributes.mouseTracker.nodeValue; //elemento specifico cliccato all'interno di containerElement (es. bottone)
	    }

	    _createClass(Click, [{
	        key: 'showInfo',
	        value: function showInfo() {
	            var message = 'Page ' + this.wrapperElement.page.name + ' [width:' + this.wrapperElement.page.width + ', height: ' + this.wrapperElement.page.height + '] \n Container: ' + this.wrapperElement.name + ' \n ### ' + this.dateTime + ' - (x: ' + this.x + ' y:' + this.y + ') ------ ' + this.nameSelectedElement;
	            console.log(message);
	        }
	    }]);

	    return Click;
	}();

	var MouseMovement = function () {
	    function MouseMovement(wrapperElement, mouseX, mouseY) {
	        _classCallCheck(this, MouseMovement);

	        this.wrapperElement = wrapperElement;
	        this.dateTime = Date.now();
	        this.x = mouseX + window.pageXOffset;
	        this.y = mouseY + window.pageYOffset;
	    }

	    _createClass(MouseMovement, [{
	        key: 'showInfo',
	        value: function showInfo() {
	            /*let message = `Page ${this.wrapperElement.page.name} [width:${this.wrapperElement.page.width}, height: ${this.wrapperElement.page.height}] \n Container: ${this.wrapperElement.name} \n ### ${this.dateTime} - (x: ${this.x} y:${this.y})`;*/
	            var message = 'Page ' + this.wrapperElement.page.name + ' ' + this.wrapperElement.name + ' ### ' + this.dateTime + ' - x: ' + this.x + ' y:' + this.y;
	            console.log(message);
	        }
	    }]);

	    return MouseMovement;
	}();

	var Sender = function () {
	    function Sender() {
	        _classCallCheck(this, Sender);
	    }

	    _createClass(Sender, null, [{
	        key: 'sendJsonAllData',
	        value: function sendJsonAllData(mouseTrackerList, wrappers) {
	            var reporClicktToSend = JsonReport.createClickObjectToSend(mouseTrackerList, wrappers);
	            var reporMouseMovementstToSend = JsonReport.createMouseMovementObjectToSend(mouseTrackerList, wrappers);
	            return JSON.stringify(reporClicktToSend.concat(reporMouseMovementstToSend));
	        }
	    }, {
	        key: 'sendJsonClickData',
	        value: function sendJsonClickData(pageClickList, wrappers) {
	            var reportToSend = JsonReport.createClickObjectToSend(pageClickList, wrappers);
	            return JSON.stringify(reportToSend);
	        }
	    }, {
	        key: 'sendJsonMouseMovementsData',
	        value: function sendJsonMouseMovementsData(movementsList, wrappers) {
	            var reportToSend = JsonReport.createMouseMovementObjectToSend(movementsList, wrappers);
	            return JSON.stringify(reportToSend);
	        }
	    }]);

	    return Sender;
	}();

	var JsonReport = function () {
	    function JsonReport() {
	        _classCallCheck(this, JsonReport);
	    }

	    _createClass(JsonReport, null, [{
	        key: 'createMouseMovementObjectToSend',
	        value: function createMouseMovementObjectToSend(list, wrappers) {
	            // arriva una lista di Container
	            var array = [];
	            list.forEach(function (container) {
	                if (Inspector.containerIsInWrapperList(container.name, wrappers) || wrappers.length == 0) {
	                    //verifica se il container selezionato è tra quelli richiesti dall'utente, se wrappers è vuoto vuol dire che l'utente vuole prendere tutti i wrappers della pagina e quindi l'if sarà sempre true
	                    container.mouseMovementListener.getList().forEach(function (ele) {
	                        var obj = {
	                            type: 'move',
	                            dateTime: ele.dateTime,
	                            x: ele.x,
	                            y: ele.y,
	                            wrapperName: ele.wrapperElement.name,
	                            browser: ele.wrapperElement.page.browser,
	                            namePage: ele.wrapperElement.page.name,
	                            heightPage: ele.wrapperElement.page.height,
	                            widthPage: ele.wrapperElement.page.width
	                        };
	                        array.push(obj);
	                    });
	                }
	            });
	            return array;
	        }
	    }, {
	        key: 'createClickObjectToSend',
	        value: function createClickObjectToSend(list, wrappers) {
	            var array = [];
	            list.forEach(function (container) {
	                if (Inspector.containerIsInWrapperList(container.name, wrappers) || wrappers.length == 0) {
	                    //verifica se il container selezionato è tra quelli richiesti dall'utente, se wrappers è vuoto vuol dire che l'utente vuole prendere tutti i wrappers della pagina e quindi l'if sarà sempre true
	                    container.clickListener.getClickList().forEach(function (ele) {
	                        var obj = {
	                            type: 'click',
	                            dateTime: ele.dateTime,
	                            nameSelectedElement: ele.nameSelectedElement,
	                            x: ele.x,
	                            y: ele.y,
	                            wrapperName: ele.wrapperElement.name,
	                            browser: ele.wrapperElement.page.browser,
	                            namePage: ele.wrapperElement.page.name,
	                            heightPage: ele.wrapperElement.page.height,
	                            widthPage: ele.wrapperElement.page.width
	                        };
	                        array.push(obj);
	                    });
	                }
	            });
	            return array;
	        }
	    }]);

	    return JsonReport;
	}();

	module.exports = exports['default'];

/***/ }
/******/ ])
});
;
//# sourceMappingURL=mouseTracker.js.map


text:
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "public/fpdf_formfill.h"

#define IDS_XFA_Validate_Input                                          \
  "At least one required field was empty. Please fill in the required " \
  "fields\r\n(highlighted) before continuing."

// submit
#define FXFA_CONFIG 0x00000001
#define FXFA_TEMPLATE 0x00000010
#define FXFA_LOCALESET 0x00000100
#define FXFA_DATASETS 0x00001000
#define FXFA_XMPMETA 0x00010000
#define FXFA_XFDF 0x00100000
#define FXFA_FORM 0x01000000
#define FXFA_PDF 0x10000000

#ifndef _WIN32
extern void SetLastError(int err);

extern int GetLastError();
#endif

CPDFXFA_Document::CPDFXFA_Document(CPDF_Document* pPDFDoc,
                                   CPDFXFA_App* pProvider)
    : m_iDocType(DOCTYPE_PDF),
      m_pPDFDoc(pPDFDoc),
      m_pSDKDoc(nullptr),
      m_pXFADoc(nullptr),
      m_pXFADocView(nullptr),
      m_pApp(pProvider),
      m_pJSContext(nullptr) {
}

CPDFXFA_Document::~CPDFXFA_Document() {
  if (m_pXFADoc) {
    IXFA_App* pApp = m_pApp->GetXFAApp();
    if (pApp) {
      IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();
      if (pDocHandler) {
        CloseXFADoc(pDocHandler);
      }
    }
    delete m_pXFADoc;
  }
  if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv())
    m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
  delete m_pSDKDoc;
  if (m_pPDFDoc) {
    CPDF_Parser* pParser = m_pPDFDoc->GetParser();
    if (pParser)
      delete pParser;
    else
      delete m_pPDFDoc;
  }
}

FX_BOOL CPDFXFA_Document::LoadXFADoc() {
  if (!m_pPDFDoc)
    return FALSE;

  m_XFAPageList.RemoveAll();

  IXFA_App* pApp = m_pApp->GetXFAApp();
  if (!pApp)
    return FALSE;

  m_pXFADoc = pApp->CreateDoc(this, m_pPDFDoc);
  if (!m_pXFADoc) {
    SetLastError(FPDF_ERR_XFALOAD);
    return FALSE;
  }

  IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();
  if (!pDocHandler) {
    SetLastError(FPDF_ERR_XFALOAD);
    return FALSE;
  }

  pDocHandler->StartLoad(m_pXFADoc);
  int iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL);
  if (iStatus != XFA_PARSESTATUS_Done) {
    CloseXFADoc(pDocHandler);
    SetLastError(FPDF_ERR_XFALOAD);
    return FALSE;
  }
  pDocHandler->StopLoad(m_pXFADoc);
  pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime());

  if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic)
    m_iDocType = DOCTYPE_DYNAMIC_XFA;
  else
    m_iDocType = DOCTYPE_STATIC_XFA;

  m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View);
  if (m_pXFADocView->StartLayout() < 0) {
    CloseXFADoc(pDocHandler);
    SetLastError(FPDF_ERR_XFALAYOUT);
    return FALSE;
  }

  m_pXFADocView->DoLayout(NULL);
  m_pXFADocView->StopLayout();
  return TRUE;
}

int CPDFXFA_Document::GetPageCount() {
  if (!m_pPDFDoc && !m_pXFADoc)
    return 0;

  switch (m_iDocType) {
    case DOCTYPE_PDF:
    case DOCTYPE_STATIC_XFA:
      if (m_pPDFDoc)
        return m_pPDFDoc->GetPageCount();
    case DOCTYPE_DYNAMIC_XFA:
      if (m_pXFADoc)
        return m_pXFADocView->CountPageViews();
    default:
      return 0;
  }

  return 0;
}

CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) {
  if (page_index < 0)
    return nullptr;
  CPDFXFA_Page* pPage = nullptr;
  int nCount = m_XFAPageList.GetSize();
  if (nCount > 0 && page_index < nCount) {
    pPage = m_XFAPageList.GetAt(page_index);
    if (pPage)
      pPage->AddRef();
  } else {
    m_XFAPageList.SetSize(GetPageCount());
  }
  if (pPage)
    return pPage;
  pPage = new CPDFXFA_Page(this, page_index);
  if (!pPage->LoadPage()) {
    delete pPage;
    return nullptr;
  }
  m_XFAPageList.SetAt(page_index, pPage);
  return pPage;
}

CPDFXFA_Page* CPDFXFA_Document::GetPage(IXFA_PageView* pPage) {
  if (!pPage)
    return NULL;

  if (!m_pXFADoc)
    return NULL;

  if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
    return NULL;

  int nSize = m_XFAPageList.GetSize();
  for (int i = 0; i < nSize; i++) {
    CPDFXFA_Page* pTempPage = m_XFAPageList.GetAt(i);
    if (!pTempPage)
      continue;
    if (pTempPage->GetXFAPageView() && pTempPage->GetXFAPageView() == pPage)
      return pTempPage;
  }

  return NULL;
}

void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) {
  m_XFAPageList.SetAt(page->GetPageIndex(), NULL);
}

CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument(
    CPDFDoc_Environment* pFormFillEnv) {
  if (!m_pSDKDoc && pFormFillEnv)
    m_pSDKDoc = new CPDFSDK_Document(this, pFormFillEnv);
  return m_pSDKDoc;
}

void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF,
                                      CPDF_Rect& pdfRect) {
  pdfRect.left = fxRectF.left;
  pdfRect.top = fxRectF.bottom();
  pdfRect.right = fxRectF.right();
  pdfRect.bottom = fxRectF.top;
}

void CPDFXFA_Document::SetChangeMark(IXFA_Doc* hDoc) {
  if (hDoc == m_pXFADoc && m_pSDKDoc) {
    m_pSDKDoc->SetChangeMark();
  }
}

FX_BOOL CPDFXFA_Document::GetChangeMark(IXFA_Doc* hDoc) {
  if (hDoc == m_pXFADoc && m_pSDKDoc)
    return m_pSDKDoc->GetChangeMark();
  return FALSE;
}

void CPDFXFA_Document::InvalidateRect(IXFA_PageView* pPageView,
                                      const CFX_RectF& rt,
                                      FX_DWORD dwFlags /* = 0 */) {
  if (!m_pXFADoc || !m_pSDKDoc)
    return;

  if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
    return;

  CPDF_Rect rcPage;
  FXRect2PDFRect(rt, rcPage);

  CPDFXFA_Page* pPage = GetPage(pPageView);

  if (pPage == NULL)
    return;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (!pEnv)
    return;

  pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom,
                       rcPage.right, rcPage.top);
}

void CPDFXFA_Document::InvalidateRect(IXFA_Widget* hWidget,
                                      FX_DWORD dwFlags /* = 0 */) {
  if (!hWidget)
    return;

  if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
    return;

  if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
    return;

  IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
  if (!pWidgetHandler)
    return;

  IXFA_PageView* pPageView = pWidgetHandler->GetPageView(hWidget);
  if (!pPageView)
    return;

  CFX_RectF rect;
  pWidgetHandler->GetRect(hWidget, rect);
  InvalidateRect(pPageView, rect, dwFlags);
}

void CPDFXFA_Document::DisplayCaret(IXFA_Widget* hWidget,
                                    FX_BOOL bVisible,
                                    const CFX_RectF* pRtAnchor) {
  if (!hWidget || pRtAnchor == NULL)
    return;

  if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
    return;

  if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
    return;

  IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
  if (!pWidgetHandler)
    return;

  IXFA_PageView* pPageView = pWidgetHandler->GetPageView(hWidget);
  if (!pPageView)
    return;

  CPDFXFA_Page* pPage = GetPage(pPageView);

  if (pPage == NULL)
    return;

  CPDF_Rect rcCaret;
  FXRect2PDFRect(*pRtAnchor, rcCaret);

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (!pEnv)
    return;

  pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top,
                         rcCaret.right, rcCaret.bottom);
}

FX_BOOL CPDFXFA_Document::GetPopupPos(IXFA_Widget* hWidget,
                                      FX_FLOAT fMinPopup,
                                      FX_FLOAT fMaxPopup,
                                      const CFX_RectF& rtAnchor,
                                      CFX_RectF& rtPopup) {
  if (NULL == hWidget) {
    return FALSE;
  }
  IXFA_PageView* pXFAPageView =
      m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget);
  if (NULL == pXFAPageView) {
    return FALSE;
  }
  CPDFXFA_Page* pPage = GetPage(pXFAPageView);
  if (pPage == NULL)
    return FALSE;

  CXFA_WidgetAcc* pWidgetAcc =
      m_pXFADocView->GetWidgetHandler()->GetDataAcc(hWidget);

  int nRotate = 0;
#ifdef PDF_ENABLE_XFA
  nRotate = pWidgetAcc->GetRotate();
#endif

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return FALSE;
  FS_RECTF pageViewRect;
  pEnv->FFI_GetPageViewRect(pPage, pageViewRect);

  CPDF_Rect rcAnchor;

  rcAnchor.left = rtAnchor.left;
  rcAnchor.top = rtAnchor.bottom();
  rcAnchor.right = rtAnchor.right();
  rcAnchor.bottom = rtAnchor.top;

  int t1, t2, t;
  FX_DWORD dwPos;
  FX_FLOAT fPoupHeight;
  switch (nRotate) {
    case 90: {
      t1 = (int)(pageViewRect.right - rcAnchor.right);
      t2 = (int)(rcAnchor.left - pageViewRect.left);
      if (rcAnchor.bottom < pageViewRect.bottom) {
        rtPopup.left += rcAnchor.bottom - pageViewRect.bottom;
      }

      break;
    }

    case 180: {
      t2 = (int)(pageViewRect.top - rcAnchor.top);
      t1 = (int)(rcAnchor.bottom - pageViewRect.bottom);
      if (rcAnchor.left < pageViewRect.left) {
        rtPopup.left += rcAnchor.left - pageViewRect.left;
      }
      break;
    }
    case 270: {
      t1 = (int)(rcAnchor.left - pageViewRect.left);
      t2 = (int)(pageViewRect.right - rcAnchor.right);

      if (rcAnchor.top > pageViewRect.top) {
        rtPopup.left -= rcAnchor.top - pageViewRect.top;
      }
      break;
    }
    case 0:
    default: {
      t1 = (int)(pageViewRect.top - rcAnchor.top);
      t2 = (int)(rcAnchor.bottom - pageViewRect.bottom);
      if (rcAnchor.right > pageViewRect.right) {
        rtPopup.left -= rcAnchor.right - pageViewRect.right;
      }
      break;
    }
  }

  if (t1 <= 0 && t2 <= 0) {
    return FALSE;
  }
  if (t1 <= 0) {
    t = t2;
    dwPos = 1;
  } else if (t2 <= 0) {
    t = t1;
    dwPos = 0;
  } else if (t1 > t2) {
    t = t1;
    dwPos = 0;
  } else {
    t = t2;
    dwPos = 1;
  }
  if (t < fMinPopup) {
    fPoupHeight = fMinPopup;
  } else if (t > fMaxPopup) {
    fPoupHeight = fMaxPopup;
  } else {
    fPoupHeight = (FX_FLOAT)t;
  }

  switch (nRotate) {
    case 0:
    case 180: {
      if (dwPos == 0) {
        rtPopup.top = rtAnchor.height;
        rtPopup.height = fPoupHeight;
      } else {
        rtPopup.top = -fPoupHeight;
        rtPopup.height = fPoupHeight;
      }
      break;
    }
    case 90:
    case 270: {
      if (dwPos == 0) {
        rtPopup.top = rtAnchor.width;
        rtPopup.height = fPoupHeight;
      } else {
        rtPopup.top = -fPoupHeight;
        rtPopup.height = fPoupHeight;
      }
      break;
    }
    default:
      break;
  }

  return TRUE;
}

FX_BOOL CPDFXFA_Document::PopupMenu(IXFA_Widget* hWidget,
                                    CFX_PointF ptPopup,
                                    const CFX_RectF* pRectExclude) {
  if (NULL == hWidget) {
    return FALSE;
  }
  IXFA_PageView* pXFAPageView =
      m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget);
  if (pXFAPageView == NULL)
    return FALSE;
  CPDFXFA_Page* pPage = GetPage(pXFAPageView);

  if (pPage == NULL)
    return FALSE;

  int menuFlag = 0;

  IXFA_MenuHandler* pXFAMenuHander = m_pApp->GetXFAApp()->GetMenuHandler();
  if (pXFAMenuHander->CanUndo(hWidget))
    menuFlag |= FXFA_MEMU_UNDO;
  if (pXFAMenuHander->CanRedo(hWidget))
    menuFlag |= FXFA_MEMU_REDO;
  if (pXFAMenuHander->CanPaste(hWidget))
    menuFlag |= FXFA_MEMU_PASTE;
  if (pXFAMenuHander->CanCopy(hWidget))
    menuFlag |= FXFA_MEMU_COPY;
  if (pXFAMenuHander->CanCut(hWidget))
    menuFlag |= FXFA_MEMU_CUT;
  if (pXFAMenuHander->CanSelectAll(hWidget))
    menuFlag |= FXFA_MEMU_SELECTALL;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return FALSE;

  return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL);
}

void CPDFXFA_Document::PageViewEvent(IXFA_PageView* pPageView,
                                     FX_DWORD dwFlags) {
  if (!pPageView || (dwFlags != XFA_PAGEVIEWEVENT_PostAdded &&
                     dwFlags != XFA_PAGEVIEWEVENT_PostRemoved)) {
    return;
  }
  CPDFXFA_Page* pPage = nullptr;
  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (dwFlags == XFA_PAGEVIEWEVENT_PostAdded) {
    int nPageIndex = pPageView->GetPageViewIndex();
    pPage = GetPage(nPageIndex);
    if (pPage)
      pPage->SetXFAPageView(pPageView);
    pEnv->FFI_PageEvent(nPageIndex, dwFlags);
    return;
  }
  pPage = GetPage(pPageView);
  if (!pPage)
    return;
  pEnv->FFI_PageEvent(pPage->GetPageIndex(), dwFlags);
  pPage->Release();
}

void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget,
                                   CXFA_WidgetAcc* pWidgetData,
                                   FX_DWORD dwEvent,
                                   void* pParam,
                                   void* pAdditional) {
  if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget)
    return;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (!pEnv)
    return;

  IXFA_PageView* pPageView =
      m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget);
  if (pPageView == NULL)
    return;

  CPDFXFA_Page* pXFAPage = GetPage(pPageView);
  if (pXFAPage == NULL)
    return;

  CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage);
  if (dwEvent == XFA_WIDGETEVENT_PostAdded) {
    pSdkPageView->AddAnnot(hWidget);

  } else if (dwEvent == XFA_WIDGETEVENT_PreRemoved) {
    CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget);
    if (pAnnot) {
      pSdkPageView->DeleteAnnot(pAnnot);
    }
  }
}

int32_t CPDFXFA_Document::CountPages(IXFA_Doc* hDoc) {
  if (hDoc == m_pXFADoc && m_pSDKDoc) {
    return GetPageCount();
  }
  return 0;
}
int32_t CPDFXFA_Document::GetCurrentPage(IXFA_Doc* hDoc) {
  if (hDoc != m_pXFADoc || !m_pSDKDoc)
    return -1;
  if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
    return -1;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return -1;

  return pEnv->FFI_GetCurrentPageIndex(this);
}
void CPDFXFA_Document::SetCurrentPage(IXFA_Doc* hDoc, int32_t iCurPage) {
  if (hDoc != m_pXFADoc || !m_pSDKDoc || m_iDocType != DOCTYPE_DYNAMIC_XFA ||
      iCurPage < 0 || iCurPage >= m_pSDKDoc->GetPageCount()) {
    return;
  }
  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (!pEnv)
    return;
  pEnv->FFI_SetCurrentPage(this, iCurPage);
}
FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(IXFA_Doc* hDoc) {
  if (hDoc != m_pXFADoc || !m_pSDKDoc)
    return FALSE;
  if (m_pSDKDoc->GetInterForm())
    return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled();

  return FALSE;
}
void CPDFXFA_Document::SetCalculationsEnabled(IXFA_Doc* hDoc,
                                              FX_BOOL bEnabled) {
  if (hDoc != m_pXFADoc || !m_pSDKDoc)
    return;
  if (m_pSDKDoc->GetInterForm())
    m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled);
}

void CPDFXFA_Document::GetTitle(IXFA_Doc* hDoc, CFX_WideString& wsTitle) {
  if (hDoc != m_pXFADoc)
    return;
  if (m_pPDFDoc == NULL)
    return;
  CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo();

  if (pInfoDict == NULL)
    return;

  CFX_ByteString csTitle = pInfoDict->GetStringBy("Title");
  wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength()));
  csTitle.ReleaseBuffer(csTitle.GetLength());
}
void CPDFXFA_Document::SetTitle(IXFA_Doc* hDoc,
                                const CFX_WideStringC& wsTitle) {
  if (hDoc != m_pXFADoc)
    return;
  if (m_pPDFDoc == NULL)
    return;
  CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo();

  if (pInfoDict == NULL)
    return;
  pInfoDict->SetAt("Title", new CPDF_String(wsTitle));
}
void CPDFXFA_Document::ExportData(IXFA_Doc* hDoc,
                                  const CFX_WideStringC& wsFilePath,
                                  FX_BOOL bXDP) {
  if (hDoc != m_pXFADoc)
    return;
  if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
    return;
  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return;
  int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
  CFX_ByteString bs = CFX_WideString(wsFilePath).UTF16LE_Encode();

  if (wsFilePath.IsEmpty()) {
    if (!pEnv->GetFormFillInfo() ||
        pEnv->GetFormFillInfo()->m_pJsPlatform == NULL)
      return;
    CFX_WideString filepath = pEnv->JS_fieldBrowse();
    bs = filepath.UTF16LE_Encode();
  }
  int len = bs.GetLength() / sizeof(unsigned short);
  FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile(
      bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
      (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb");
  bs.ReleaseBuffer(len * sizeof(unsigned short));

  if (pFileHandler == NULL)
    return;

  CFPDF_FileStream fileWrite(pFileHandler);

  IXFA_DocHandler* pXFADocHander = m_pApp->GetXFAApp()->GetDocHandler();
  CFX_ByteString content;
  if (fileType == FXFA_SAVEAS_XML) {
    content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
    fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
                         content.GetLength());
    CFX_WideStringC data(L"data");
    if (pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), data, &fileWrite)) {
      // TODO: Maybe report error.
    }
  } else if (fileType == FXFA_SAVEAS_XDP) {
    if (m_pPDFDoc == NULL)
      return;
    CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
    if (pRoot == NULL)
      return;
    CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
    if (NULL == pAcroForm)
      return;
    CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
    if (pXFA == NULL)
      return;
    if (!pXFA->IsArray())
      return;
    CPDF_Array* pArray = pXFA->GetArray();
    if (NULL == pArray)
      return;
    int size = pArray->GetCount();
    for (int i = 1; i < size; i += 2) {
      CPDF_Object* pPDFObj = pArray->GetElement(i);
      CPDF_Object* pPrePDFObj = pArray->GetElement(i - 1);
      if (!pPrePDFObj->IsString())
        continue;
      if (!pPDFObj->IsReference())
        continue;
      CPDF_Object* pDirectObj = pPDFObj->GetDirect();
      if (!pDirectObj->IsStream())
        continue;
      if (pPrePDFObj->GetString() == "form") {
        CFX_WideStringC form(L"form");
        pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), form, &fileWrite);
      } else if (pPrePDFObj->GetString() == "datasets") {
        CFX_WideStringC datasets(L"datasets");
        pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), datasets,
                                   &fileWrite);
      } else {
        if (i == size - 1) {
          CFX_WideString wPath = CFX_WideString::FromUTF16LE(
              (unsigned short*)(const FX_CHAR*)bs,
              bs.GetLength() / sizeof(unsigned short));
          CFX_ByteString bPath = wPath.UTF8Encode();
          CFX_ByteString szFormat =
              "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
          content.Format(szFormat, (char*)(const FX_CHAR*)bPath);
          fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
                               content.GetLength());
        }

        CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj;
        CPDF_StreamAcc* pAcc = new CPDF_StreamAcc;
        pAcc->LoadAllData(pStream);
        fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(),
                             pAcc->GetSize());
        delete pAcc;
      }
    }
  }
  if (!fileWrite.Flush()) {
    // TODO: Report error.
  }
}
void CPDFXFA_Document::ImportData(IXFA_Doc* hDoc,
                                  const CFX_WideStringC& wsFilePath) {
  // TODO...
}

void CPDFXFA_Document::GotoURL(IXFA_Doc* hDoc,
                               const CFX_WideStringC& bsURL,
                               FX_BOOL bAppend) {
  if (hDoc != m_pXFADoc)
    return;

  if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
    return;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return;

  CFX_WideStringC str(bsURL.GetPtr());

  pEnv->FFI_GotoURL(this, str, bAppend);
}

FX_BOOL CPDFXFA_Document::IsValidationsEnabled(IXFA_Doc* hDoc) {
  if (hDoc != m_pXFADoc || !m_pSDKDoc)
    return FALSE;
  if (m_pSDKDoc->GetInterForm())
    return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled();

  return TRUE;
}
void CPDFXFA_Document::SetValidationsEnabled(IXFA_Doc* hDoc, FX_BOOL bEnabled) {
  if (hDoc != m_pXFADoc || !m_pSDKDoc)
    return;
  if (m_pSDKDoc->GetInterForm())
    m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled);
}
void CPDFXFA_Document::SetFocusWidget(IXFA_Doc* hDoc, IXFA_Widget* hWidget) {
  if (hDoc != m_pXFADoc)
    return;

  if (NULL == hWidget) {
    m_pSDKDoc->SetFocusAnnot(NULL);
    return;
  }

  int pageViewCount = m_pSDKDoc->GetPageViewCount();
  for (int i = 0; i < pageViewCount; i++) {
    CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i);
    if (pPageView == NULL)
      continue;
    CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget);
    if (pAnnot) {
      m_pSDKDoc->SetFocusAnnot(pAnnot);
      break;
    }
  }
}
void CPDFXFA_Document::Print(IXFA_Doc* hDoc,
                             int32_t nStartPage,
                             int32_t nEndPage,
                             FX_DWORD dwOptions) {
  if (hDoc != m_pXFADoc)
    return;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return;

  if (!pEnv->GetFormFillInfo() ||
      pEnv->GetFormFillInfo()->m_pJsPlatform == NULL)
    return;
  if (pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print == NULL)
    return;
  pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print(
      pEnv->GetFormFillInfo()->m_pJsPlatform,
      dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage,
      dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage,
      dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder,
      dwOptions & XFA_PRINTOPT_PrintAnnot);
}

void CPDFXFA_Document::GetURL(IXFA_Doc* hDoc, CFX_WideString& wsDocURL) {
  if (hDoc != m_pXFADoc)
    return;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return;

  pEnv->FFI_GetURL(this, wsDocURL);
}

FX_ARGB CPDFXFA_Document::GetHighlightColor(IXFA_Doc* hDoc) {
  if (hDoc != m_pXFADoc)
    return 0;
  if (m_pSDKDoc) {
    if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) {
      FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA);
      uint8_t alpha = pInterForm->GetHighlightAlpha();
      FX_ARGB argb = ArgbEncode((int)alpha, color);
      return argb;
    }
  }
  return 0;
}

FX_BOOL CPDFXFA_Document::_NotifySubmit(FX_BOOL bPrevOrPost) {
  if (bPrevOrPost)
    return _OnBeforeNotifySumbit();

  _OnAfterNotifySumbit();
  return TRUE;
}

FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() {
#ifdef PDF_ENABLE_XFA
  if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
    return TRUE;
  if (m_pXFADocView == NULL)
    return TRUE;
  IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
  if (pWidgetHandler == NULL)
    return TRUE;
  IXFA_WidgetAccIterator* pWidgetAccIterator =
      m_pXFADocView->CreateWidgetAccIterator();
  if (pWidgetAccIterator) {
    CXFA_EventParam Param;
    Param.m_eType = XFA_EVENT_PreSubmit;
    CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
    while (pWidgetAcc) {
      pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
      pWidgetAcc = pWidgetAccIterator->MoveToNext();
    }
    pWidgetAccIterator->Release();
  }
  pWidgetAccIterator = m_pXFADocView->CreateWidgetAccIterator();
  if (pWidgetAccIterator) {
    CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
    pWidgetAcc = pWidgetAccIterator->MoveToNext();
    while (pWidgetAcc) {
      int fRet = pWidgetAcc->ProcessValidate(-1);
      if (fRet == XFA_EVENTERROR_Error) {
        CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
        if (pEnv == NULL)
          return FALSE;
        CFX_WideString ws;
        ws.FromLocal(IDS_XFA_Validate_Input);
        CFX_ByteString bs = ws.UTF16LE_Encode();
        int len = bs.GetLength() / sizeof(unsigned short);
        pEnv->FFI_Alert(
            (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)),
            (FPDF_WIDESTRING)L"", 0, 1);
        bs.ReleaseBuffer(len * sizeof(unsigned short));
        pWidgetAccIterator->Release();
        return FALSE;
      }
      pWidgetAcc = pWidgetAccIterator->MoveToNext();
    }
    pWidgetAccIterator->Release();
    m_pXFADocView->UpdateDocView();
  }
#endif
  return TRUE;
}
void CPDFXFA_Document::_OnAfterNotifySumbit() {
  if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
    return;
  if (m_pXFADocView == NULL)
    return;
  IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
  if (pWidgetHandler == NULL)
    return;
  IXFA_WidgetAccIterator* pWidgetAccIterator =
      m_pXFADocView->CreateWidgetAccIterator();
  if (pWidgetAccIterator == NULL)
    return;
  CXFA_EventParam Param;
  Param.m_eType = XFA_EVENT_PostSubmit;

  CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
  while (pWidgetAcc) {
    pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
    pWidgetAcc = pWidgetAccIterator->MoveToNext();
  }
  pWidgetAccIterator->Release();
  m_pXFADocView->UpdateDocView();
}

FX_BOOL CPDFXFA_Document::SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit) {
  if (!_NotifySubmit(TRUE))
    return FALSE;
  if (NULL == m_pXFADocView)
    return FALSE;
  m_pXFADocView->UpdateDocView();

  FX_BOOL ret = _SubmitData(hDoc, submit);
  _NotifySubmit(FALSE);
  return ret;
}

IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(IXFA_Doc* hDoc,
                                               const CFX_WideString& wsLink) {
  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return FALSE;
  CFX_ByteString bs = wsLink.UTF16LE_Encode();
  int len = bs.GetLength() / sizeof(unsigned short);
  FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile(
      0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb");
  bs.ReleaseBuffer(len * sizeof(unsigned short));

  if (pFileHandler == NULL)
    return NULL;
  return new CFPDF_FileStream(pFileHandler);
}
FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
                                            int fileType,
                                            FPDF_DWORD encodeType,
                                            FPDF_DWORD flag) {
  if (NULL == m_pXFADocView)
    return FALSE;
  IXFA_DocHandler* pDocHandler = m_pApp->GetXFAApp()->GetDocHandler();
  CFX_ByteString content;

  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (pEnv == NULL)
    return FALSE;

  CFPDF_FileStream fileStream(pFileHandler);

  if (fileType == FXFA_SAVEAS_XML) {
    CFX_WideString ws;
    ws.FromLocal("data");
    CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
    fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength());
    pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream);
  } else if (fileType == FXFA_SAVEAS_XDP) {
    if (flag == 0)
      flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
             FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
    if (m_pPDFDoc == NULL) {
      fileStream.Flush();
      return FALSE;
    }
    CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
    if (pRoot == NULL) {
      fileStream.Flush();
      return FALSE;
    }
    CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
    if (NULL == pAcroForm) {
      fileStream.Flush();
      return FALSE;
    }
    CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
    if (pXFA == NULL) {
      fileStream.Flush();
      return FALSE;
    }
    if (!pXFA->IsArray()) {
      fileStream.Flush();
      return FALSE;
    }
    CPDF_Array* pArray = pXFA->GetArray();
    if (NULL == pArray) {
      fileStream.Flush();
      return FALSE;
    }
    int size = pArray->GetCount();
    for (int i = 1; i < size; i += 2) {
      CPDF_Object* pPDFObj = pArray->GetElement(i);
      CPDF_Object* pPrePDFObj = pArray->GetElement(i - 1);
      if (!pPrePDFObj->IsString())
        continue;
      if (!pPDFObj->IsReference())
        continue;
      CPDF_Object* pDirectObj = pPDFObj->GetDirect();
      if (!pDirectObj->IsStream())
        continue;
      if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG))
        continue;
      if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE))
        continue;
      if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET))
        continue;
      if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS))
        continue;
      if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA))
        continue;
      if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF))
        continue;
      if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM))
        continue;
      if (pPrePDFObj->GetString() == "form") {
        CFX_WideString ws;
        ws.FromLocal("form");
        pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream);
      } else if (pPrePDFObj->GetString() == "datasets") {
        CFX_WideString ws;
        ws.FromLocal("datasets");
        pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream);
      } else {
        // PDF,creator.
        // TODO:
      }
    }
  }
  return TRUE;
}

void CPDFXFA_Document::_ClearChangeMark() {
  if (m_pSDKDoc)
    m_pSDKDoc->ClearChangeMark();
}

void CPDFXFA_Document::_ToXFAContentFlags(CFX_WideString csSrcContent,
                                          FPDF_DWORD& flag) {
  if (csSrcContent.Find(L" config ", 0) != -1)
    flag |= FXFA_CONFIG;
  if (csSrcContent.Find(L" template ", 0) != -1)
    flag |= FXFA_TEMPLATE;
  if (csSrcContent.Find(L" localeSet ", 0) != -1)
    flag |= FXFA_LOCALESET;
  if (csSrcContent.Find(L" datasets ", 0) != -1)
    flag |= FXFA_DATASETS;
  if (csSrcContent.Find(L" xmpmeta ", 0) != -1)
    flag |= FXFA_XMPMETA;
  if (csSrcContent.Find(L" xfdf ", 0) != -1)
    flag |= FXFA_XFDF;
  if (csSrcContent.Find(L" form ", 0) != -1)
    flag |= FXFA_FORM;
  if (flag == 0)
    flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
           FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
}
FX_BOOL CPDFXFA_Document::_MailToInfo(CFX_WideString& csURL,
                                      CFX_WideString& csToAddress,
                                      CFX_WideString& csCCAddress,
                                      CFX_WideString& csBCCAddress,
                                      CFX_WideString& csSubject,
                                      CFX_WideString& csMsg) {
  CFX_WideString srcURL = csURL;
  srcURL.TrimLeft();
  if (0 != srcURL.Left(7).CompareNoCase(L"mailto:"))
    return FALSE;
  int pos = srcURL.Find(L'?', 0);
  CFX_WideString tmp;
  if (pos == -1) {
    pos = srcURL.Find(L'@', 0);
    if (pos == -1)
      return FALSE;
    else {
      tmp = srcURL.Right(csURL.GetLength() - 7);
      tmp.TrimLeft();
      tmp.TrimRight();
    }
  } else {
    tmp = srcURL.Left(pos);
    tmp = tmp.Right(tmp.GetLength() - 7);
    tmp.TrimLeft();
    tmp.TrimRight();
  }

  csToAddress = tmp;

  srcURL = srcURL.Right(srcURL.GetLength() - (pos + 1));
  while (!srcURL.IsEmpty()) {
    srcURL.TrimLeft();
    srcURL.TrimRight();
    pos = srcURL.Find(L'&', 0);
    if (pos == -1)
      tmp = srcURL;
    else
      tmp = srcURL.Left(pos);

    tmp.TrimLeft();
    tmp.TrimRight();
    if (tmp.GetLength() >= 3 && 0 == tmp.Left(3).CompareNoCase(L"cc=")) {
      tmp = tmp.Right(tmp.GetLength() - 3);
      if (!csCCAddress.IsEmpty())
        csCCAddress += L';';
      csCCAddress += tmp;

    } else if (tmp.GetLength() >= 4 &&
               0 == tmp.Left(4).CompareNoCase(L"bcc=")) {
      tmp = tmp.Right(tmp.GetLength() - 4);
      if (!csBCCAddress.IsEmpty())
        csBCCAddress += L';';
      csBCCAddress += tmp;
    } else if (tmp.GetLength() >= 8 &&
               0 == tmp.Left(8).CompareNoCase(L"subject=")) {
      tmp = tmp.Right(tmp.GetLength() - 8);
      csSubject += tmp;
    } else if (tmp.GetLength() >= 5 &&
               0 == tmp.Left(5).CompareNoCase(L"body=")) {
      tmp = tmp.Right(tmp.GetLength() - 5);
      csMsg += tmp;
    }
    if (pos == -1)
      srcURL = L"";
    else
      srcURL = srcURL.Right(csURL.GetLength() - (pos + 1));
  }
  csToAddress.Replace(L",", L";");
  csCCAddress.Replace(L",", L";");
  csBCCAddress.Replace(L",", L";");
  return TRUE;
}

FX_BOOL CPDFXFA_Document::_SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit) {
#ifdef PDF_ENABLE_XFA
  CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
  if (!pEnv)
    return FALSE;
  CFX_WideStringC csURLC;
  submit.GetSubmitTarget(csURLC);
  CFX_WideString csURL = csURLC;
  if (csURL.IsEmpty()) {
    CFX_WideString ws;
    ws.FromLocal("Submit cancelled.");
    CFX_ByteString bs = ws.UTF16LE_Encode();
    int len = bs.GetLength() / sizeof(unsigned short);
    pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)),
                    (FPDF_WIDESTRING)L"", 0, 4);
    bs.ReleaseBuffer(len * sizeof(unsigned short));
    return FALSE;
  }
  FPDF_BOOL bRet = TRUE;
  FPDF_FILEHANDLER* pFileHandler = nullptr;
  int fileFlag = -1;
  switch (submit.GetSubmitFormat()) {
    case XFA_ATTRIBUTEENUM_Xdp: {
      CFX_WideStringC csContentC;
      submit.GetSubmitXDPContent(csContentC);
      CFX_WideString csContent;
      csContent = csContentC;
      csContent.TrimLeft();
      csContent.TrimRight();
      CFX_WideString space;
      space.FromLocal(" ");
      csContent = space + csContent + space;
      FPDF_DWORD flag = 0;
      if (submit.IsSubmitEmbedPDF())
        flag |= FXFA_PDF;
      _ToXFAContentFlags(csContent, flag);
      pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb");
      fileFlag = FXFA_SAVEAS_XDP;
      _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag);
      break;
    }
    case XFA_ATTRIBUTEENUM_Xml:
      pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
      fileFlag = FXFA_SAVEAS_XML;
      _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0);
      break;
    case XFA_ATTRIBUTEENUM_Pdf:
      break;
    case XFA_ATTRIBUTEENUM_Urlencoded:
      pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
      fileFlag = FXFA_SAVEAS_XML;
      _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0);
      break;
    default:
      return false;
  }
  if (!pFileHandler)
    return FALSE;
  if (0 == csURL.Left(7).CompareNoCase(L"mailto:")) {
    CFX_WideString csToAddress;
    CFX_WideString csCCAddress;
    CFX_WideString csBCCAddress;
    CFX_WideString csSubject;
    CFX_WideString csMsg;
    bRet = _MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject,
                       csMsg);
    if (!bRet)
      return FALSE;
    CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode();
    CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode();
    CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode();
    CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode();
    CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode();
    FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength());
    FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength());
    FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength());
    FPDF_WIDESTRING pSubject =
        (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength());
    FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
    pEnv->FFI_EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg);
    bsTo.ReleaseBuffer();
    bsCC.ReleaseBuffer();
    bsBcc.ReleaseBuffer();
    bsSubject.ReleaseBuffer();
    bsMsg.ReleaseBuffer();
  } else {
    // http¡¢ftp
    CFX_WideString ws;
    CFX_ByteString bs = csURL.UTF16LE_Encode();
    int len = bs.GetLength() / sizeof(unsigned short);
    pEnv->FFI_UploadTo(
        pFileHandler, fileFlag,
        (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)));
    bs.ReleaseBuffer(len * sizeof(unsigned short));
  }
  return bRet;
#else
  return TRUE;
#endif
}

FX_BOOL CPDFXFA_Document::SetGlobalProperty(IXFA_Doc* hDoc,
                                            const CFX_ByteStringC& szPropName,
                                            FXJSE_HVALUE hValue) {
  if (hDoc != m_pXFADoc)
    return FALSE;

  if (m_pSDKDoc && m_pSDKDoc->GetEnv()->GetJSRuntime())
    return m_pSDKDoc->GetEnv()->GetJSRuntime()->SetHValueByName(szPropName,
                                                                hValue);
  return FALSE;
}
FX_BOOL CPDFXFA_Document::GetPDFScriptObject(IXFA_Doc* hDoc,
                                             const CFX_ByteStringC& utf8Name,
                                             FXJSE_HVALUE hValue) {
  if (hDoc != m_pXFADoc)
    return FALSE;

  if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime())
    return FALSE;

  if (!m_pJSContext) {
    m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc);
    m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext();
  }

  return _GetHValueByName(utf8Name, hValue,
                          m_pSDKDoc->GetEnv()->GetJSRuntime());
}
FX_BOOL CPDFXFA_Document::GetGlobalProperty(IXFA_Doc* hDoc,
                                            const CFX_ByteStringC& szPropName,
                                            FXJSE_HVALUE hValue) {
  if (hDoc != m_pXFADoc)
    return FALSE;
  if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime())
    return FALSE;

  if (!m_pJSContext) {
    m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc);
    m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext();
  }

  return _GetHValueByName(szPropName, hValue,
                          m_pSDKDoc->GetEnv()->GetJSRuntime());
}
FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name,
                                           FXJSE_HVALUE hValue,
                                           IJS_Runtime* runTime) {
  return runTime->GetHValueByName(utf8Name, hValue);
}


text:
namespace oslmp {
namespace impl {

class HQEqualizerPresets {

    HQEqualizerPresets() = delete;

public:
    struct PresetData {
        const char *name;
        int16_t num_bands;
        const int16_t *band_level;
    };

    static int16_t sGetNumPresets() noexcept;
    static const PresetData *sGetPresetData(uint16_t preset_no) noexcept;
};

} // namespace impl
} // namespace oslmp

#endif // HQEQUALIZER_PRESETS_HPP_


text:
package org.apache.skywalking.oap.server.core.storage.type;

import org.apache.skywalking.oap.server.core.storage.StorageData;

/**
 * Converter between the give T and K.
 *
 * @param <T> A storage entity implementation.
 * @param <K> The data structure recognized by the storage implementation.
 */
public interface StorageBuilder<T extends StorageData, K> {
    T storage2Entity(K storageData);

    K entity2Storage(T entity);
}


text:
boto v2.13.0
============

:date: 2013/09/12

This release adds support for VPC within AWS Opsworks, added dry-run support &
the ability to modify reserved instances in EC2 as well as several important
bugfixes for EC2, SNS & DynamoDBv2.

Features
--------

* Added support for VPC within Opsworks. (:sha:`56e1df3`)
* Added support for ``dry_run`` within EC2. (:sha:`dd7774c`)
* Added support for ``modify_reserved_instances`` &
  ``describe_reserved_instances_modifications`` within EC2. (:sha:`7a08672`)

Bugfixes
--------

* Fixed EC2's ``associate_public_ip`` to work correctly. (:sha:`9db6101`)
* Fixed a bug with ``dynamodb_load`` when working with sets. (:issue:`1664`,
  :sha:`ef2d28b`)
* Changed SNS ``publish`` to use POST. (:sha:`9c11772`)
* Fixed inability to create LaunchConfigurations when using Block Device
  Mappings. (:issue:`1709`, :issue:`1710`, :sha:`5fd728e`)
* Fixed DynamoDBv2's ``batch_write`` to appropriately handle
  ``UnprocessedItems``. (:issue:`1566`, :issue:`1679`, :issue:`1714`,
  :sha:`2fc2369`)
* Several documentation improvements/fixes:

    * Added Opsworks docs to the index. (:sha:`5d48763`)
    * Added docs on the correct string values for ``get_all_images``.
      (:issue:`1674`, :sha:`1e4ed2e`)
    * Removed a duplicate ``boto.s3.prefix`` entry from the docs.
      (:issue:`1707`, :sha:`b42d34c`)
    * Added an API reference for ``boto.swf.layer2``. (:issue:`1712`,
      :sha:`9f7b15f`)


text:
import { cloneDeep } from 'lodash';
/**
 * Extending object that entered in first argument.
 *
 * Returns extended object or false if have no target object or incorrect type.
 *
 * If you wish to clone source object (without modify it), just use empty new
 * object as first argument, like this:
 *   deepExtend({}, yourObj_1, [yourObj_N]);
 */
export var deepExtend = function () {
    var objects = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        objects[_i] = arguments[_i];
    }
    if (arguments.length < 1 || typeof arguments[0] !== 'object') {
        return false;
    }
    if (arguments.length < 2) {
        return arguments[0];
    }
    var target = arguments[0];
    // convert arguments to array and cut off target object
    var args = Array.prototype.slice.call(arguments, 1);
    var val, src;
    args.forEach(function (obj) {
        // skip argument if it is array or isn't object
        if (typeof obj !== 'object' || Array.isArray(obj)) {
            return;
        }
        Object.keys(obj).forEach(function (key) {
            src = target[key]; // source value
            val = obj[key]; // new value
            // recursion prevention
            if (val === target) {
                return;
                /**
                 * if new value isn't object then just overwrite by new value
                 * instead of extending.
                 */
            }
            else if (typeof val !== 'object' || val === null) {
                target[key] = val;
                return;
                // just clone arrays (and recursive clone objects inside)
            }
            else if (Array.isArray(val)) {
                target[key] = cloneDeep(val);
                return;
                // overwrite by new value if source isn't object or array
            }
            else if (typeof src !== 'object' || src === null || Array.isArray(src)) {
                target[key] = deepExtend({}, val);
                return;
                // source value and new value is objects both, extending...
            }
            else {
                target[key] = deepExtend(src, val);
                return;
            }
        });
    });
    return target;
};
var Deferred = (function () {
    function Deferred() {
        var _this = this;
        this.promise = new Promise(function (resolve, reject) {
            _this.resolve = resolve;
            _this.reject = reject;
        });
    }
    return Deferred;
}());
export { Deferred };
// getDeepFromObject({result: {data: 1}}, 'result.data', 2); // returns 1
export function getDeepFromObject(object, name, defaultValue) {
    if (object === void 0) { object = {}; }
    var keys = name.split('.');
    // clone the object
    var level = deepExtend({}, object);
    keys.forEach(function (k) {
        if (level && typeof level[k] !== 'undefined') {
            level = level[k];
        }
    });
    return typeof level === 'undefined' ? defaultValue : level;
}
//# sourceMappingURL=helpers.js.map