diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 4cda0db62..4e1a3a13f 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -13,6 +13,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Add INPUT_SHA env var + run: | + export INPUT_SHA=$(git rev-parse ${{ github.event.inputs.ref }}) + echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV + - name: Install Node ${{ env.NODE_VERSION }} uses: actions/setup-node@v3 with: @@ -67,6 +72,29 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - name: Get next release version + if: ${{ github.ref == 'refs/heads/master' }} + uses: actions/github-script@v7 + id: next-version + with: + result-encoding: string + script: | + const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version'); + const nextVersion = await getNextVersion({ + core, + github, + context, + sha: process.env.INPUT_SHA, + }); + return nextVersion; + env: + INPUT_SHA: ${{ env.INPUT_SHA }} + + - name: Write version to files + if: ${{ github.ref == 'refs/heads/master' }} + run: | + ./deployment/write-versions.sh ${{ steps.next-version.outputs.result }} + - name: Deploy updated builds to staging if: ${{ github.ref == 'refs/heads/master' }} id: build diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml new file mode 100644 index 000000000..01dd2e524 --- /dev/null +++ b/.github/workflows/deploy-release.yml @@ -0,0 +1,92 @@ +name: Publish Next Release (Manual) + +on: + workflow_dispatch: + inputs: + ref: + description: Reference git commit to release (e.g. "master", "12341fa") + required: true + default: master + +env: + NODE_VERSION: 18 + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + + - name: AWS, credentials setup + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: us-west-1 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + - name: Add INPUT_SHA env var + run: | + export INPUT_SHA=$(git rev-parse ${{ github.event.inputs.ref }}) + echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV + + - name: Install branch-github-actions + uses: actions/checkout@v4 + with: + repository: BranchMetrics/branch-github-actions + ref: master + path: .branch-github-actions + token: ${{ secrets.BRANCHLET_ACCESS_TOKEN }} + + - name: Get next release version + uses: actions/github-script@v7 + id: next-version + with: + result-encoding: string + script: | + const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version'); + const nextVersion = await getNextVersion({ + core, + github, + context, + sha: process.env.INPUT_SHA, + }); + return nextVersion; + env: + INPUT_SHA: ${{ env.INPUT_SHA }} + + - name: Install Node ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Write version to files + run: | + ./deployment/write-versions.sh ${{ steps.next-version.outputs.result }} + + - name: Configure NPM + run: npm ci + + - name: Release to npm, s3, prod + run: | + ./deployment/release.sh ${{ steps.next-version.outputs.result }} + + - name: Create Github Release + uses: actions/github-script@v7 + env: + GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }} + INPUT_SHA: ${{ env.INPUT_SHA }} + with: + result-encoding: string + script: | + const createRelease = require('./.branch-github-actions/custom-scripts/create-release'); + const sha = process.env.INPUT_SHA; + const version = process.env.GE_NEXT_VERSION; + await createRelease({ + core, + context, + github, + sha, + version, + }); \ No newline at end of file diff --git a/.gitignore b/.gitignore index d03d63141..cf23ce078 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ test-results.json .direnv/ dev.config dev.html -example.html \ No newline at end of file +example.html +dist/ \ No newline at end of file diff --git a/deployment/deploy-qa.sh b/deployment/deploy-qa.sh index 29094911d..8bb898862 100755 --- a/deployment/deploy-qa.sh +++ b/deployment/deploy-qa.sh @@ -24,14 +24,12 @@ NC='\033[0m' ./deployment/build-example-html.sh "key_live_feebgAAhbH9Tv85H5wLQhpdaefiZv5Dv" "https://api.stage.branch.io" "https://cdn.branch.io/branch-staging-latest.min.js" aws s3 cp example.html s3://branch-cdn/example-staging.html - ./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js" - aws s3 cp example.html s3://branch-builds/web-sdk/example.html - echo -en "${GREEN}Pushing to CDN ...${NC}\n" aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-staging-latest.min.js --cache-control "max-age=300" echo -en "Invalidating cloudfront distribution for staging ...\n" aws configure set preview.cloudfront true aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-staging-latest.min.js /example-staging + # Exit prompts echo -en "${GREEN}Done deploy QA script ...${NC}\n" diff --git a/deployment/deploy.sh b/deployment/deploy.sh deleted file mode 100755 index 94c7eb42d..000000000 --- a/deployment/deploy.sh +++ /dev/null @@ -1,174 +0,0 @@ -#/bin/bash - -# To trigger a production deploy push a -# commit with these items: -# -# version: x.y.z -# Changelog: - -set -e - -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' - -#-------------------------------------------------------------------------------------------- -# Production Deploy -#-------------------------------------------------------------------------------------------- - -if [ "$CIRCLE_BRANCH" == 'production' ]; then - - echo -en "${GREEN}Production Release...${NC}\n" - - GIT_COMMIT_MSG=$(git log --format=%B -n 1 $CIRCLE_SHA1) - - VER=$(echo "$GIT_COMMIT_MSG" | grep version | cut -f 2 -d " ") - - VERSION=$(echo $VER|tr -d '\r') - - DATE=$(date "+%Y-%m-%d") - - if [[ "$GIT_COMMIT_MSG" != *"version"* ]]; then - echo "Version not found in commit message - Not deploying" - exit 0 - fi - - VER_REG='^([0-9]+\.){0,2}(\*|[0-9]+)$' - - if [[ $VERSION =~ $VER_REG ]]; then - echo -en "${GREEN} Extracted version $VERSION ${NC}\n" - else - echo -en "${RED}ERROR: Wrong version input: '$VERSION' - Exiting Build ${NC}\n" - exit 1 - fi - - # Expect a Changelog in commit message - CHANGELOG=$(echo "$GIT_COMMIT_MSG" | awk '/Changelog/{y=1;next}y') - INSERT="## [v$VERSION] - $DATE" - - if [ -z "$CHANGELOG" ]; then - echo "Changelog not found in commit message - Not deploying" - exit 0 - fi - - echo -en "\n${GREEN}Extracted Changelog:\n$INSERT\n$CHANGELOG\n${NC}\n" - - echo -en "\n${GREEN}Resetting local repo${NC}\n" - -cat <add.txt -$CHANGELOG -EOF - - # Update CHANGELOG.md - sed -i '/\#\# \[VERSION\] - unreleased/r add.txt' CHANGELOG.md - - sed -i -e "s/## \[VERSION\] - unreleased/## [$VERSION] - $DATE/" CHANGELOG.md - perl -i -pe '$_ = "\n## [VERSION] - unreleased\n\n" if $. ==4' CHANGELOG.md - - echo -en "${GREEN}Bumping versions ...${NC}\n" - sed -i -e "s/version = '.*';$/version = '$VERSION';/" src/0_config.js - sed -i -e "s/version = '.*';$/version = '$VERSION';/" test/web-config.js - - sed -i -e "s/\"version\":.*$/\"version\": \"$VERSION\",/" package.json - sed -i -e "s/\"build\":.*$/\"build\": \"$VERSION\"/" package.json - - sed -i -e "s/\"version\":.*$/\"version\": \"$VERSION\",/" bower.json - sed -i -e "s/\"build\":.*$/\"build\": \"$VERSION\"/" bower.json - - echo -en "${GREEN}make release...${NC}\n" - make release - - rm add.txt - - echo -en "${GREEN}Commiting changes back to repo${NC}\n" - git config --global user.email "buildbot@branch.io" && git config --global user.name "Build Bot" - git config --global push.default simple - git commit -am "Pushing release $VERSION [ci skip]" - - echo -en "${GREEN}Pushing to S3: branch-cdn ...${NC}\n" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-$VERSION.min.js --acl public-read --cache-control "max-age=300" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --acl public-read --cache-control "max-age=300" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-v2.0.0.min.js --acl public-read --cache-control "max-age=300" - aws s3 cp example.html s3://branch-cdn/example.html --acl public-read - - # Pushing to QA builds - echo -en "${GREEN}Pushing to S3: branch-builds ...${NC}\n" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-$VERSION.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-latest.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-v2.0.0.min.js --acl public-read - aws s3 cp --content-type="text/javascript" dist/build.js s3://branch-builds/websdk/branch.js --acl public-read - aws s3 cp example.html s3://branch-builds/websdk/example.html --acl public-read - - # Invalidate cache at CDN - echo -en "${GREEN}Invalidating cloudfrond distribution for WebSDK ...${NC}\n" - aws configure set preview.cloudfront true - aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js /example.html /branch-v2.0.0.min.js - - echo -en "${GREEN}Pushing git tags${NC}\n" - git tag v$VERSION - git push origin v$VERSION - - echo -en "${GREEN}npm publish ...${NC}\n" - npm publish - - # Reset - echo -en "${GREEN}make clean ...${NC}\n" - make clean - make - git commit -am "Resetting to HEAD [ci skip]" - - echo -en "${GREEN}Updating production files ...${NC}\n" - git push origin $CIRCLE_BRANCH - - # Push back to master - echo -en "${GREEN}Updating Master files ...${NC}\n" - rm -rf /tmp/$CIRCLE_PROJECT_REPONAME - git clone git@github.com:BranchMetrics/$CIRCLE_PROJECT_REPONAME.git /tmp/$CIRCLE_PROJECT_REPONAME - - pushd /tmp/$CIRCLE_PROJECT_REPONAME - - git merge origin/production -m "Merge Production [ci skip]" - git push origin master - popd - - # Send an update to slack channels - - # Currently broken. Was sending to archived #web-sdk channel anyway. - # DEPLOY_IMG=http://workshops.lewagon.org/assets/landing-2/deploy-button-5068ec2c575492ba428569111afe3ce6.jpg - # echo -en "${GREEN}Sending update to slack ...${NC}\n" - # #uncomment to send updates to int-eng - # #slackcli -t $SLACK_TOKEN -h int-eng -m $MESSAGE -u websdk-deploy -i $DEPLOY_IMG - # slackcli -t $SLACK_TOKEN -h web-sdk -m "$CIRCLE_USERNAME deployed WebSDK v$VERSION" -u websdk-deploy -i $DEPLOY_IMG - # - # echo "Please update the javascript version in https://github.com/BranchMetrics/documentation/edit/master/ingredients/web_sdk/_initialization.md" - - echo "Check the following links are valid:" - echo "- https://cdn.branch.io/branch-$VERSION.min.js" - echo "- https://cdn.branch.io/example.html using the right version number $VERSION" - echo "- https://www.npmjs.com/package/branch-sdk using the right version number $VERSION" - -#-------------------------------------------------------------------------------------------- -# Master Deploy -#-------------------------------------------------------------------------------------------- - -elif [ "$CIRCLE_BRANCH" == 'master' ]; then - - echo -en "${GREEN}QA Release...${NC}\n" - - echo -en "${GREEN}make release ...${NC}\n" - make release - - echo -en "${GREEN}Pushing to S3: branch-builds ...${NC}\n" - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-$VERSION.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-latest.min.js --acl public-read - aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-builds/websdk/branch-v2.0.0.min.js --acl public-read - aws s3 cp --content-type="text/javascript" dist/build.js s3://branch-builds/websdk/branch.js --acl public-read - aws s3 cp example.html s3://branch-builds/websdk/example.html --acl public-read - -else - echo -en "${GREEN}No associated target to $CIRCLE_BRANCH - not Deploying${NC}\n" - exit 0 -fi - -# Exit prompts -echo -en "${GREEN}Done deploy script ...${NC}\n" diff --git a/deployment/release.sh b/deployment/release.sh new file mode 100755 index 000000000..0922cb583 --- /dev/null +++ b/deployment/release.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; } + +VERSION_NO_V=$1 +VERSION="v"$VERSION_NO_V +DATE=$(date "+%Y-%m-%d") + +echo "Releasing Branch Web SDK" + +make release + +./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js" +aws s3 cp example.html s3://branch-builds/example.html + +aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-$VERSION.min.js --acl public-read +aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --acl public-read + +echo -en "Invalidating cloudfront distribution...\n" +aws configure set preview.cloudfront true +aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js + +npm publish + +echo "Post-release sanity checks." +read -p "Can you visit https://cdn.branch.io/branch-$VERSION.min.js ?" -n 1 -r +echo +read -p "Is https://cdn.branch.io/example.html using the right version number $VERSION?" -n 1 -r +echo +read -p "Is https://www.npmjs.com/package/branch-sdk using the right version number $VERSION?" -n 1 -r +echo \ No newline at end of file diff --git a/deployment/write-versions.sh b/deployment/write-versions.sh new file mode 100755 index 000000000..67e4f9eac --- /dev/null +++ b/deployment/write-versions.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; } + +sed -i -e "s/\"version\":.*$/\"version\": \"$1\",/" package.json +sed -i -e "s/version = '.*';$/version = '$1';/" src/0_config.js +sed -i -e "s/version = '.*';$/version = '$1';/" test/web-config.js \ No newline at end of file diff --git a/dist/build.js b/dist/build.js deleted file mode 100644 index 5c36b5a95..000000000 --- a/dist/build.js +++ /dev/null @@ -1,3297 +0,0 @@ -(function() {// Input 0 -/* - - Copyright The Closure Library Authors. - SPDX-License-Identifier: Apache-2.0 -*/ -var $jscomp = $jscomp || {}; -$jscomp.scope = {}; -$jscomp.ASSUME_ES5 = !1; -$jscomp.ASSUME_NO_NATIVE_MAP = !1; -$jscomp.ASSUME_NO_NATIVE_SET = !1; -$jscomp.SIMPLE_FROUND_POLYFILL = !1; -$jscomp.ISOLATE_POLYFILLS = !1; -$jscomp.FORCE_POLYFILL_PROMISE = !1; -$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION = !1; -$jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) { - if (a == Array.prototype || a == Object.prototype) { - return a; - } - a[b] = c.value; - return a; -}; -$jscomp.getGlobal = function(a) { - a = ["object" == typeof globalThis && globalThis, a, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof global && global]; - for (var b = 0; b < a.length; ++b) { - var c = a[b]; - if (c && c.Math == Math) { - return c; - } - } - throw Error("Cannot find global object"); -}; -$jscomp.global = $jscomp.getGlobal(this); -$jscomp.IS_SYMBOL_NATIVE = "function" === typeof Symbol && "symbol" === typeof Symbol("x"); -$jscomp.TRUST_ES6_POLYFILLS = !$jscomp.ISOLATE_POLYFILLS || $jscomp.IS_SYMBOL_NATIVE; -$jscomp.polyfills = {}; -$jscomp.propertyToPolyfillSymbol = {}; -$jscomp.POLYFILL_PREFIX = "$jscp$"; -var $jscomp$lookupPolyfilledValue = function(a, b, c) { - if (!c || null != a) { - c = $jscomp.propertyToPolyfillSymbol[b]; - if (null == c) { - return a[b]; - } - c = a[c]; - return void 0 !== c ? c : a[b]; - } -}; -$jscomp.polyfill = function(a, b, c, d) { - b && ($jscomp.ISOLATE_POLYFILLS ? $jscomp.polyfillIsolated(a, b, c, d) : $jscomp.polyfillUnisolated(a, b, c, d)); -}; -$jscomp.polyfillUnisolated = function(a, b, c, d) { - c = $jscomp.global; - a = a.split("."); - for (d = 0; d < a.length - 1; d++) { - var e = a[d]; - if (!(e in c)) { - return; - } - c = c[e]; - } - a = a[a.length - 1]; - d = c[a]; - b = b(d); - b != d && null != b && $jscomp.defineProperty(c, a, {configurable:!0, writable:!0, value:b}); -}; -$jscomp.polyfillIsolated = function(a, b, c, d) { - var e = a.split("."); - a = 1 === e.length; - d = e[0]; - d = !a && d in $jscomp.polyfills ? $jscomp.polyfills : $jscomp.global; - for (var f = 0; f < e.length - 1; f++) { - var g = e[f]; - if (!(g in d)) { - return; - } - d = d[g]; - } - e = e[e.length - 1]; - c = $jscomp.IS_SYMBOL_NATIVE && "es6" === c ? d[e] : null; - b = b(c); - null != b && (a ? $jscomp.defineProperty($jscomp.polyfills, e, {configurable:!0, writable:!0, value:b}) : b !== c && (void 0 === $jscomp.propertyToPolyfillSymbol[e] && (c = 1E9 * Math.random() >>> 0, $jscomp.propertyToPolyfillSymbol[e] = $jscomp.IS_SYMBOL_NATIVE ? $jscomp.global.Symbol(e) : $jscomp.POLYFILL_PREFIX + c + "$" + e), $jscomp.defineProperty(d, $jscomp.propertyToPolyfillSymbol[e], {configurable:!0, writable:!0, value:b}))); -}; -$jscomp.polyfill("Array.prototype.includes", function(a) { - return a ? a : function(b, c) { - var d = this; - d instanceof String && (d = String(d)); - var e = d.length; - c = c || 0; - for (0 > c && (c = Math.max(c + e, 0)); c < e; c++) { - var f = d[c]; - if (f === b || Object.is(f, b)) { - return !0; - } - } - return !1; - }; -}, "es7", "es3"); -var COMPILED = !0, goog = goog || {}; -goog.global = this || self; -goog.exportPath_ = function(a, b, c, d) { - a = a.split("."); - d = d || goog.global; - a[0] in d || "undefined" == typeof d.execScript || d.execScript("var " + a[0]); - for (var e; a.length && (e = a.shift());) { - if (a.length || void 0 === b) { - d = d[e] && d[e] !== Object.prototype[e] ? d[e] : d[e] = {}; - } else { - if (!c && goog.isObject(b) && goog.isObject(d[e])) { - for (var f in b) { - b.hasOwnProperty(f) && (d[e][f] = b[f]); - } - } else { - d[e] = b; - } - } - } -}; -goog.define = function(a, b) { - if (!COMPILED) { - var c = goog.global.CLOSURE_UNCOMPILED_DEFINES, d = goog.global.CLOSURE_DEFINES; - c && void 0 === c.nodeType && Object.prototype.hasOwnProperty.call(c, a) ? b = c[a] : d && void 0 === d.nodeType && Object.prototype.hasOwnProperty.call(d, a) && (b = d[a]); - } - return b; -}; -goog.FEATURESET_YEAR = 2012; -goog.DEBUG = !0; -goog.LOCALE = "en"; -goog.TRUSTED_SITE = !0; -goog.DISALLOW_TEST_ONLY_CODE = COMPILED && !goog.DEBUG; -goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING = !1; -goog.provide = function(a) { - if (goog.isInModuleLoader_()) { - throw Error("goog.provide cannot be used within a module."); - } - if (!COMPILED && goog.isProvided_(a)) { - throw Error('Namespace "' + a + '" already declared.'); - } - goog.constructNamespace_(a); -}; -goog.constructNamespace_ = function(a, b, c) { - if (!COMPILED) { - delete goog.implicitNamespaces_[a]; - for (var d = a; (d = d.substring(0, d.lastIndexOf("."))) && !goog.getObjectByName(d);) { - goog.implicitNamespaces_[d] = !0; - } - } - goog.exportPath_(a, b, c); -}; -goog.NONCE_PATTERN_ = /^[\w+/_-]+[=]{0,2}$/; -goog.getScriptNonce_ = function(a) { - a = (a || goog.global).document; - return (a = a.querySelector && a.querySelector("script[nonce]")) && (a = a.nonce || a.getAttribute("nonce")) && goog.NONCE_PATTERN_.test(a) ? a : ""; -}; -goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/; -goog.module = function(a) { - if ("string" !== typeof a || !a || -1 == a.search(goog.VALID_MODULE_RE_)) { - throw Error("Invalid module identifier"); - } - if (!goog.isInGoogModuleLoader_()) { - throw Error("Module " + a + " has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide."); - } - if (goog.moduleLoaderState_.moduleName) { - throw Error("goog.module may only be called once per module."); - } - goog.moduleLoaderState_.moduleName = a; - if (!COMPILED) { - if (goog.isProvided_(a)) { - throw Error('Namespace "' + a + '" already declared.'); - } - delete goog.implicitNamespaces_[a]; - } -}; -goog.module.get = function(a) { - return goog.module.getInternal_(a); -}; -goog.module.getInternal_ = function(a) { - if (!COMPILED) { - if (a in goog.loadedModules_) { - return goog.loadedModules_[a].exports; - } - if (!goog.implicitNamespaces_[a]) { - return a = goog.getObjectByName(a), null != a ? a : null; - } - } - return null; -}; -goog.ModuleType = {ES6:"es6", GOOG:"goog"}; -goog.moduleLoaderState_ = null; -goog.isInModuleLoader_ = function() { - return goog.isInGoogModuleLoader_() || goog.isInEs6ModuleLoader_(); -}; -goog.isInGoogModuleLoader_ = function() { - return !!goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.GOOG; -}; -goog.isInEs6ModuleLoader_ = function() { - if (goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.ES6) { - return !0; - } - var a = goog.global.$jscomp; - return a ? "function" != typeof a.getCurrentModulePath ? !1 : !!a.getCurrentModulePath() : !1; -}; -goog.module.declareLegacyNamespace = function() { - if (!COMPILED && !goog.isInGoogModuleLoader_()) { - throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module"); - } - if (!COMPILED && !goog.moduleLoaderState_.moduleName) { - throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace."); - } - goog.moduleLoaderState_.declareLegacyNamespace = !0; -}; -goog.declareModuleId = function(a) { - if (!COMPILED) { - if (!goog.isInEs6ModuleLoader_()) { - throw Error("goog.declareModuleId may only be called from within an ES6 module"); - } - if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) { - throw Error("goog.declareModuleId may only be called once per module."); - } - if (a in goog.loadedModules_) { - throw Error('Module with namespace "' + a + '" already exists.'); - } - } - if (goog.moduleLoaderState_) { - goog.moduleLoaderState_.moduleName = a; - } else { - var b = goog.global.$jscomp; - if (!b || "function" != typeof b.getCurrentModulePath) { - throw Error('Module with namespace "' + a + '" has been loaded incorrectly.'); - } - b = b.require(b.getCurrentModulePath()); - goog.loadedModules_[a] = {exports:b, type:goog.ModuleType.ES6, moduleId:a}; - } -}; -goog.setTestOnly = function(a) { - if (goog.DISALLOW_TEST_ONLY_CODE) { - throw a = a || "", Error("Importing test-only code into non-debug environment" + (a ? ": " + a : ".")); - } -}; -goog.forwardDeclare = function(a) { -}; -COMPILED || (goog.isProvided_ = function(a) { - return a in goog.loadedModules_ || !goog.implicitNamespaces_[a] && null != goog.getObjectByName(a); -}, goog.implicitNamespaces_ = {"goog.module":!0}); -goog.getObjectByName = function(a, b) { - a = a.split("."); - b = b || goog.global; - for (var c = 0; c < a.length; c++) { - if (b = b[a[c]], null == b) { - return null; - } - } - return b; -}; -goog.addDependency = function(a, b, c, d) { - !COMPILED && goog.DEPENDENCIES_ENABLED && goog.debugLoader_.addDependency(a, b, c, d); -}; -goog.ENABLE_DEBUG_LOADER = !1; -goog.logToConsole_ = function(a) { - goog.global.console && goog.global.console.error(a); -}; -goog.require = function(a) { - if (!COMPILED) { - goog.ENABLE_DEBUG_LOADER && goog.debugLoader_.requested(a); - if (goog.isProvided_(a)) { - if (goog.isInModuleLoader_()) { - return goog.module.getInternal_(a); - } - } else if (goog.ENABLE_DEBUG_LOADER) { - var b = goog.moduleLoaderState_; - goog.moduleLoaderState_ = null; - try { - goog.debugLoader_.load_(a); - } finally { - goog.moduleLoaderState_ = b; - } - } - return null; - } -}; -goog.requireType = function(a) { - return {}; -}; -goog.basePath = ""; -goog.abstractMethod = function() { - throw Error("unimplemented abstract method"); -}; -goog.addSingletonGetter = function(a) { - a.instance_ = void 0; - a.getInstance = function() { - if (a.instance_) { - return a.instance_; - } - goog.DEBUG && (goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = a); - return a.instance_ = new a(); - }; -}; -goog.instantiatedSingletons_ = []; -goog.LOAD_MODULE_USING_EVAL = !0; -goog.SEAL_MODULE_EXPORTS = goog.DEBUG; -goog.loadedModules_ = {}; -goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER; -goog.TRANSPILE = "detect"; -goog.ASSUME_ES_MODULES_TRANSPILED = !1; -goog.TRUSTED_TYPES_POLICY_NAME = "goog"; -goog.hasBadLetScoping = null; -goog.loadModule = function(a) { - var b = goog.moduleLoaderState_; - try { - goog.moduleLoaderState_ = {moduleName:"", declareLegacyNamespace:!1, type:goog.ModuleType.GOOG}; - var c = {}, d = c; - if ("function" === typeof a) { - d = a.call(void 0, d); - } else if ("string" === typeof a) { - d = goog.loadModuleFromSource_.call(void 0, d, a); - } else { - throw Error("Invalid module definition"); - } - var e = goog.moduleLoaderState_.moduleName; - if ("string" === typeof e && e) { - goog.moduleLoaderState_.declareLegacyNamespace ? goog.constructNamespace_(e, d, c !== d) : goog.SEAL_MODULE_EXPORTS && Object.seal && "object" == typeof d && null != d && Object.seal(d), goog.loadedModules_[e] = {exports:d, type:goog.ModuleType.GOOG, moduleId:goog.moduleLoaderState_.moduleName}; - } else { - throw Error('Invalid module name "' + e + '"'); - } - } finally { - goog.moduleLoaderState_ = b; - } -}; -goog.loadModuleFromSource_ = function(a, b) { - eval(goog.CLOSURE_EVAL_PREFILTER_.createScript(b)); - return a; -}; -goog.normalizePath_ = function(a) { - a = a.split("/"); - for (var b = 0; b < a.length;) { - "." == a[b] ? a.splice(b, 1) : b && ".." == a[b] && a[b - 1] && ".." != a[b - 1] ? a.splice(--b, 2) : b++; - } - return a.join("/"); -}; -goog.loadFileSync_ = function(a) { - if (goog.global.CLOSURE_LOAD_FILE_SYNC) { - return goog.global.CLOSURE_LOAD_FILE_SYNC(a); - } - try { - var b = new goog.global.XMLHttpRequest(); - b.open("get", a, !1); - b.send(); - return 0 == b.status || 200 == b.status ? b.responseText : null; - } catch (c) { - return null; - } -}; -goog.typeOf = function(a) { - var b = typeof a; - return "object" != b ? b : a ? Array.isArray(a) ? "array" : b : "null"; -}; -goog.isArrayLike = function(a) { - var b = goog.typeOf(a); - return "array" == b || "object" == b && "number" == typeof a.length; -}; -goog.isDateLike = function(a) { - return goog.isObject(a) && "function" == typeof a.getFullYear; -}; -goog.isObject = function(a) { - var b = typeof a; - return "object" == b && null != a || "function" == b; -}; -goog.getUid = function(a) { - return Object.prototype.hasOwnProperty.call(a, goog.UID_PROPERTY_) && a[goog.UID_PROPERTY_] || (a[goog.UID_PROPERTY_] = ++goog.uidCounter_); -}; -goog.hasUid = function(a) { - return !!a[goog.UID_PROPERTY_]; -}; -goog.removeUid = function(a) { - null !== a && "removeAttribute" in a && a.removeAttribute(goog.UID_PROPERTY_); - try { - delete a[goog.UID_PROPERTY_]; - } catch (b) { - } -}; -goog.UID_PROPERTY_ = "closure_uid_" + (1e9 * Math.random() >>> 0); -goog.uidCounter_ = 0; -goog.cloneObject = function(a) { - var b = goog.typeOf(a); - if ("object" == b || "array" == b) { - if ("function" === typeof a.clone) { - return a.clone(); - } - if ("undefined" !== typeof Map && a instanceof Map) { - return new Map(a); - } - if ("undefined" !== typeof Set && a instanceof Set) { - return new Set(a); - } - b = "array" == b ? [] : {}; - for (var c in a) { - b[c] = goog.cloneObject(a[c]); - } - return b; - } - return a; -}; -goog.bindNative_ = function(a, b, c) { - return a.call.apply(a.bind, arguments); -}; -goog.bindJs_ = function(a, b, c) { - if (!a) { - throw Error(); - } - if (2 < arguments.length) { - var d = Array.prototype.slice.call(arguments, 2); - return function() { - var e = Array.prototype.slice.call(arguments); - Array.prototype.unshift.apply(e, d); - return a.apply(b, e); - }; - } - return function() { - return a.apply(b, arguments); - }; -}; -goog.bind = function(a, b, c) { - Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? goog.bind = goog.bindNative_ : goog.bind = goog.bindJs_; - return goog.bind.apply(null, arguments); -}; -goog.partial = function(a, b) { - var c = Array.prototype.slice.call(arguments, 1); - return function() { - var d = c.slice(); - d.push.apply(d, arguments); - return a.apply(this, d); - }; -}; -goog.now = function() { - return Date.now(); -}; -goog.globalEval = function(a) { - (0,eval)(a); -}; -goog.getCssName = function(a, b) { - if ("." == String(a).charAt(0)) { - throw Error('className passed in goog.getCssName must not start with ".". You passed: ' + a); - } - var c = function(e) { - return goog.cssNameMapping_[e] || e; - }, d = function(e) { - e = e.split("-"); - for (var f = [], g = 0; g < e.length; g++) { - f.push(c(e[g])); - } - return f.join("-"); - }; - d = goog.cssNameMapping_ ? "BY_WHOLE" == goog.cssNameMappingStyle_ ? c : d : function(e) { - return e; - }; - a = b ? a + "-" + d(b) : d(a); - return goog.global.CLOSURE_CSS_NAME_MAP_FN ? goog.global.CLOSURE_CSS_NAME_MAP_FN(a) : a; -}; -goog.setCssNameMapping = function(a, b) { - goog.cssNameMapping_ = a; - goog.cssNameMappingStyle_ = b; -}; -!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING && (goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING); -goog.GetMsgOptions = function() { -}; -goog.getMsg = function(a, b, c) { - c && c.html && (a = a.replace(/").replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, "&")); - b && (a = a.replace(/\{\$([^}]+)}/g, function(d, e) { - return null != b && e in b ? b[e] : d; - })); - return a; -}; -goog.getMsgWithFallback = function(a, b) { - return a; -}; -goog.exportSymbol = function(a, b, c) { - goog.exportPath_(a, b, !0, c); -}; -goog.exportProperty = function(a, b, c) { - a[b] = c; -}; -goog.inherits = function(a, b) { - function c() { - } - c.prototype = b.prototype; - a.superClass_ = b.prototype; - a.prototype = new c(); - a.prototype.constructor = a; - a.base = function(d, e, f) { - for (var g = Array(arguments.length - 2), h = 2; h < arguments.length; h++) { - g[h - 2] = arguments[h]; - } - return b.prototype[e].apply(d, g); - }; -}; -goog.scope = function(a) { - if (goog.isInModuleLoader_()) { - throw Error("goog.scope is not supported within a module."); - } - a.call(goog.global); -}; -COMPILED || (goog.global.COMPILED = COMPILED); -goog.defineClass = function(a, b) { - var c = b.constructor, d = b.statics; - c && c != Object.prototype.constructor || (c = function() { - throw Error("cannot instantiate an interface (no constructor defined)."); - }); - c = goog.defineClass.createSealingConstructor_(c, a); - a && goog.inherits(c, a); - delete b.constructor; - delete b.statics; - goog.defineClass.applyProperties_(c.prototype, b); - null != d && (d instanceof Function ? d(c) : goog.defineClass.applyProperties_(c, d)); - return c; -}; -goog.defineClass.SEAL_CLASS_INSTANCES = goog.DEBUG; -goog.defineClass.createSealingConstructor_ = function(a, b) { - return goog.defineClass.SEAL_CLASS_INSTANCES ? function() { - var c = a.apply(this, arguments) || this; - c[goog.UID_PROPERTY_] = c[goog.UID_PROPERTY_]; - return c; - } : a; -}; -goog.defineClass.OBJECT_PROTOTYPE_FIELDS_ = "constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "); -goog.defineClass.applyProperties_ = function(a, b) { - for (var c in b) { - Object.prototype.hasOwnProperty.call(b, c) && (a[c] = b[c]); - } - for (var d = 0; d < goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length; d++) { - c = goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[d], Object.prototype.hasOwnProperty.call(b, c) && (a[c] = b[c]); - } -}; -goog.identity_ = function(a) { - return a; -}; -goog.createTrustedTypesPolicy = function(a) { - var b = null, c = goog.global.trustedTypes; - if (!c || !c.createPolicy) { - return b; - } - try { - b = c.createPolicy(a, {createHTML:goog.identity_, createScript:goog.identity_, createScriptURL:goog.identity_}); - } catch (d) { - goog.logToConsole_(d.message); - } - return b; -}; -!COMPILED && goog.DEPENDENCIES_ENABLED && (goog.isEdge_ = function() { - return !!(goog.global.navigator && goog.global.navigator.userAgent ? goog.global.navigator.userAgent : "").match(/Edge\/(\d+)(\.\d)*/i); -}, goog.inHtmlDocument_ = function() { - var a = goog.global.document; - return null != a && "write" in a; -}, goog.isDocumentLoading_ = function() { - var a = goog.global.document; - return a.attachEvent ? "complete" != a.readyState : "loading" == a.readyState; -}, goog.findBasePath_ = function() { - if (void 0 != goog.global.CLOSURE_BASE_PATH && "string" === typeof goog.global.CLOSURE_BASE_PATH) { - goog.basePath = goog.global.CLOSURE_BASE_PATH; - } else if (goog.inHtmlDocument_()) { - var a = goog.global.document, b = a.currentScript; - a = b ? [b] : a.getElementsByTagName("SCRIPT"); - for (b = a.length - 1; 0 <= b; --b) { - var c = a[b].src, d = c.lastIndexOf("?"); - d = -1 == d ? c.length : d; - if ("base.js" == c.slice(d - 7, d)) { - goog.basePath = c.slice(0, d - 7); - break; - } - } - } -}, goog.findBasePath_(), goog.protectScriptTag_ = function(a) { - return a.replace(/<\/(SCRIPT)/ig, "\\x3c/$1"); -}, goog.DebugLoader_ = function() { - this.dependencies_ = {}; - this.idToPath_ = {}; - this.written_ = {}; - this.loadingDeps_ = []; - this.depsToLoad_ = []; - this.paused_ = !1; - this.factory_ = new goog.DependencyFactory(); - this.deferredCallbacks_ = {}; - this.deferredQueue_ = []; -}, goog.DebugLoader_.prototype.bootstrap = function(a, b) { - function c() { - d && (goog.global.setTimeout(d, 0), d = null); - } - var d = b; - if (a.length) { - b = []; - for (var e = 0; e < a.length; e++) { - var f = this.getPathFromDeps_(a[e]); - if (!f) { - throw Error("Unregonized namespace: " + a[e]); - } - b.push(this.dependencies_[f]); - } - f = goog.require; - var g = 0; - for (e = 0; e < a.length; e++) { - f(a[e]), b[e].onLoad(function() { - ++g == a.length && c(); - }); - } - } else { - c(); - } -}, goog.DebugLoader_.prototype.loadClosureDeps = function() { - this.depsToLoad_.push(this.factory_.createDependency(goog.normalizePath_(goog.basePath + "deps.js"), "deps.js", [], [], {})); - this.loadDeps_(); -}, goog.DebugLoader_.prototype.requested = function(a, b) { - (a = this.getPathFromDeps_(a)) && (b || this.areDepsLoaded_(this.dependencies_[a].requires)) && (b = this.deferredCallbacks_[a]) && (delete this.deferredCallbacks_[a], b()); -}, goog.DebugLoader_.prototype.setDependencyFactory = function(a) { - this.factory_ = a; -}, goog.DebugLoader_.prototype.load_ = function(a) { - if (this.getPathFromDeps_(a)) { - var b = this, c = [], d = function(e) { - var f = b.getPathFromDeps_(e); - if (!f) { - throw Error("Bad dependency path or symbol: " + e); - } - if (!b.written_[f]) { - b.written_[f] = !0; - e = b.dependencies_[f]; - for (f = 0; f < e.requires.length; f++) { - goog.isProvided_(e.requires[f]) || d(e.requires[f]); - } - c.push(e); - } - }; - d(a); - a = !!this.depsToLoad_.length; - this.depsToLoad_ = this.depsToLoad_.concat(c); - this.paused_ || a || this.loadDeps_(); - } else { - goog.logToConsole_("goog.require could not find: " + a); - } -}, goog.DebugLoader_.prototype.loadDeps_ = function() { - for (var a = this, b = this.paused_; this.depsToLoad_.length && !b;) { - (function() { - var c = !1, d = a.depsToLoad_.shift(), e = !1; - a.loading_(d); - var f = {pause:function() { - if (c) { - throw Error("Cannot call pause after the call to load."); - } - b = !0; - }, resume:function() { - c ? a.resume_() : b = !1; - }, loaded:function() { - if (e) { - throw Error("Double call to loaded."); - } - e = !0; - a.loaded_(d); - }, pending:function() { - for (var g = [], h = 0; h < a.loadingDeps_.length; h++) { - g.push(a.loadingDeps_[h]); - } - return g; - }, setModuleState:function(g) { - goog.moduleLoaderState_ = {type:g, moduleName:"", declareLegacyNamespace:!1}; - }, registerEs6ModuleExports:function(g, h, k) { - k && (goog.loadedModules_[k] = {exports:h, type:goog.ModuleType.ES6, moduleId:k || ""}); - }, registerGoogModuleExports:function(g, h) { - goog.loadedModules_[g] = {exports:h, type:goog.ModuleType.GOOG, moduleId:g}; - }, clearModuleState:function() { - goog.moduleLoaderState_ = null; - }, defer:function(g) { - if (c) { - throw Error("Cannot register with defer after the call to load."); - } - a.defer_(d, g); - }, areDepsLoaded:function() { - return a.areDepsLoaded_(d.requires); - }}; - try { - d.load(f); - } finally { - c = !0; - } - })(); - } - b && this.pause_(); -}, goog.DebugLoader_.prototype.pause_ = function() { - this.paused_ = !0; -}, goog.DebugLoader_.prototype.resume_ = function() { - this.paused_ && (this.paused_ = !1, this.loadDeps_()); -}, goog.DebugLoader_.prototype.loading_ = function(a) { - this.loadingDeps_.push(a); -}, goog.DebugLoader_.prototype.loaded_ = function(a) { - for (var b = 0; b < this.loadingDeps_.length; b++) { - if (this.loadingDeps_[b] == a) { - this.loadingDeps_.splice(b, 1); - break; - } - } - for (b = 0; b < this.deferredQueue_.length; b++) { - if (this.deferredQueue_[b] == a.path) { - this.deferredQueue_.splice(b, 1); - break; - } - } - if (this.loadingDeps_.length == this.deferredQueue_.length && !this.depsToLoad_.length) { - for (; this.deferredQueue_.length;) { - this.requested(this.deferredQueue_.shift(), !0); - } - } - a.loaded(); -}, goog.DebugLoader_.prototype.areDepsLoaded_ = function(a) { - for (var b = 0; b < a.length; b++) { - var c = this.getPathFromDeps_(a[b]); - if (!c || !(c in this.deferredCallbacks_ || goog.isProvided_(a[b]))) { - return !1; - } - } - return !0; -}, goog.DebugLoader_.prototype.getPathFromDeps_ = function(a) { - return a in this.idToPath_ ? this.idToPath_[a] : a in this.dependencies_ ? a : null; -}, goog.DebugLoader_.prototype.defer_ = function(a, b) { - this.deferredCallbacks_[a.path] = b; - this.deferredQueue_.push(a.path); -}, goog.LoadController = function() { -}, goog.LoadController.prototype.pause = function() { -}, goog.LoadController.prototype.resume = function() { -}, goog.LoadController.prototype.loaded = function() { -}, goog.LoadController.prototype.pending = function() { -}, goog.LoadController.prototype.registerEs6ModuleExports = function(a, b, c) { -}, goog.LoadController.prototype.setModuleState = function(a) { -}, goog.LoadController.prototype.clearModuleState = function() { -}, goog.LoadController.prototype.defer = function(a) { -}, goog.LoadController.prototype.areDepsLoaded = function() { -}, goog.Dependency = function(a, b, c, d, e) { - this.path = a; - this.relativePath = b; - this.provides = c; - this.requires = d; - this.loadFlags = e; - this.loaded_ = !1; - this.loadCallbacks_ = []; -}, goog.Dependency.prototype.getPathName = function() { - var a = this.path, b = a.indexOf("://"); - 0 <= b && (a = a.substring(b + 3), b = a.indexOf("/"), 0 <= b && (a = a.substring(b + 1))); - return a; -}, goog.Dependency.prototype.onLoad = function(a) { - this.loaded_ ? a() : this.loadCallbacks_.push(a); -}, goog.Dependency.prototype.loaded = function() { - this.loaded_ = !0; - var a = this.loadCallbacks_; - this.loadCallbacks_ = []; - for (var b = 0; b < a.length; b++) { - a[b](); - } -}, goog.Dependency.defer_ = !1, goog.Dependency.callbackMap_ = {}, goog.Dependency.registerCallback_ = function(a) { - var b = Math.random().toString(32); - goog.Dependency.callbackMap_[b] = a; - return b; -}, goog.Dependency.unregisterCallback_ = function(a) { - delete goog.Dependency.callbackMap_[a]; -}, goog.Dependency.callback_ = function(a, b) { - if (a in goog.Dependency.callbackMap_) { - for (var c = goog.Dependency.callbackMap_[a], d = [], e = 1; e < arguments.length; e++) { - d.push(arguments[e]); - } - c.apply(void 0, d); - } else { - throw Error("Callback key " + a + " does not exist (was base.js loaded more than once?)."); - } -}, goog.Dependency.prototype.load = function(a) { - if (goog.global.CLOSURE_IMPORT_SCRIPT) { - goog.global.CLOSURE_IMPORT_SCRIPT(this.path) ? a.loaded() : a.pause(); - } else { - if (goog.inHtmlDocument_()) { - var b = goog.global.document; - if ("complete" == b.readyState && !goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING) { - if (/\bdeps.js$/.test(this.path)) { - a.loaded(); - return; - } - throw Error('Cannot write "' + this.path + '" after document load'); - } - var c = goog.getScriptNonce_(); - if (!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING && goog.isDocumentLoading_()) { - var d = function(h) { - h.readyState && "complete" != h.readyState ? h.onload = d : (goog.Dependency.unregisterCallback_(e), a.loaded()); - }; - var e = goog.Dependency.registerCallback_(d); - c = c ? ' nonce="' + c + '"' : ""; - var f = '