diff --git a/.eslintignore b/.eslintignore index 0d60b8df106..0022114ea33 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,6 +8,7 @@ gulpfile.js /tests/compile/* /tests/jsunit/* /tests/generators/* +/tests/mocha/run_mocha_tests_in_browser.js /tests/test_runner.js /tests/workspace_svg/* /generators/* diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index f0bd0b7625e..00000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,73 +0,0 @@ - - -### Problem statement - - - -### Expected Behavior - - - -### Actual Behavior - - - -### Steps to Reproduce - - - -1. Start by.. -2. Next, do.. - -### Stack Traces - - - -``` -Replace with error stack trace. -``` - -### Operating System and Browser - - - - - - - - - - - - - -### Additional Information - - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..9119a01724a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,64 @@ + +--- +name: Bug report +about: Create a report to help us improve +labels: 'type: bug, triage' +assignees: '' + +--- + +**Describe the bug** + + + +**To Reproduce** + + +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** + + + +**Screenshots** + + + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Stack Traces** + + + +``` +Replace with error stack trace. +``` + +**Additional context** + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000000..5b85b635c6e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project +labels: 'type: feature request, triage' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** + + + +**Describe the solution you'd like** + + + +**Describe alternatives you've considered** + + + +**Additional context** + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c828f584208..211fff419a3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -48,6 +48,12 @@ Tested on: * Version [e.g. 22] --> +### Documentation + + + ### Additional Information diff --git a/.travis.yml b/.travis.yml index d65b14554c1..bc0bb84157b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ node_js: - 8 - 10 addons: + firefox: latest apt: packages: - google-chrome-stable diff --git a/README.md b/README.md index 457fb810f72..a7d11b41cc1 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,46 @@ blocks together to build programs. All code is free and open source. ![](https://developers.google.com/blockly/images/sample.png) -Blockly has an active [developer forum](https://groups.google.com/forum/#!forum/blockly). Please drop by and say hello. Show us your prototypes early; collectively we have a lot of experience and can offer hints which will save you time. +Blockly has an active [developer forum](https://groups.google.com/forum/#!forum/blockly). Please drop by and say hello. Show us your prototypes early; collectively we have a lot of experience and can offer hints which will save you time. We actively monitor the forums and typically respond to questions within 2 working days. Help us focus our development efforts by telling us [what you are doing with Blockly](https://developers.google.com/blockly/registration). The questionnaire only takes a few minutes and will help us better support the Blockly community. +Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com) + Want to contribute? Great! First, read [our guidelines for contributors](https://developers.google.com/blockly/guides/modify/contributing). + +## Releases + +We release by pushing the latest code to the master branch, followed by updating our [docs](developers.google.com/blockly) and [demo pages](https://blockly-demo.appspot.com). We typically release a new version of Blockly once a quarter (every 3 months). If there are breaking bugs, such as a crash when performing a standard action or a rendering issue that makes Blockly unusable, we will cherry-pick fixes to master between releases to fix them. The [releases page](https://github.com/google/blockly/releases) has a list of all releases. + +Releases are tagged by the release date (YYYYMMDD) with a leading '1.' and a trailing '.0' in case we ever need a major or minor version (such as [1.20190419.0](https://github.com/google/blockly/tree/1.20190419.0)). If you're using npm, a specific release can be installed by using its tag: `npm install git://github.com/google/blockly.git#1.20181219.0` + +### New APIs + +Once a new API is merged into master it is considered beta until the following release. We generally try to avoid changing an API after it has been merged to master, but sometimes we need to make changes after seeing how an API is used. If an API has been around for at least two releases we'll do our best to avoid breaking it. + +Unreleased APIs may change radically. Anything that is in `develop` but not `master` is subject to change without warning. + +### Branches + +There are two main branches for Blockly. + +**[master](https://github.com/google/blockly)** - This is the (mostly) stable current release of Blockly. + +**[develop](https://github.com/google/blockly/tree/develop)** - This is where most of our work happens. Pull requests should always be made against develop. This branch will generally be usable, but may be less stable than the master branch. Once something is in develop we expect it to merge to master in the next release. + +**other branches:** - Larger changes may have their own branches until they are good enough for people to try out. These will be developed separately until we think they are almost ready for release. These branches typically get merged into develop immediately after a release to allow extra time for testing. + +## Issues and Milestones + +We typically triage all bugs within 2 working days, which includes adding any appropriate labels and assigning it to a milestone. Please keep in mind, we are a small team so even feature reqeusts that everyone agrees on may not be prioritized. + +### Milestones + +**Upcoming release** - The upcoming release milestone is for all bugs we plan on fixing before the next release. This typically has the form of `year_quarter_release` (such as `2019_q2_release`). Some bugs will be added to this release when they are triaged, others may be added closer to a release. + +**Bug Bash Backlog** - These are bugs that we're still prioritizing. They haven't been added to a specific release yet, but we'll consider them for each release depending on relative priority and available time. + +**Icebox** - These are bugs that we do not intend to spend time on. They are either too much work or minor enough that we don't expect them to ever take priority. We are still happy to accept pull requests for these bugs. diff --git a/accessible/README.md b/accessible/README.md deleted file mode 100644 index a69fa6667cf..00000000000 --- a/accessible/README.md +++ /dev/null @@ -1,54 +0,0 @@ -Accessible Blockly -================== - -Google's Blockly is a web-based, visual programming editor that is accessible -to blind users. - -The code in this directory renders a version of the Blockly toolbox and -workspace that is fully keyboard-navigable, and compatible with most screen -readers. It is optimized for NVDA on Firefox. - -In the future, Accessible Blockly may be modified to suit accessibility needs -other than visual impairments. Note that deaf users are expected to continue -using Blockly over Accessible Blockly. - - -Using Accessible Blockly in Your Web App ----------------------------------------- -The demo at blockly/demos/accessible covers the absolute minimum required to -import Accessible Blockly into your web app. You will need to import the files -in the same order as in the demo: utils.service.js will need to be the first -Angular file imported. - -When the DOMContentLoaded event fires, call ng.platform.browser.bootstrap() on -the main component to be loaded. This will usually be blocklyApp.AppComponent, -but if you have another component that wraps it, use that one instead. - - -Customizing the Sidebar and Audio ---------------------------------- -The Accessible Blockly workspace comes with a customizable sidebar. - -To customize the sidebar, you will need to declare an ACCESSIBLE_GLOBALS object -in the global scope that looks like this: - - var ACCESSIBLE_GLOBALS = { - mediaPathPrefix: null, - customSidebarButtons: [] - }; - -The value of mediaPathPrefix should be the location of the accessible/media -folder. - -The value of 'customSidebarButtons' should be a list of objects, each -representing buttons on the sidebar. Each of these objects should have the -following keys: - - 'text' (the text to display on the button) - - 'action' (the function that gets run when the button is clicked) - - 'id' (optional; the id of the button) - - -Limitations ------------ -- We do not support having multiple Accessible Blockly apps in a single webpage. -- Accessible Blockly does not support the use of shadow blocks. diff --git a/accessible/app.component.js b/accessible/app.component.js deleted file mode 100644 index c31fd4259bb..00000000000 --- a/accessible/app.component.js +++ /dev/null @@ -1,109 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Top-level component for the Accessible Blockly application. - * @author madeeha@google.com (Madeeha Ghori) - */ - -goog.provide('blocklyApp.AppComponent'); - -goog.require('Blockly'); - -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.BlockConnectionService'); -goog.require('blocklyApp.BlockOptionsModalComponent'); -goog.require('blocklyApp.BlockOptionsModalService'); -goog.require('blocklyApp.KeyboardInputService'); -goog.require('blocklyApp.NotificationsService'); -goog.require('blocklyApp.SidebarComponent'); -goog.require('blocklyApp.ToolboxModalComponent'); -goog.require('blocklyApp.ToolboxModalService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.TreeService'); -goog.require('blocklyApp.UtilsService'); -goog.require('blocklyApp.VariableAddModalComponent'); -goog.require('blocklyApp.VariableModalService'); -goog.require('blocklyApp.VariableRenameModalComponent'); -goog.require('blocklyApp.VariableRemoveModalComponent'); -goog.require('blocklyApp.WorkspaceComponent'); - - -blocklyApp.workspace = new Blockly.Workspace(); - -blocklyApp.AppComponent = ng.core.Component({ - selector: 'blockly-app', - template: ` - - - -
- {{getAriaLiveReadout()}} -
- - - - - - - - - - `, - directives: [ - blocklyApp.BlockOptionsModalComponent, - blocklyApp.SidebarComponent, - blocklyApp.ToolboxModalComponent, - blocklyApp.VariableAddModalComponent, - blocklyApp.VariableRenameModalComponent, - blocklyApp.VariableRemoveModalComponent, - blocklyApp.WorkspaceComponent - ], - pipes: [blocklyApp.TranslatePipe], - // All services are declared here, so that all components in the application - // use the same instance of the service. - // https://www.sitepoint.com/angular-2-components-providers-classes-factories-values/ - providers: [ - blocklyApp.AudioService, - blocklyApp.BlockConnectionService, - blocklyApp.BlockOptionsModalService, - blocklyApp.KeyboardInputService, - blocklyApp.NotificationsService, - blocklyApp.ToolboxModalService, - blocklyApp.TreeService, - blocklyApp.UtilsService, - blocklyApp.VariableModalService - ] -}) -.Class({ - constructor: [ - blocklyApp.NotificationsService, function(notificationsService) { - this.notificationsService = notificationsService; - } - ], - getAriaLiveReadout: function() { - return this.notificationsService.getDisplayedMessage(); - } -}); diff --git a/accessible/audio.service.js b/accessible/audio.service.js deleted file mode 100644 index 4f7eb4f0866..00000000000 --- a/accessible/audio.service.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service for playing audio files. - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.AudioService'); - -goog.require('blocklyApp.NotificationsService'); - - -blocklyApp.AudioService = ng.core.Class({ - constructor: [ - blocklyApp.NotificationsService, function(notificationsService) { - this.notificationsService = notificationsService; - - // We do not play any audio unless a media path prefix is specified. - this.canPlayAudio = false; - - if (ACCESSIBLE_GLOBALS.hasOwnProperty('mediaPathPrefix')) { - this.canPlayAudio = true; - var mediaPathPrefix = ACCESSIBLE_GLOBALS['mediaPathPrefix']; - this.AUDIO_PATHS_ = { - 'connect': mediaPathPrefix + 'click.mp3', - 'delete': mediaPathPrefix + 'delete.mp3', - 'oops': mediaPathPrefix + 'oops.mp3' - }; - } - - this.cachedAudioFiles_ = {}; - // Store callback references here so that they can be removed if a new - // call to this.play_() comes in. - this.onEndedCallbacks_ = { - 'connect': [], - 'delete': [], - 'oops': [] - }; - } - ], - play_: function(audioId, onEndedCallback) { - if (this.canPlayAudio) { - if (!this.cachedAudioFiles_.hasOwnProperty(audioId)) { - this.cachedAudioFiles_[audioId] = new Audio(this.AUDIO_PATHS_[audioId]); - } - - if (onEndedCallback) { - this.onEndedCallbacks_[audioId].push(onEndedCallback); - this.cachedAudioFiles_[audioId].addEventListener( - 'ended', onEndedCallback); - } else { - var that = this; - this.onEndedCallbacks_[audioId].forEach(function(callback) { - that.cachedAudioFiles_[audioId].removeEventListener( - 'ended', callback); - }); - this.onEndedCallbacks_[audioId].length = 0; - } - - this.cachedAudioFiles_[audioId].play(); - } - }, - playConnectSound: function() { - this.play_('connect'); - }, - playDeleteSound: function() { - this.play_('delete'); - }, - playOopsSound: function(optionalStatusMessage) { - if (optionalStatusMessage) { - var that = this; - this.play_('oops', function() { - that.notificationsService.speak(optionalStatusMessage); - }); - } else { - this.play_('oops'); - } - } -}); diff --git a/accessible/block-connection.service.js b/accessible/block-connection.service.js deleted file mode 100644 index d2c5cd8665a..00000000000 --- a/accessible/block-connection.service.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service for handling the mechanics of how blocks - * get connected to each other. - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.BlockConnectionService'); - -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.NotificationsService'); - - -blocklyApp.BlockConnectionService = ng.core.Class({ - constructor: [ - blocklyApp.NotificationsService, blocklyApp.AudioService, - function(_notificationsService, _audioService) { - this.notificationsService = _notificationsService; - this.audioService = _audioService; - - // When a user "adds a link" to a block, the connection representing this - // link is stored here. - this.markedConnection_ = null; - }], - findCompatibleConnection_: function(block, targetConnection) { - // Locates and returns a connection on the given block that is compatible - // with the target connection, if one exists. Returns null if no such - // connection exists. - // Note: the targetConnection is assumed to be the markedConnection_, or - // possibly its counterpart (in the case where the marked connection is - // currently attached to another connection). This method therefore ignores - // input connections on the given block, since one doesn't usually mark an - // output connection and attach a block to it. - if (!targetConnection || !targetConnection.getSourceBlock().workspace) { - return null; - } - - var desiredType = Blockly.OPPOSITE_TYPE[targetConnection.type]; - var potentialConnection = ( - desiredType == Blockly.OUTPUT_VALUE ? block.outputConnection : - desiredType == Blockly.PREVIOUS_STATEMENT ? block.previousConnection : - desiredType == Blockly.NEXT_STATEMENT ? block.nextConnection : - null); - - if (potentialConnection && - potentialConnection.checkType_(targetConnection)) { - return potentialConnection; - } else { - return null; - } - }, - isAnyConnectionMarked: function() { - return Boolean(this.markedConnection_); - }, - getMarkedConnectionSourceBlock: function() { - return this.markedConnection_ ? - this.markedConnection_.getSourceBlock() : null; - }, - canBeAttachedToMarkedConnection: function(block) { - return Boolean( - this.findCompatibleConnection_(block, this.markedConnection_)); - }, - canBeMovedToMarkedConnection: function(block) { - if (!this.markedConnection_) { - return false; - } - - // It should not be possible to move any ancestor of the block containing - // the marked connection to the marked connection. - var ancestorBlock = this.getMarkedConnectionSourceBlock(); - while (ancestorBlock) { - if (ancestorBlock.id == block.id) { - return false; - } - ancestorBlock = ancestorBlock.getParent(); - } - - return this.canBeAttachedToMarkedConnection(block); - }, - markConnection: function(connection) { - this.markedConnection_ = connection; - this.notificationsService.speak(Blockly.Msg.ADDED_LINK_MSG); - }, - attachToMarkedConnection: function(block) { - var xml = Blockly.Xml.blockToDom(block); - var reconstitutedBlock = Blockly.Xml.domToBlock(xml, blocklyApp.workspace); - - var targetConnection = null; - if (this.markedConnection_.targetBlock() && - this.markedConnection_.type == Blockly.PREVIOUS_STATEMENT) { - // Is the marked connection a 'previous' connection that is already - // connected? If so, find the block that's currently connected to it, and - // use that block's 'next' connection as the new marked connection. - // Otherwise, splicing does not happen correctly, and inserting a block - // in the middle of a group of two linked blocks will split the group. - targetConnection = this.markedConnection_.targetConnection; - } else { - targetConnection = this.markedConnection_; - } - - var connection = this.findCompatibleConnection_( - reconstitutedBlock, targetConnection); - if (connection) { - targetConnection.connect(connection); - - this.markedConnection_ = null; - this.audioService.playConnectSound(); - return reconstitutedBlock.id; - } else { - // We throw an error here, because we expect any UI controls that would - // result in a non-connection to be disabled or hidden. - throw Error( - 'Unable to connect block to marked connection. This should not ' + - 'happen.'); - } - } -}); diff --git a/accessible/block-options-modal.component.js b/accessible/block-options-modal.component.js deleted file mode 100644 index 6ac7975b5de..00000000000 --- a/accessible/block-options-modal.component.js +++ /dev/null @@ -1,146 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Component that represents the block options modal. - * - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.BlockOptionsModalComponent'); - -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.BlockOptionsModalService'); -goog.require('blocklyApp.KeyboardInputService'); -goog.require('blocklyApp.TranslatePipe'); - -goog.require('Blockly.CommonModal'); - - -blocklyApp.BlockOptionsModalComponent = ng.core.Component({ - selector: 'blockly-block-options-modal', - template: ` -
- -
-

{{'BLOCK_OPTIONS'|translate}}

-
-
- -
-
- -
- -
-
-
- `, - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.BlockOptionsModalService, blocklyApp.KeyboardInputService, - blocklyApp.AudioService, - function(blockOptionsModalService_, keyboardInputService_, audioService_) { - this.blockOptionsModalService = blockOptionsModalService_; - this.keyboardInputService = keyboardInputService_; - this.audioService = audioService_; - - this.modalIsVisible = false; - this.actionButtonsInfo = []; - this.activeButtonIndex = -1; - this.onDismissCallback = null; - - var that = this; - this.blockOptionsModalService.registerPreShowHook( - function(newActionButtonsInfo, onDismissCallback) { - that.modalIsVisible = true; - that.actionButtonsInfo = newActionButtonsInfo; - that.activeActionButtonIndex = -1; - that.onDismissCallback = onDismissCallback; - - Blockly.CommonModal.setupKeyboardOverrides(that); - that.keyboardInputService.addOverride('13', function(evt) { - evt.preventDefault(); - evt.stopPropagation(); - - if (that.activeButtonIndex == -1) { - return; - } - - var button = document.getElementById( - that.getOptionId(that.activeButtonIndex)); - if (that.activeButtonIndex < - that.actionButtonsInfo.length) { - that.actionButtonsInfo[that.activeButtonIndex].action(); - } else { - that.dismissModal(); - } - - that.hideModal(); - }); - - setTimeout(function() { - document.getElementById('blockOptionsModal').focus(); - }, 150); - } - ); - } - ], - focusOnOption: function(index) { - var button = document.getElementById(this.getOptionId(index)); - button.focus(); - }, - // Counts the number of interactive elements for the modal. - numInteractiveElements: function() { - return this.actionButtonsInfo.length + 1; - }, - // Returns the ID for the corresponding option button. - getOptionId: function(index) { - return 'block-options-modal-option-' + index; - }, - // Returns the ID for the "cancel" option button. - getCancelOptionId: function() { - return this.getOptionId(this.actionButtonsInfo.length); - }, - dismissModal: function() { - this.onDismissCallback(); - this.hideModal(); - }, - // Closes the modal. - hideModal: function() { - this.modalIsVisible = false; - this.keyboardInputService.clearOverride(); - this.blockOptionsModalService.hideModal(); - } -}); diff --git a/accessible/block-options-modal.service.js b/accessible/block-options-modal.service.js deleted file mode 100644 index ad775c6d47c..00000000000 --- a/accessible/block-options-modal.service.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service for the block options modal. - * - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.BlockOptionsModalService'); - - -blocklyApp.BlockOptionsModalService = ng.core.Class({ - constructor: [function() { - this.actionButtonsInfo = []; - // The aim of the pre-show hook is to populate the modal component with the - // information it needs to display the modal (e.g., which action buttons to - // display). - this.preShowHook = function() { - throw Error( - 'A pre-show hook must be defined for the block options modal ' + - 'before it can be shown.'); - }; - this.modalIsShown = false; - this.onDismissCallback = null; - }], - registerPreShowHook: function(preShowHook) { - var that = this; - this.preShowHook = function() { - preShowHook(that.actionButtonsInfo, that.onDismissCallback); - }; - }, - isModalShown: function() { - return this.modalIsShown; - }, - showModal: function(actionButtonsInfo, onDismissCallback) { - this.actionButtonsInfo = actionButtonsInfo; - this.onDismissCallback = onDismissCallback; - - this.preShowHook(); - this.modalIsShown = true; - }, - hideModal: function() { - this.modalIsShown = false; - } -}); diff --git a/accessible/commonModal.js b/accessible/commonModal.js deleted file mode 100644 index 57e88b529ee..00000000000 --- a/accessible/commonModal.js +++ /dev/null @@ -1,77 +0,0 @@ -goog.provide('Blockly.CommonModal'); - - -Blockly.CommonModal = function() {}; - -Blockly.CommonModal.setupKeyboardOverrides = function(component) { - component.keyboardInputService.setOverride({ - // Tab key: navigates to the previous or next item in the list. - '9': function(evt) { - evt.preventDefault(); - evt.stopPropagation(); - - if (evt.shiftKey) { - // Move to the previous item in the list. - if (component.activeButtonIndex <= 0) { - component.activeActionButtonIndex = 0; - component.audioService.playOopsSound(); - } else { - component.activeButtonIndex--; - } - } else { - // Move to the next item in the list. - if (component.activeButtonIndex == component.numInteractiveElements(component) - 1) { - component.audioService.playOopsSound(); - } else { - component.activeButtonIndex++; - } - } - - component.focusOnOption(component.activeButtonIndex, component); - }, - // Escape key: closes the modal. - '27': function() { - component.dismissModal(); - }, - // Up key: no-op. - '38': function(evt) { - evt.preventDefault(); - }, - // Down key: no-op. - '40': function(evt) { - evt.preventDefault(); - } - }); -} - -Blockly.CommonModal.getInteractiveElements = function(component) { - return Array.prototype.filter.call( - component.getInteractiveContainer().elements, function(element) { - if (element.type === 'hidden') { - return false; - } - if (element.disabled) { - return false; - } - if (element.tabIndex < 0) { - return false; - } - return true; - }); -}; - -Blockly.CommonModal.numInteractiveElements = function(component) { - var elements = this.getInteractiveElements(component); - return elements.length; -}; - -Blockly.CommonModal.focusOnOption = function(index, component) { - var elements = this.getInteractiveElements(component); - var button = elements[index]; - button.focus(); -}; - -Blockly.CommonModal.hideModal = function() { - this.modalIsVisible = false; - this.keyboardInputService.clearOverride(); -}; \ No newline at end of file diff --git a/accessible/field-segment.component.js b/accessible/field-segment.component.js deleted file mode 100644 index c68afb455b2..00000000000 --- a/accessible/field-segment.component.js +++ /dev/null @@ -1,206 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Component that renders a "field segment" (a group - * of non-editable Blockly.Field followed by 0 or 1 editable Blockly.Field) - * in a block. Also handles any interactions with the field. - * @author madeeha@google.com (Madeeha Ghori) - */ - -goog.provide('blocklyApp.FieldSegmentComponent'); - -goog.require('blocklyApp.NotificationsService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.VariableModalService'); - - -blocklyApp.FieldSegmentComponent = ng.core.Component({ - selector: 'blockly-field-segment', - template: ` - - - - `, - inputs: ['prefixFields', 'mainField', 'mainFieldId', 'level'], - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.NotificationsService, - blocklyApp.VariableModalService, - function(notificationsService, variableModalService) { - this.notificationsService = notificationsService; - this.variableModalService = variableModalService; - this.dropdownOptions = []; - this.rawOptions = []; - }], - // Angular2 hook - called after initialization. - ngAfterContentInit: function() { - if (this.mainField) { - this.mainField.initModel(); - } - }, - // Angular2 hook - called to check if the cached component needs an update. - ngDoCheck: function() { - if (this.isDropdown() && this.shouldBreakCache()) { - this.optionValue = this.mainField.getValue(); - this.fieldValue = this.mainField.getValue(); - this.rawOptions = this.mainField.getOptions(); - this.dropdownOptions = this.rawOptions.map(function(valueAndText) { - return { - text: valueAndText[0], - value: valueAndText[1] - }; - }); - - // Set the currently selected value to the variable on the field. - for (var i = 0; i < this.dropdownOptions.length; i++) { - if (this.dropdownOptions[i].text === this.fieldValue) { - this.selectedOption = this.dropdownOptions[i].value; - } - } - } - }, - // Returns whether the mutable, cached information needs to be refreshed. - shouldBreakCache: function() { - var newOptions = this.mainField.getOptions(); - if (newOptions.length != this.rawOptions.length) { - return true; - } - - for (var i = 0; i < this.rawOptions.length; i++) { - // Compare the value of the cached options with the values in the field. - if (newOptions[i][0] != this.rawOptions[i][0]) { - return true; - } - } - - if (this.fieldValue != this.mainField.getValue()) { - return true; - } - - return false; - }, - // Gets the prefix text, to be printed before a field. - getPrefixText: function() { - var prefixTexts = this.prefixFields.map(function(prefixField) { - return prefixField.getText(); - }); - return prefixTexts.join(' '); - }, - // Gets the description, for labeling a field. - getFieldDescription: function() { - var description = this.mainField.getText(); - if (this.prefixFields.length > 0) { - description = this.getPrefixText() + ': ' + description; - } - return description; - }, - // Returns true if the field is text input, false otherwise. - isTextInput: function() { - return this.mainField instanceof Blockly.FieldTextInput && - !(this.mainField instanceof Blockly.FieldNumber); - }, - // Returns true if the field is number input, false otherwise. - isNumberInput: function() { - return this.mainField instanceof Blockly.FieldNumber; - }, - // Returns true if the field is a dropdown, false otherwise. - isDropdown: function() { - return this.mainField instanceof Blockly.FieldDropdown; - }, - // Sets the text value on the underlying field. - setTextValue: function(newValue) { - this.mainField.setValue(newValue); - }, - // Sets the number value on the underlying field. - setNumberValue: function(newValue) { - // Do not permit a residual value of NaN after a backspace event. - this.mainField.setValue(newValue || 0); - }, - // Confirm a selection for dropdown fields. - selectOption: function() { - if (this.optionValue != Blockly.RENAME_VARIABLE_ID && this.optionValue != - Blockly.DELETE_VARIABLE_ID) { - this.mainField.setValue(this.optionValue); - } - - if (this.optionValue == Blockly.RENAME_VARIABLE_ID) { - this.variableModalService.showRenameModal_(this.mainField.getValue()); - } - - if (this.optionValue == Blockly.DELETE_VARIABLE_ID) { - this.variableModalService.showRemoveModal_(this.mainField.getValue()); - } - }, - // Sets the value on a dropdown input. - setDropdownValue: function(optionValue) { - this.optionValue = optionValue; - if (this.optionValue == 'NO_ACTION') { - return; - } - - var optionText = undefined; - for (var i = 0; i < this.dropdownOptions.length; i++) { - if (this.dropdownOptions[i].value == optionValue) { - optionText = this.dropdownOptions[i].text; - break; - } - } - - if (!optionText) { - throw Error( - 'There is no option text corresponding to the value: ' + - this.optionValue); - } - - this.notificationsService.speak('Selected option ' + optionText); - } -}); diff --git a/accessible/keyboard-input.service.js b/accessible/keyboard-input.service.js deleted file mode 100644 index 63827563719..00000000000 --- a/accessible/keyboard-input.service.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service for handling keyboard input. - * - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.KeyboardInputService'); - - -blocklyApp.KeyboardInputService = ng.core.Class({ - constructor: [function() { - // Default custom actions for global keystrokes. The keys of this object - // are string representations of the key codes. - this.keysToActions = {}; - // Override for the default keysToActions mapping (e.g. in a modal - // context). - this.keysToActionsOverride = null; - - // Attach a keydown handler to the entire window. - var that = this; - document.addEventListener('keydown', function(evt) { - var stringifiedKeycode = String(evt.keyCode); - var actionsObject = that.keysToActionsOverride || that.keysToActions; - - if (actionsObject.hasOwnProperty(stringifiedKeycode)) { - actionsObject[stringifiedKeycode](evt); - } - }); - }], - setOverride: function(newKeysToActions) { - this.keysToActionsOverride = newKeysToActions; - }, - addOverride: function(keyCode, action) { - this.keysToActionsOverride[keyCode] = action; - }, - clearOverride: function() { - this.keysToActionsOverride = null; - } -}); diff --git a/accessible/libs/README b/accessible/libs/README deleted file mode 100644 index ebf4d96ba7c..00000000000 --- a/accessible/libs/README +++ /dev/null @@ -1,15 +0,0 @@ -This folder contains the following dependencies for accessible Blockly: - -* Angular2 (angular2-all.umd.min.js, angular2-polyfills.min.js) -* RxJava (Rx.umd.min) - -Used for data binding between the core Blockly workspace and accessible Blockly. -RxJava is required by Angular2. -Fetched from https://code.angularjs.org/ -The current version is 2.0.0-beta.16. - -* ES6 Shim - -Required by Angular2, for Javascript files. -Fetched from https://github.com/paulmillr/es6-shim -The current version is 0.35.1. diff --git a/accessible/libs/Rx.umd.min.js b/accessible/libs/Rx.umd.min.js deleted file mode 100644 index 38c0666b4b3..00000000000 --- a/accessible/libs/Rx.umd.min.js +++ /dev/null @@ -1,748 +0,0 @@ -/** - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2015-2016 Netflix, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -**/ -/** - @license - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2015-2016 Netflix, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - **/ -(function(w){"object"===typeof exports&&"undefined"!==typeof module?module.exports=w():"function"===typeof define&&define.amd?define([],w):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).Rx=w()})(function(){return function a(b,f,g){function k(e,d){if(!f[e]){if(!b[e]){var c="function"==typeof require&&require;if(!d&&c)return c(e,!0);if(l)return l(e,!0);c=Error("Cannot find module '"+e+"'");throw c.code="MODULE_NOT_FOUND",c;}c=f[e]={exports:{}}; -b[e][0].call(c.exports,function(a){var c=b[e][1][a];return k(c?c:a)},c,c.exports,a,b,f,g)}return f[e].exports}for(var l="function"==typeof require&&require,h=0;h=n?h.complete():(c=b?b(c[e],e):c[e],h.next(c),a.index=e+1,this.schedule(a)))};e.prototype._subscribe=function(a){var c=this.arrayLike,m=this.mapFn, -n=this.scheduler,b=c.length;if(n)return n.schedule(e.dispatch,0,{arrayLike:c,index:0,length:b,mapFn:m,subscriber:a});for(n=0;n=a.count?b.complete():(b.next(d[e]),b.isUnsubscribed||(a.index=e+1,this.schedule(a)))};d.prototype._subscribe=function(a){var e=this.array,n=e.length,b=this.scheduler;if(b)return b.schedule(d.dispatch,0,{array:e,index:0,count:n,subscriber:a});for(b=0;bd)this.period=0;c&&"function"===typeof c.schedule||(this.scheduler=l.asap)}g(e,a);e.create=function(a,c){void 0===a&&(a=0);void 0===c&&(c=l.asap);return new e(a,c)};e.dispatch=function(a){var c=a.subscriber,e=a.period;c.next(a.index);c.isUnsubscribed||(a.index+=1,this.schedule(a,e))};e.prototype._subscribe=function(a){var c=this.period;a.add(this.scheduler.schedule(e.dispatch,c,{index:0,subscriber:a,period:c}))};return e}(b.Observable);f.IntervalObservable=a},{"../Observable":3,"../scheduler/asap":224, -"../util/isNumeric":243}],128:[function(a,b,f){var g=this&&this.__extends||function(a,c){function d(){this.constructor=a}for(var e in c)c.hasOwnProperty(e)&&(a[e]=c[e]);a.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)},k=a("../util/root"),l=a("../util/isObject"),h=a("../util/tryCatch");b=a("../Observable");var e=a("../util/isFunction"),d=a("../util/SymbolShim"),c=a("../util/errorObject");a=function(a){function b(c,h,f,q){a.call(this);if(null==c)throw Error("iterator cannot be null."); -if(l.isObject(h))this.thisArg=h,this.scheduler=f;else if(e.isFunction(h))this.project=h,this.thisArg=f,this.scheduler=q;else if(null!=h)throw Error("When provided, `project` must be a function.");if((h=c[d.SymbolShim.iterator])||"string"!==typeof c)if(h||void 0===c.length){if(!h)throw new TypeError("Object is not iterable");c=c[d.SymbolShim.iterator]()}else c=new n(c);else c=new m(c);this.iterator=c}g(b,a);b.create=function(a,c,d,e){return new b(a,c,d,e)};b.dispatch=function(a){var d=a.index,e=a.thisArg, -m=a.project,b=a.iterator,n=a.subscriber;a.hasError?n.error(a.error):(b=b.next(),b.done?n.complete():(m?(b=h.tryCatch(m).call(e,b.value,d),b===c.errorObject?(a.error=c.errorObject.e,a.hasError=!0):(n.next(b),a.index=d+1)):(n.next(b.value),a.index=d+1),n.isUnsubscribed||this.schedule(a)))};b.prototype._subscribe=function(a){var d=0,e=this.iterator,m=this.project,n=this.thisArg,f=this.scheduler;if(f)return f.schedule(b.dispatch,0,{index:d,thisArg:n,project:m,iterator:e,subscriber:a});do{f=e.next();if(f.done){a.complete(); -break}else if(m){f=h.tryCatch(m).call(n,f.value,d++);if(f===c.errorObject){a.error(c.errorObject.e);break}a.next(f)}else a.next(f.value);if(a.isUnsubscribed)break}while(1)};return b}(b.Observable);f.IteratorObservable=a;var m=function(){function a(c,d,e){void 0===d&&(d=0);void 0===e&&(e=c.length);this.str=c;this.idx=d;this.len=e}a.prototype[d.SymbolShim.iterator]=function(){return this};a.prototype.next=function(){return this.idxm?-1:1;e=m*Math.floor(Math.abs(e));e=0>=e?0:e>q?q:e}this.arr=c;this.idx=d;this.len=e}a.prototype[d.SymbolShim.iterator]=function(){return this};a.prototype.next=function(){return this.idx=a.end?c.complete():(c.next(e),c.isUnsubscribed||(a.index=d+1,a.start=e+1,this.schedule(a)))};b.prototype._subscribe=function(a){var e=0,d=this.start,c=this.end,m=this.scheduler;if(m)return m.schedule(b.dispatch, -0,{index:e,end:c,start:d,subscriber:a});do{if(e++>=c){a.complete();break}a.next(d++);if(a.isUnsubscribed)break}while(1)};return b}(a("../Observable").Observable);f.RangeObservable=a},{"../Observable":3}],132:[function(a,b,f){var g=this&&this.__extends||function(a,b){function h(){this.constructor=a}for(var e in b)b.hasOwnProperty(e)&&(a[e]=b[e]);a.prototype=null===b?Object.create(b):(h.prototype=b.prototype,new h)};a=function(a){function b(h,e){a.call(this);this.value=h;this.scheduler=e;this._isScalar= -!0}g(b,a);b.create=function(a,e){return new b(a,e)};b.dispatch=function(a){var e=a.value,d=a.subscriber;a.done?d.complete():(d.next(e),d.isUnsubscribed||(a.done=!0,this.schedule(a)))};b.prototype._subscribe=function(a){var e=this.value,d=this.scheduler;if(d)return d.schedule(b.dispatch,0,{done:!1,value:e,subscriber:a});a.next(e);a.isUnsubscribed||a.complete()};return b}(a("../Observable").Observable);f.ScalarObservable=a},{"../Observable":3}],133:[function(a,b,f){var g=this&&this.__extends||function(a, -e){function d(){this.constructor=a}for(var c in e)e.hasOwnProperty(c)&&(a[c]=e[c]);a.prototype=null===e?Object.create(e):(d.prototype=e.prototype,new d)};b=a("../Observable");var k=a("../scheduler/asap"),l=a("../util/isNumeric");a=function(a){function e(d,c,e){void 0===c&&(c=0);void 0===e&&(e=k.asap);a.call(this);this.source=d;this.delayTime=c;this.scheduler=e;if(!l.isNumeric(c)||0>c)this.delayTime=0;e&&"function"===typeof e.schedule||(this.scheduler=k.asap)}g(e,a);e.create=function(a,c,m){void 0=== -c&&(c=0);void 0===m&&(m=k.asap);return new e(a,c,m)};e.dispatch=function(a){return a.source.subscribe(a.subscriber)};e.prototype._subscribe=function(a){return this.scheduler.schedule(e.dispatch,this.delayTime,{source:this.source,subscriber:a})};return e}(b.Observable);f.SubscribeOnObservable=a},{"../Observable":3,"../scheduler/asap":224,"../util/isNumeric":243}],134:[function(a,b,f){var g=this&&this.__extends||function(a,c){function e(){this.constructor=a}for(var b in c)c.hasOwnProperty(b)&&(a[b]= -c[b]);a.prototype=null===c?Object.create(c):(e.prototype=c.prototype,new e)},k=a("../util/isNumeric");b=a("../Observable");var l=a("../scheduler/asap"),h=a("../util/isScheduler"),e=a("../util/isDate");a=function(a){function c(c,b,f){void 0===c&&(c=0);a.call(this);this.period=-1;this.dueTime=0;k.isNumeric(b)?this.period=1>+b&&1||+b:h.isScheduler(b)&&(f=b);h.isScheduler(f)||(f=l.asap);this.scheduler=f;this.dueTime=e.isDate(c)?+c-this.scheduler.now():c}g(c,a);c.create=function(a,d,e){void 0===a&&(a= -0);return new c(a,d,e)};c.dispatch=function(a){var c=a.index,d=a.period,e=a.subscriber;e.next(c);if(!e.isUnsubscribed){if(-1===d)return e.complete();a.index=c+1;this.schedule(a,d)}};c.prototype._subscribe=function(a){return this.scheduler.schedule(c.dispatch,this.dueTime,{index:0,period:this.period,subscriber:a})};return c}(b.Observable);f.TimerObservable=a},{"../Observable":3,"../scheduler/asap":224,"../util/isDate":241,"../util/isNumeric":243,"../util/isScheduler":246}],135:[function(a,b,f){var g= -this&&this.__extends||function(a,d){function c(){this.constructor=a}for(var b in d)d.hasOwnProperty(b)&&(a[b]=d[b]);a.prototype=null===d?Object.create(d):(c.prototype=d.prototype,new c)};b=a("../OuterSubscriber");var k=a("../util/subscribeToResult");f.buffer=function(a){return this.lift(new l(a))};var l=function(){function a(d){this.closingNotifier=d}a.prototype.call=function(a){return new h(a,this.closingNotifier)};return a}(),h=function(a){function d(c,d){a.call(this,c);this.buffer=[];this.add(k.subscribeToResult(this, -d))}g(d,a);d.prototype._next=function(a){this.buffer.push(a)};d.prototype.notifyNext=function(a,d,e,b,h){a=this.buffer;this.buffer=[];this.destination.next(a)};return d}(b.OuterSubscriber)},{"../OuterSubscriber":6,"../util/subscribeToResult":250}],136:[function(a,b,f){var g=this&&this.__extends||function(a,e){function d(){this.constructor=a}for(var c in e)e.hasOwnProperty(c)&&(a[c]=e[c]);a.prototype=null===e?Object.create(e):(d.prototype=e.prototype,new d)};a=a("../Subscriber");f.bufferCount=function(a, -e){void 0===e&&(e=null);return this.lift(new k(a,e))};var k=function(){function a(e,d){this.bufferSize=e;this.startBufferEvery=d}a.prototype.call=function(a){return new l(a,this.bufferSize,this.startBufferEvery)};return a}(),l=function(a){function e(d,c,e){a.call(this,d);this.bufferSize=c;this.startBufferEvery=e;this.buffers=[[]];this.count=0}g(e,a);e.prototype._next=function(a){var c=this.count+=1,e=this.destination,b=this.bufferSize,h=this.buffers,f=h.length,k=-1;0===c%(null==this.startBufferEvery? -b:this.startBufferEvery)&&h.push([]);for(c=0;c=d[0].time-e.now();)d.shift().notification.observe(b);0(d||0)?Number.POSITIVE_INFINITY:d;return this.lift(new e(a,d,b))};var e=function(){function a(c,d,e){this.project=c;this.concurrent=d;this.scheduler=e}a.prototype.call=function(a){return new d(a,this.project,this.concurrent,this.scheduler)};return a}();f.ExpandOperator=e;var d=function(a){function d(e,b,m,h){a.call(this, -e);this.project=b;this.concurrent=m;this.scheduler=h;this.active=this.index=0;this.hasCompleted=!1;ma?this.lift(new l(-1,this)):this.lift(new l(a-1,this))};var l=function(){function a(d,c){this.count=d;this.source=c}a.prototype.call=function(a){return new h(a, -this.count,this.source)};return a}(),h=function(a){function d(c,d,b){a.call(this,c);this.count=d;this.source=b}g(d,a);d.prototype.complete=function(){if(!this.isStopped){var c=this.source,d=this.count;if(0===d)return a.prototype.complete.call(this);-1this.total&&this.destination.next(a)};return b}(a.Subscriber)},{"../Subscriber":9}],194:[function(a,b,f){var g=this&&this.__extends||function(a,d){function c(){this.constructor=a}for(var b in d)d.hasOwnProperty(b)&&(a[b]=d[b]);a.prototype=null===d?Object.create(d):(c.prototype=d.prototype,new c)};b=a("../OuterSubscriber"); -var k=a("../util/subscribeToResult");f.skipUntil=function(a){return this.lift(new l(a))};var l=function(){function a(d){this.notifier=d}a.prototype.call=function(a){return new h(a,this.notifier)};return a}(),h=function(a){function d(c,d){a.call(this,c);this.isInnerStopped=this.hasValue=!1;this.add(k.subscribeToResult(this,d))}g(d,a);d.prototype._next=function(c){this.hasValue&&a.prototype._next.call(this,c)};d.prototype._complete=function(){this.isInnerStopped?a.prototype._complete.call(this):this.unsubscribe()}; -d.prototype.notifyNext=function(a,d,b,e,f){this.hasValue=!0};d.prototype.notifyComplete=function(){this.isInnerStopped=!0;this.isStopped&&a.prototype._complete.call(this)};return d}(b.OuterSubscriber)},{"../OuterSubscriber":6,"../util/subscribeToResult":250}],195:[function(a,b,f){var g=this&&this.__extends||function(a,b){function d(){this.constructor=a}for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);a.prototype=null===b?Object.create(b):(d.prototype=b.prototype,new d)};a=a("../Subscriber");f.skipWhile= -function(a){return this.lift(new k(a))};var k=function(){function a(b){this.predicate=b}a.prototype.call=function(a){return new l(a,this.predicate)};return a}(),l=function(a){function b(d,c){a.call(this,d);this.predicate=c;this.skipping=!0;this.index=0}g(b,a);b.prototype._next=function(a){var c=this.destination;this.skipping&&this.tryCallPredicate(a);this.skipping||c.next(a)};b.prototype.tryCallPredicate=function(a){try{this.skipping=!!this.predicate(a,this.index++)}catch(c){this.destination.error(c)}}; -return b}(a.Subscriber)},{"../Subscriber":9}],196:[function(a,b,f){var g=a("../observable/ArrayObservable"),k=a("../observable/ScalarObservable"),l=a("../observable/EmptyObservable"),h=a("./concat"),e=a("../util/isScheduler");f.startWith=function(){for(var a=[],c=0;cthis.total)throw new k.ArgumentOutOfRangeError;}a.prototype.call= -function(a){return new e(a,this.total)};return a}(),e=function(a){function c(c,b){a.call(this,c);this.total=b;this.count=0}g(c,a);c.prototype._next=function(a){var c=this.total;++this.count<=c&&(this.destination.next(a),this.count===c&&this.destination.complete())};return c}(b.Subscriber)},{"../Subscriber":9,"../observable/EmptyObservable":121,"../util/ArgumentOutOfRangeError":231}],202:[function(a,b,f){var g=this&&this.__extends||function(a,c){function b(){this.constructor=a}for(var e in c)c.hasOwnProperty(e)&& -(a[e]=c[e]);a.prototype=null===c?Object.create(c):(b.prototype=c.prototype,new b)};b=a("../Subscriber");var k=a("../util/ArgumentOutOfRangeError"),l=a("../observable/EmptyObservable");f.takeLast=function(a){return 0===a?new l.EmptyObservable:this.lift(new h(a))};var h=function(){function a(c){this.total=c;if(0>this.total)throw new k.ArgumentOutOfRangeError;}a.prototype.call=function(a){return new e(a,this.total)};return a}(),e=function(a){function c(c,b){a.call(this,c);this.total=b;this.index=this.count= -0;this.ring=Array(b)}g(c,a);c.prototype._next=function(a){var c=this.index,d=this.ring,b=this.total,e=this.count;1this.index};a.prototype.hasCompleted=function(){return this.array.length===this.index};return a}(),u=function(a){function b(c,d,e,f){a.call(this,c);this.parent=d;this.observable=e;this.index=f;this.stillUnsubscribed=!0;this.buffer=[];this.isComplete=!1}k(b,a);b.prototype[c.SymbolShim.iterator]=function(){return this};b.prototype.next= -function(){var a=this.buffer;return 0===a.length&&this.isComplete?{done:!0}:{value:a.shift(),done:!1}};b.prototype.hasValue=function(){return 0=b?this.scheduleNow(a,d):this.scheduleLater(a,b,d)};a.prototype.scheduleNow=function(a,b){return(new g.QueueAction(this,a)).schedule(b)};a.prototype.scheduleLater=function(a,b,d){return(new k.FutureAction(this,a)).schedule(d,b)};return a}(); -f.QueueScheduler=a},{"./FutureAction":221,"./QueueAction":222}],224:[function(a,b,f){a=a("./AsapScheduler");f.asap=new a.AsapScheduler},{"./AsapScheduler":220}],225:[function(a,b,f){a=a("./QueueScheduler");f.queue=new a.QueueScheduler},{"./QueueScheduler":223}],226:[function(a,b,f){var g=this&&this.__extends||function(a,b){function f(){this.constructor=a}for(var e in b)b.hasOwnProperty(e)&&(a[e]=b[e]);a.prototype=null===b?Object.create(b):(f.prototype=b.prototype,new f)};a=function(a){function b(){a.apply(this, -arguments);this.value=null;this.hasNext=!1}g(b,a);b.prototype._subscribe=function(b){this.hasCompleted&&this.hasNext&&b.next(this.value);return a.prototype._subscribe.call(this,b)};b.prototype._next=function(a){this.value=a;this.hasNext=!0};b.prototype._complete=function(){var a=-1,b=this.observers,d=b.length;this.isUnsubscribed=!0;if(this.hasNext)for(;++ac?1:c; -this._windowTime=1>d?1:d}g(b,a);b.prototype._next=function(b){var d=this._getNow();this.events.push(new h(d,b));this._trimBufferThenGetEvents(d);a.prototype._next.call(this,b)};b.prototype._subscribe=function(b){var d=this._trimBufferThenGetEvents(this._getNow()),f=this.scheduler;f&&b.add(b=new l.ObserveOnSubscriber(b,f));for(var f=-1,g=d.length;++fb&&(g=Math.max(g,f-b));0o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(5),a=n(6),u=n(7),c=function(t){function e(e){t.call(this),this.attributeName=e}return r(e,t),Object.defineProperty(e.prototype,"token",{get:function(){return this},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"@Attribute("+s.stringify(this.attributeName)+")"},e=i([s.CONST(),o("design:paramtypes",[String])],e)}(u.DependencyMetadata);e.AttributeMetadata=c;var p=function(t){function e(e,n){var r=void 0===n?{}:n,i=r.descendants,o=void 0===i?!1:i,s=r.first,a=void 0===s?!1:s,u=r.read,c=void 0===u?null:u;t.call(this),this._selector=e,this.descendants=o,this.first=a,this.read=c}return r(e,t),Object.defineProperty(e.prototype,"isViewQuery",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selector",{get:function(){return a.resolveForwardRef(this._selector)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVarBindingQuery",{get:function(){return s.isString(this.selector)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"varBindings",{get:function(){return this.selector.split(",")},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"@Query("+s.stringify(this.selector)+")"},e=i([s.CONST(),o("design:paramtypes",[Object,Object])],e)}(u.DependencyMetadata);e.QueryMetadata=p;var l=function(t){function e(e,n){var r=void 0===n?{}:n,i=r.descendants,o=void 0===i?!1:i,s=r.read,a=void 0===s?null:s;t.call(this,e,{descendants:o,read:a})}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object,Object])],e)}(p);e.ContentChildrenMetadata=l;var h=function(t){function e(e,n){var r=(void 0===n?{}:n).read,i=void 0===r?null:r;t.call(this,e,{descendants:!0,first:!0,read:i})}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object,Object])],e)}(p);e.ContentChildMetadata=h;var f=function(t){function e(e,n){var r=void 0===n?{}:n,i=r.descendants,o=void 0===i?!1:i,s=r.first,a=void 0===s?!1:s,u=r.read,c=void 0===u?null:u;t.call(this,e,{descendants:o,first:a,read:c})}return r(e,t),Object.defineProperty(e.prototype,"isViewQuery",{get:function(){return!0},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"@ViewQuery("+s.stringify(this.selector)+")"},e=i([s.CONST(),o("design:paramtypes",[Object,Object])],e)}(p);e.ViewQueryMetadata=f;var d=function(t){function e(e,n){var r=(void 0===n?{}:n).read,i=void 0===r?null:r;t.call(this,e,{descendants:!0,read:i})}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object,Object])],e)}(f);e.ViewChildrenMetadata=d;var v=function(t){function e(e,n){var r=(void 0===n?{}:n).read,i=void 0===r?null:r;t.call(this,e,{descendants:!0,first:!0,read:i})}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object,Object])],e)}(f);e.ViewChildMetadata=v},function(t,e){(function(t){"use strict";function n(t){Zone.current.scheduleMicroTask("scheduleMicrotask",t)}function r(t){return t.name?t.name:typeof t}function i(){H=!0}function o(){if(H)throw"Cannot enable prod mode after platform setup.";W=!1}function s(){return W}function a(t){return t}function u(){return function(t){return t}}function c(t){return void 0!==t&&null!==t}function p(t){return void 0===t||null===t}function l(t){return"boolean"==typeof t}function h(t){return"number"==typeof t}function f(t){return"string"==typeof t}function d(t){return"function"==typeof t}function v(t){return d(t)}function y(t){return"object"==typeof t&&null!==t}function m(t){return t instanceof U.Promise}function g(t){return Array.isArray(t)}function _(t){return t instanceof e.Date&&!isNaN(t.valueOf())}function b(){}function P(t){if("string"==typeof t)return t;if(void 0===t||null===t)return""+t;if(t.name)return t.name;if(t.overriddenName)return t.overriddenName;var e=t.toString(),n=e.indexOf("\n");return-1===n?e:e.substring(0,n)}function E(t){return t}function w(t,e){return t}function C(t,e){return t[e]}function R(t,e){return t===e||"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)}function S(t){return t}function O(t){return p(t)?null:t}function T(t){return p(t)?!1:t}function x(t){return null!==t&&("function"==typeof t||"object"==typeof t)}function A(t){console.log(t)}function I(t,e,n){for(var r=e.split("."),i=t;r.length>1;){var o=r.shift();i=i.hasOwnProperty(o)&&c(i[o])?i[o]:i[o]={}}(void 0===i||null===i)&&(i={}),i[r.shift()]=n}function M(){if(p(Y))if(c(Symbol)&&c(Symbol.iterator))Y=Symbol.iterator;else for(var t=Object.getOwnPropertyNames(Map.prototype),e=0;e=0&&t[r]==e;r--)n--;t=t.substring(0,n)}return t},t.replace=function(t,e,n){return t.replace(e,n)},t.replaceAll=function(t,e,n){return t.replace(e,n)},t.slice=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=null),t.slice(e,null===n?void 0:n)},t.replaceAllMapped=function(t,e,n){return t.replace(e,function(){for(var t=[],e=0;et?-1:t>e?1:0},t}();e.StringWrapper=X;var q=function(){function t(t){void 0===t&&(t=[]),this.parts=t}return t.prototype.add=function(t){this.parts.push(t)},t.prototype.toString=function(){return this.parts.join("")},t}();e.StringJoiner=q;var G=function(t){function e(e){t.call(this),this.message=e}return F(e,t),e.prototype.toString=function(){return this.message},e}(Error);e.NumberParseError=G;var z=function(){function t(){}return t.toFixed=function(t,e){return t.toFixed(e)},t.equal=function(t,e){return t===e},t.parseIntAutoRadix=function(t){var e=parseInt(t);if(isNaN(e))throw new G("Invalid integer literal when parsing "+t);return e},t.parseInt=function(t,e){if(10==e){if(/^(\-|\+)?[0-9]+$/.test(t))return parseInt(t,e)}else if(16==e){if(/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(t))return parseInt(t,e)}else{var n=parseInt(t,e);if(!isNaN(n))return n}throw new G("Invalid integer literal when parsing "+t+" in base "+e)},t.parseFloat=function(t){return parseFloat(t)},Object.defineProperty(t,"NaN",{get:function(){return NaN},enumerable:!0,configurable:!0}),t.isNaN=function(t){return isNaN(t)},t.isInteger=function(t){return Number.isInteger(t)},t}();e.NumberWrapper=z,e.RegExp=U.RegExp;var K=function(){function t(){}return t.create=function(t,e){return void 0===e&&(e=""),e=e.replace(/g/g,""),new U.RegExp(t,e+"g")},t.firstMatch=function(t,e){return t.lastIndex=0,t.exec(e)},t.test=function(t,e){return t.lastIndex=0,t.test(e)},t.matcher=function(t,e){return t.lastIndex=0,{re:t,input:e}},t.replaceAll=function(t,e,n){var r=t.exec(e),i="";t.lastIndex=0;for(var o=0;r;)i+=e.substring(o,r.index),i+=n(r),o=r.index+r[0].length,t.lastIndex=o,r=t.exec(e);return i+=e.substring(o)},t}();e.RegExpWrapper=K;var $=function(){function t(){}return t.next=function(t){return t.re.exec(t.input)},t}();e.RegExpMatcherWrapper=$;var Q=function(){function t(){}return t.apply=function(t,e){return t.apply(null,e)},t}();e.FunctionWrapper=Q,e.looseIdentical=R,e.getMapKey=S,e.normalizeBlank=O,e.normalizeBool=T,e.isJsObject=x,e.print=A;var J=function(){function t(){}return t.parse=function(t){return U.JSON.parse(t)},t.stringify=function(t){return U.JSON.stringify(t,null,2)},t}();e.Json=J;var Z=function(){function t(){}return t.create=function(t,n,r,i,o,s,a){return void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=0),new e.Date(t,n-1,r,i,o,s,a)},t.fromISOString=function(t){return new e.Date(t)},t.fromMillis=function(t){return new e.Date(t)},t.toMillis=function(t){return t.getTime()},t.now=function(){return new e.Date},t.toJson=function(t){return t.toJSON()},t}();e.DateWrapper=Z,e.setValueOnPath=I;var Y=null;e.getSymbolIterator=M,e.evalExpression=k,e.isPrimitive=N,e.hasConstructor=D,e.bitWiseOr=V,e.bitWiseAnd=j,e.escape=L}).call(e,function(){return this}())},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var i=n(7);e.InjectMetadata=i.InjectMetadata,e.OptionalMetadata=i.OptionalMetadata,e.InjectableMetadata=i.InjectableMetadata,e.SelfMetadata=i.SelfMetadata,e.HostMetadata=i.HostMetadata,e.SkipSelfMetadata=i.SkipSelfMetadata,e.DependencyMetadata=i.DependencyMetadata,r(n(8));var o=n(10);e.forwardRef=o.forwardRef,e.resolveForwardRef=o.resolveForwardRef;var s=n(11);e.Injector=s.Injector;var a=n(16);e.ReflectiveInjector=a.ReflectiveInjector;var u=n(24);e.Binding=u.Binding,e.ProviderBuilder=u.ProviderBuilder,e.bind=u.bind,e.Provider=u.Provider,e.provide=u.provide;var c=n(17);e.ResolvedReflectiveFactory=c.ResolvedReflectiveFactory,e.ReflectiveDependency=c.ReflectiveDependency;var p=n(22);e.ReflectiveKey=p.ReflectiveKey;var l=n(23);e.NoProviderError=l.NoProviderError,e.AbstractProviderError=l.AbstractProviderError,e.CyclicDependencyError=l.CyclicDependencyError,e.InstantiationError=l.InstantiationError,e.InvalidProviderError=l.InvalidProviderError,e.NoAnnotationError=l.NoAnnotationError,e.OutOfBoundsError=l.OutOfBoundsError;var h=n(25);e.OpaqueToken=h.OpaqueToken},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=function(){function t(t){this.token=t}return t.prototype.toString=function(){return"@Inject("+o.stringify(this.token)+")"},t=r([o.CONST(),i("design:paramtypes",[Object])],t)}();e.InjectMetadata=s;var a=function(){function t(){}return t.prototype.toString=function(){return"@Optional()"},t=r([o.CONST(),i("design:paramtypes",[])],t)}();e.OptionalMetadata=a;var u=function(){function t(){}return Object.defineProperty(t.prototype,"token",{get:function(){return null},enumerable:!0,configurable:!0}),t=r([o.CONST(),i("design:paramtypes",[])],t)}();e.DependencyMetadata=u;var c=function(){function t(){}return t=r([o.CONST(),i("design:paramtypes",[])],t)}();e.InjectableMetadata=c;var p=function(){function t(){}return t.prototype.toString=function(){return"@Self()"},t=r([o.CONST(),i("design:paramtypes",[])],t)}();e.SelfMetadata=p;var l=function(){function t(){}return t.prototype.toString=function(){return"@SkipSelf()"},t=r([o.CONST(),i("design:paramtypes",[])],t)}();e.SkipSelfMetadata=l;var h=function(){function t(){}return t.prototype.toString=function(){return"@Host()"},t=r([o.CONST(),i("design:paramtypes",[])],t)}();e.HostMetadata=h},function(t,e,n){"use strict";var r=n(7),i=n(9);e.Inject=i.makeParamDecorator(r.InjectMetadata),e.Optional=i.makeParamDecorator(r.OptionalMetadata),e.Injectable=i.makeDecorator(r.InjectableMetadata),e.Self=i.makeParamDecorator(r.SelfMetadata),e.Host=i.makeParamDecorator(r.HostMetadata),e.SkipSelf=i.makeParamDecorator(r.SkipSelfMetadata)},function(t,e,n){"use strict";function r(t){return c.isFunction(t)&&t.hasOwnProperty("annotation")&&(t=t.annotation),t}function i(t,e){if(t===Object||t===String||t===Function||t===Number||t===Array)throw new Error("Can not use native "+c.stringify(t)+" as constructor");if(c.isFunction(t))return t;if(t instanceof Array){var n=t,i=t[t.length-1];if(!c.isFunction(i))throw new Error("Last position of Class method array must be Function in key "+e+" was '"+c.stringify(i)+"'");var o=n.length-1;if(o!=i.length)throw new Error("Number of annotations ("+o+") does not match number of arguments ("+i.length+") in the function: "+c.stringify(i));for(var s=[],a=0,u=n.length-1;u>a;a++){var p=[];s.push(p);var h=n[a];if(h instanceof Array)for(var f=0;f-1?(t.splice(n,1),!0):!1},t.clear=function(t){t.length=0},t.isEmpty=function(t){return 0==t.length},t.fill=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=null),t.fill(e,n,null===r?t.length:r)},t.equals=function(t,e){if(t.length!=e.length)return!1;for(var n=0;nr&&(n=o,r=s)}}return n},t.flatten=function(t){var e=[];return r(t,e),e},t.addAll=function(t,e){for(var n=0;n0&&(this.provider0=e[0],this.keyId0=e[0].key.id),n>1&&(this.provider1=e[1],this.keyId1=e[1].key.id),n>2&&(this.provider2=e[2],this.keyId2=e[2].key.id),n>3&&(this.provider3=e[3],this.keyId3=e[3].key.id),n>4&&(this.provider4=e[4],this.keyId4=e[4].key.id),n>5&&(this.provider5=e[5],this.keyId5=e[5].key.id),n>6&&(this.provider6=e[6],this.keyId6=e[6].key.id),n>7&&(this.provider7=e[7],this.keyId7=e[7].key.id),n>8&&(this.provider8=e[8],this.keyId8=e[8].key.id),n>9&&(this.provider9=e[9],this.keyId9=e[9].key.id)}return t.prototype.getProviderAtIndex=function(t){if(0==t)return this.provider0;if(1==t)return this.provider1;if(2==t)return this.provider2;if(3==t)return this.provider3;if(4==t)return this.provider4;if(5==t)return this.provider5;if(6==t)return this.provider6;if(7==t)return this.provider7;if(8==t)return this.provider8;if(9==t)return this.provider9;throw new s.OutOfBoundsError(t)},t.prototype.createInjectorStrategy=function(t){return new m(t,this)},t}();e.ReflectiveProtoInjectorInlineStrategy=d;var v=function(){function t(t,e){this.providers=e;var n=e.length;this.keyIds=i.ListWrapper.createFixedSize(n);for(var r=0;n>r;r++)this.keyIds[r]=e[r].key.id}return t.prototype.getProviderAtIndex=function(t){if(0>t||t>=this.providers.length)throw new s.OutOfBoundsError(t);return this.providers[t]},t.prototype.createInjectorStrategy=function(t){return new g(this,t)},t}();e.ReflectiveProtoInjectorDynamicStrategy=v;var y=function(){function t(t){this.numberOfProviders=t.length,this._strategy=t.length>h?new v(this,t):new d(this,t)}return t.fromResolvedProviders=function(e){return new t(e)},t.prototype.getProviderAtIndex=function(t){return this._strategy.getProviderAtIndex(t); -},t}();e.ReflectiveProtoInjector=y;var m=function(){function t(t,e){this.injector=t,this.protoStrategy=e,this.obj0=f,this.obj1=f,this.obj2=f,this.obj3=f,this.obj4=f,this.obj5=f,this.obj6=f,this.obj7=f,this.obj8=f,this.obj9=f}return t.prototype.resetConstructionCounter=function(){this.injector._constructionCounter=0},t.prototype.instantiateProvider=function(t){return this.injector._new(t)},t.prototype.getObjByKeyId=function(t){var e=this.protoStrategy,n=this.injector;return e.keyId0===t?(this.obj0===f&&(this.obj0=n._new(e.provider0)),this.obj0):e.keyId1===t?(this.obj1===f&&(this.obj1=n._new(e.provider1)),this.obj1):e.keyId2===t?(this.obj2===f&&(this.obj2=n._new(e.provider2)),this.obj2):e.keyId3===t?(this.obj3===f&&(this.obj3=n._new(e.provider3)),this.obj3):e.keyId4===t?(this.obj4===f&&(this.obj4=n._new(e.provider4)),this.obj4):e.keyId5===t?(this.obj5===f&&(this.obj5=n._new(e.provider5)),this.obj5):e.keyId6===t?(this.obj6===f&&(this.obj6=n._new(e.provider6)),this.obj6):e.keyId7===t?(this.obj7===f&&(this.obj7=n._new(e.provider7)),this.obj7):e.keyId8===t?(this.obj8===f&&(this.obj8=n._new(e.provider8)),this.obj8):e.keyId9===t?(this.obj9===f&&(this.obj9=n._new(e.provider9)),this.obj9):f},t.prototype.getObjAtIndex=function(t){if(0==t)return this.obj0;if(1==t)return this.obj1;if(2==t)return this.obj2;if(3==t)return this.obj3;if(4==t)return this.obj4;if(5==t)return this.obj5;if(6==t)return this.obj6;if(7==t)return this.obj7;if(8==t)return this.obj8;if(9==t)return this.obj9;throw new s.OutOfBoundsError(t)},t.prototype.getMaxNumberOfObjects=function(){return h},t}();e.ReflectiveInjectorInlineStrategy=m;var g=function(){function t(t,e){this.protoStrategy=t,this.injector=e,this.objs=i.ListWrapper.createFixedSize(t.providers.length),i.ListWrapper.fill(this.objs,f)}return t.prototype.resetConstructionCounter=function(){this.injector._constructionCounter=0},t.prototype.instantiateProvider=function(t){return this.injector._new(t)},t.prototype.getObjByKeyId=function(t){for(var e=this.protoStrategy,n=0;nt||t>=this.objs.length)throw new s.OutOfBoundsError(t);return this.objs[t]},t.prototype.getMaxNumberOfObjects=function(){return this.objs.length},t}();e.ReflectiveInjectorDynamicStrategy=g;var _=function(){function t(){}return t.resolve=function(t){return o.resolveReflectiveProviders(t)},t.resolveAndCreate=function(e,n){void 0===n&&(n=null);var r=t.resolve(e);return t.fromResolvedProviders(r,n)},t.fromResolvedProviders=function(t,e){return void 0===e&&(e=null),new b(y.fromResolvedProviders(t),e)},t.fromResolvedBindings=function(e){return t.fromResolvedProviders(e)},Object.defineProperty(t.prototype,"parent",{get:function(){return u.unimplemented()},enumerable:!0,configurable:!0}),t.prototype.debugContext=function(){return null},t.prototype.resolveAndCreateChild=function(t){return u.unimplemented()},t.prototype.createChildFromResolved=function(t){return u.unimplemented()},t.prototype.resolveAndInstantiate=function(t){return u.unimplemented()},t.prototype.instantiateResolved=function(t){return u.unimplemented()},t}();e.ReflectiveInjector=_;var b=function(){function t(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null),this._debugContext=n,this._constructionCounter=0,this._proto=t,this._parent=e,this._strategy=t._strategy.createInjectorStrategy(this)}return t.prototype.debugContext=function(){return this._debugContext()},t.prototype.get=function(t,e){return void 0===e&&(e=l.THROW_IF_NOT_FOUND),this._getByKey(c.ReflectiveKey.get(t),null,null,e)},t.prototype.getAt=function(t){return this._strategy.getObjAtIndex(t)},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"internalStrategy",{get:function(){return this._strategy},enumerable:!0,configurable:!0}),t.prototype.resolveAndCreateChild=function(t){var e=_.resolve(t);return this.createChildFromResolved(e)},t.prototype.createChildFromResolved=function(e){var n=new y(e),r=new t(n);return r._parent=this,r},t.prototype.resolveAndInstantiate=function(t){return this.instantiateResolved(_.resolve([t])[0])},t.prototype.instantiateResolved=function(t){return this._instantiateProvider(t)},t.prototype._new=function(t){if(this._constructionCounter++>this._strategy.getMaxNumberOfObjects())throw new s.CyclicDependencyError(this,t.key);return this._instantiateProvider(t)},t.prototype._instantiateProvider=function(t){if(t.multiProvider){for(var e=i.ListWrapper.createFixedSize(t.resolvedFactories.length),n=0;n0?this._getByReflectiveDependency(t,R[0]):null,r=S>1?this._getByReflectiveDependency(t,R[1]):null,i=S>2?this._getByReflectiveDependency(t,R[2]):null,o=S>3?this._getByReflectiveDependency(t,R[3]):null,a=S>4?this._getByReflectiveDependency(t,R[4]):null,c=S>5?this._getByReflectiveDependency(t,R[5]):null,p=S>6?this._getByReflectiveDependency(t,R[6]):null,l=S>7?this._getByReflectiveDependency(t,R[7]):null,h=S>8?this._getByReflectiveDependency(t,R[8]):null,f=S>9?this._getByReflectiveDependency(t,R[9]):null,d=S>10?this._getByReflectiveDependency(t,R[10]):null,v=S>11?this._getByReflectiveDependency(t,R[11]):null,y=S>12?this._getByReflectiveDependency(t,R[12]):null,m=S>13?this._getByReflectiveDependency(t,R[13]):null,g=S>14?this._getByReflectiveDependency(t,R[14]):null,_=S>15?this._getByReflectiveDependency(t,R[15]):null,b=S>16?this._getByReflectiveDependency(t,R[16]):null,P=S>17?this._getByReflectiveDependency(t,R[17]):null,E=S>18?this._getByReflectiveDependency(t,R[18]):null,w=S>19?this._getByReflectiveDependency(t,R[19]):null}catch(O){throw(O instanceof s.AbstractProviderError||O instanceof s.InstantiationError)&&O.addKey(this,t.key),O}var T;try{switch(S){case 0:T=C();break;case 1:T=C(n);break;case 2:T=C(n,r);break;case 3:T=C(n,r,i);break;case 4:T=C(n,r,i,o);break;case 5:T=C(n,r,i,o,a);break;case 6:T=C(n,r,i,o,a,c);break;case 7:T=C(n,r,i,o,a,c,p);break;case 8:T=C(n,r,i,o,a,c,p,l);break;case 9:T=C(n,r,i,o,a,c,p,l,h);break;case 10:T=C(n,r,i,o,a,c,p,l,h,f);break;case 11:T=C(n,r,i,o,a,c,p,l,h,f,d);break;case 12:T=C(n,r,i,o,a,c,p,l,h,f,d,v);break;case 13:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y);break;case 14:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y,m);break;case 15:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y,m,g);break;case 16:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y,m,g,_);break;case 17:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y,m,g,_,b);break;case 18:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y,m,g,_,b,P);break;case 19:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y,m,g,_,b,P,E);break;case 20:T=C(n,r,i,o,a,c,p,l,h,f,d,v,y,m,g,_,b,P,E,w);break;default:throw new u.BaseException("Cannot instantiate '"+t.key.displayName+"' because it has more than 20 dependencies")}}catch(O){throw new s.InstantiationError(this,O,O.stack,t.key)}return T},t.prototype._getByReflectiveDependency=function(t,e){return this._getByKey(e.key,e.lowerBoundVisibility,e.upperBoundVisibility,e.optional?null:l.THROW_IF_NOT_FOUND)},t.prototype._getByKey=function(t,e,n,r){return t===P?this:n instanceof p.SelfMetadata?this._getByKeySelf(t,r):this._getByKeyDefault(t,r,e)},t.prototype._throwOrNull=function(t,e){if(e!==l.THROW_IF_NOT_FOUND)return e;throw new s.NoProviderError(this,t)},t.prototype._getByKeySelf=function(t,e){var n=this._strategy.getObjByKeyId(t.id);return n!==f?n:this._throwOrNull(t,e)},t.prototype._getByKeyDefault=function(e,n,r){var i;for(i=r instanceof p.SkipSelfMetadata?this._parent:this;i instanceof t;){var o=i,s=o._strategy.getObjByKeyId(e.id);if(s!==f)return s;i=o._parent}return null!==i?i.get(e.token,n):this._throwOrNull(e,n)},Object.defineProperty(t.prototype,"displayName",{get:function(){return"ReflectiveInjector(providers: ["+r(this,function(t){return' "'+t.key.displayName+'" '}).join(", ")+"])"},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.displayName},t}();e.ReflectiveInjector_=b;var P=c.ReflectiveKey.get(l.Injector)},function(t,e,n){"use strict";function r(t){var e,n;if(h.isPresent(t.useClass)){var r=g.resolveForwardRef(t.useClass);e=d.reflector.factory(r),n=c(r)}else h.isPresent(t.useExisting)?(e=function(t){return t},n=[b.fromKey(v.ReflectiveKey.get(t.useExisting))]):h.isPresent(t.useFactory)?(e=t.useFactory,n=u(t.useFactory,t.dependencies)):(e=function(){return t.useValue},n=P);return new w(e,n)}function i(t){return new E(v.ReflectiveKey.get(t.token),[r(t)],t.multi)}function o(t){var e=a(t,[]),n=e.map(i);return f.MapWrapper.values(s(n,new Map))}function s(t,e){for(var n=0;n1){var e=r(s.ListWrapper.reversed(t)),n=e.map(function(t){return a.stringify(t.token)});return" ("+n.join(" -> ")+")"}return""}var o=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},s=n(15),a=n(5),u=n(12),c=function(t){function e(e,n,r){t.call(this,"DI Exception"),this.keys=[n],this.injectors=[e],this.constructResolvingMessage=r,this.message=this.constructResolvingMessage(this.keys)}return o(e,t),e.prototype.addKey=function(t,e){this.injectors.push(t),this.keys.push(e),this.message=this.constructResolvingMessage(this.keys)},Object.defineProperty(e.prototype,"context",{get:function(){return this.injectors[this.injectors.length-1].debugContext()},enumerable:!0,configurable:!0}),e}(u.BaseException);e.AbstractProviderError=c;var p=function(t){function e(e,n){t.call(this,e,n,function(t){var e=a.stringify(s.ListWrapper.first(t).token);return"No provider for "+e+"!"+i(t)})}return o(e,t),e}(c);e.NoProviderError=p;var l=function(t){function e(e,n){t.call(this,e,n,function(t){return"Cannot instantiate cyclic dependency!"+i(t)})}return o(e,t),e}(c);e.CyclicDependencyError=l;var h=function(t){function e(e,n,r,i){t.call(this,"DI Exception",n,r,null),this.keys=[i],this.injectors=[e]}return o(e,t),e.prototype.addKey=function(t,e){this.injectors.push(t),this.keys.push(e)},Object.defineProperty(e.prototype,"wrapperMessage",{get:function(){var t=a.stringify(s.ListWrapper.first(this.keys).token);return"Error during instantiation of "+t+"!"+i(this.keys)+"."},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"causeKey",{get:function(){return this.keys[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"context",{get:function(){return this.injectors[this.injectors.length-1].debugContext()},enumerable:!0,configurable:!0}),e}(u.WrappedException);e.InstantiationError=h;var f=function(t){function e(e){t.call(this,"Invalid provider - only instances of Provider and Type are allowed, got: "+e.toString())}return o(e,t),e}(u.BaseException);e.InvalidProviderError=f;var d=function(t){function e(n,r){t.call(this,e._genMessage(n,r))}return o(e,t),e._genMessage=function(t,e){for(var n=[],r=0,i=e.length;i>r;r++){var o=e[r];a.isBlank(o)||0==o.length?n.push("?"):n.push(o.map(a.stringify).join(" "))}return"Cannot resolve all parameters for '"+a.stringify(t)+"'("+n.join(", ")+"). Make sure that all the parameters are decorated with Inject or have valid type annotations and that '"+a.stringify(t)+"' is decorated with Injectable."},e}(u.BaseException);e.NoAnnotationError=d;var v=function(t){function e(e){t.call(this,"Index "+e+" is out-of-bounds.")}return o(e,t),e}(u.BaseException);e.OutOfBoundsError=v;var y=function(t){function e(e,n){t.call(this,"Cannot mix multi providers and regular providers, got: "+e.toString()+" "+n.toString())}return o(e,t),e}(u.BaseException);e.MixingMultiProvidersWithRegularProvidersError=y},function(t,e,n){"use strict";function r(t){return new h(t)}function i(t,e){var n=e.useClass,r=e.useValue,i=e.useExisting,o=e.useFactory,s=e.deps,a=e.multi;return new p(t,{useClass:n,useValue:r,useExisting:i,useFactory:o,deps:s,multi:a})}var o=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},s=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},a=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},u=n(5),c=n(12),p=function(){function t(t,e){var n=e.useClass,r=e.useValue,i=e.useExisting,o=e.useFactory,s=e.deps,a=e.multi;this.token=t,this.useClass=n,this.useValue=r,this.useExisting=i,this.useFactory=o,this.dependencies=s,this._multi=a}return Object.defineProperty(t.prototype,"multi",{get:function(){return u.normalizeBool(this._multi)},enumerable:!0,configurable:!0}),t=s([u.CONST(),a("design:paramtypes",[Object,Object])],t)}();e.Provider=p;var l=function(t){function e(e,n){var r=n.toClass,i=n.toValue,o=n.toAlias,s=n.toFactory,a=n.deps,u=n.multi;t.call(this,e,{useClass:r,useValue:i,useExisting:o,useFactory:s,deps:a,multi:u})}return o(e,t),Object.defineProperty(e.prototype,"toClass",{get:function(){return this.useClass},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"toAlias",{get:function(){return this.useExisting},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"toFactory",{get:function(){return this.useFactory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"toValue",{get:function(){return this.useValue},enumerable:!0,configurable:!0}),e=s([u.CONST(),a("design:paramtypes",[Object,Object])],e)}(p);e.Binding=l,e.bind=r;var h=function(){function t(t){this.token=t}return t.prototype.toClass=function(t){if(!u.isType(t))throw new c.BaseException('Trying to create a class provider but "'+u.stringify(t)+'" is not a class!');return new p(this.token,{useClass:t})},t.prototype.toValue=function(t){return new p(this.token,{useValue:t})},t.prototype.toAlias=function(t){if(u.isBlank(t))throw new c.BaseException("Can not alias "+u.stringify(this.token)+" to a blank value!");return new p(this.token,{useExisting:t})},t.prototype.toFactory=function(t,e){if(!u.isFunction(t))throw new c.BaseException('Trying to create a factory provider but "'+u.stringify(t)+'" is not a function!');return new p(this.token,{useFactory:t,deps:e})},t}();e.ProviderBuilder=h,e.provide=i},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=function(){function t(t){this._desc=t}return t.prototype.toString=function(){return"Token "+this._desc},t=r([o.CONST(),i("design:paramtypes",[String])],t)}();e.OpaqueToken=s},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(5),a=n(7),u=n(27),c=function(t){function e(e){var n=void 0===e?{}:e,r=n.selector,i=n.inputs,o=n.outputs,s=n.properties,a=n.events,u=n.host,c=n.bindings,p=n.providers,l=n.exportAs,h=n.queries;t.call(this),this.selector=r,this._inputs=i,this._properties=s,this._outputs=o,this._events=a,this.host=u,this.exportAs=l,this.queries=h,this._providers=p,this._bindings=c}return r(e,t),Object.defineProperty(e.prototype,"inputs",{get:function(){return s.isPresent(this._properties)&&this._properties.length>0?this._properties:this._inputs},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.inputs},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outputs",{get:function(){return s.isPresent(this._events)&&this._events.length>0?this._events:this._outputs},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){return this.outputs},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"providers",{get:function(){return s.isPresent(this._bindings)&&this._bindings.length>0?this._bindings:this._providers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bindings",{get:function(){return this.providers},enumerable:!0,configurable:!0}),e=i([s.CONST(),o("design:paramtypes",[Object])],e)}(a.InjectableMetadata);e.DirectiveMetadata=c;var p=function(t){function e(e){var n=void 0===e?{}:e,r=n.selector,i=n.inputs,o=n.outputs,s=n.properties,a=n.events,c=n.host,p=n.exportAs,l=n.moduleId,h=n.bindings,f=n.providers,d=n.viewBindings,v=n.viewProviders,y=n.changeDetection,m=void 0===y?u.ChangeDetectionStrategy.Default:y,g=n.queries,_=n.templateUrl,b=n.template,P=n.styleUrls,E=n.styles,w=n.directives,C=n.pipes,R=n.encapsulation;t.call(this,{selector:r,inputs:i,outputs:o,properties:s,events:a,host:c,exportAs:p,bindings:h,providers:f,queries:g}),this.changeDetection=m,this._viewProviders=v,this._viewBindings=d,this.templateUrl=_,this.template=b,this.styleUrls=P,this.styles=E,this.directives=w,this.pipes=C,this.encapsulation=R,this.moduleId=l}return r(e,t),Object.defineProperty(e.prototype,"viewProviders",{get:function(){return s.isPresent(this._viewBindings)&&this._viewBindings.length>0?this._viewBindings:this._viewProviders},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewBindings",{get:function(){return this.viewProviders},enumerable:!0,configurable:!0}),e=i([s.CONST(),o("design:paramtypes",[Object])],e)}(c);e.ComponentMetadata=p;var l=function(t){function e(e){var n=e.name,r=e.pure;t.call(this),this.name=n,this._pure=r}return r(e,t),Object.defineProperty(e.prototype,"pure",{get:function(){return s.isPresent(this._pure)?this._pure:!0},enumerable:!0,configurable:!0}),e=i([s.CONST(),o("design:paramtypes",[Object])],e)}(a.InjectableMetadata);e.PipeMetadata=l;var h=function(){function t(t){this.bindingPropertyName=t}return t=i([s.CONST(),o("design:paramtypes",[String])],t)}();e.InputMetadata=h;var f=function(){function t(t){this.bindingPropertyName=t}return t=i([s.CONST(),o("design:paramtypes",[String])],t)}();e.OutputMetadata=f;var d=function(){function t(t){this.hostPropertyName=t}return t=i([s.CONST(),o("design:paramtypes",[String])],t)}();e.HostBindingMetadata=d;var v=function(){function t(t,e){this.eventName=t,this.args=e}return t=i([s.CONST(),o("design:paramtypes",[String,Array])],t)}();e.HostListenerMetadata=v},function(t,e,n){"use strict";var r=n(28);e.ChangeDetectionStrategy=r.ChangeDetectionStrategy,e.ChangeDetectorRef=r.ChangeDetectorRef,e.WrappedValue=r.WrappedValue,e.SimpleChange=r.SimpleChange,e.IterableDiffers=r.IterableDiffers,e.KeyValueDiffers=r.KeyValueDiffers,e.CollectionChangeRecord=r.CollectionChangeRecord,e.KeyValueChangeRecord=r.KeyValueChangeRecord},function(t,e,n){"use strict";var r=n(29),i=n(30),o=n(31),s=n(32),a=n(5),u=n(32);e.DefaultKeyValueDifferFactory=u.DefaultKeyValueDifferFactory,e.KeyValueChangeRecord=u.KeyValueChangeRecord;var c=n(30);e.DefaultIterableDifferFactory=c.DefaultIterableDifferFactory,e.CollectionChangeRecord=c.CollectionChangeRecord;var p=n(33);e.ChangeDetectionStrategy=p.ChangeDetectionStrategy,e.CHANGE_DETECTION_STRATEGY_VALUES=p.CHANGE_DETECTION_STRATEGY_VALUES,e.ChangeDetectorState=p.ChangeDetectorState,e.CHANGE_DETECTOR_STATE_VALUES=p.CHANGE_DETECTOR_STATE_VALUES,e.isDefaultChangeDetectionStrategy=p.isDefaultChangeDetectionStrategy;var l=n(34);e.ChangeDetectorRef=l.ChangeDetectorRef;var h=n(29);e.IterableDiffers=h.IterableDiffers;var f=n(31);e.KeyValueDiffers=f.KeyValueDiffers;var d=n(35);e.WrappedValue=d.WrappedValue,e.ValueUnwrapper=d.ValueUnwrapper,e.SimpleChange=d.SimpleChange,e.devModeEqual=d.devModeEqual,e.looseIdentical=d.looseIdentical,e.uninitialized=d.uninitialized,e.keyValDiff=a.CONST_EXPR([a.CONST_EXPR(new s.DefaultKeyValueDifferFactory)]),e.iterableDiff=a.CONST_EXPR([a.CONST_EXPR(new i.DefaultIterableDifferFactory)]),e.defaultIterableDiffers=a.CONST_EXPR(new r.IterableDiffers(e.iterableDiff)),e.defaultKeyValueDiffers=a.CONST_EXPR(new o.KeyValueDiffers(e.keyValDiff))},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s); -return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(12),a=n(15),u=n(6),c=function(){function t(t){this.factories=t}return t.create=function(e,n){if(o.isPresent(n)){var r=a.ListWrapper.clone(n.factories);return e=e.concat(r),new t(e)}return new t(e)},t.extend=function(e){return new u.Provider(t,{useFactory:function(n){if(o.isBlank(n))throw new s.BaseException("Cannot extend IterableDiffers without a parent injector");return t.create(e,n)},deps:[[t,new u.SkipSelfMetadata,new u.OptionalMetadata]]})},t.prototype.find=function(t){var e=this.factories.find(function(e){return e.supports(t)});if(o.isPresent(e))return e;throw new s.BaseException("Cannot find a differ supporting object '"+t+"' of type '"+o.getTypeNameForDebugging(t)+"'")},t=r([o.CONST(),i("design:paramtypes",[Array])],t)}();e.IterableDiffers=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(12),a=n(15),u=n(5),c=function(){function t(){}return t.prototype.supports=function(t){return a.isListLikeIterable(t)},t.prototype.create=function(t,e){return new l(e)},t=r([o.CONST(),i("design:paramtypes",[])],t)}();e.DefaultIterableDifferFactory=c;var p=function(t,e){return e},l=function(){function t(t){this._trackByFn=t,this._length=null,this._collection=null,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=u.isPresent(this._trackByFn)?this._trackByFn:p}return Object.defineProperty(t.prototype,"collection",{get:function(){return this._collection},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),t.prototype.forEachItem=function(t){var e;for(e=this._itHead;null!==e;e=e._next)t(e)},t.prototype.forEachPreviousItem=function(t){var e;for(e=this._previousItHead;null!==e;e=e._nextPrevious)t(e)},t.prototype.forEachAddedItem=function(t){var e;for(e=this._additionsHead;null!==e;e=e._nextAdded)t(e)},t.prototype.forEachMovedItem=function(t){var e;for(e=this._movesHead;null!==e;e=e._nextMoved)t(e)},t.prototype.forEachRemovedItem=function(t){var e;for(e=this._removalsHead;null!==e;e=e._nextRemoved)t(e)},t.prototype.forEachIdentityChange=function(t){var e;for(e=this._identityChangesHead;null!==e;e=e._nextIdentityChange)t(e)},t.prototype.diff=function(t){if(u.isBlank(t)&&(t=[]),!a.isListLikeIterable(t))throw new s.BaseException("Error trying to diff '"+t+"'");return this.check(t)?this:null},t.prototype.onDestroy=function(){},t.prototype.check=function(t){var e=this;this._reset();var n,r,i,o=this._itHead,s=!1;if(u.isArray(t)){var c=t;for(this._length=t.length,n=0;n"+u.stringify(this.currentIndex)+"]"},t}();e.CollectionChangeRecord=h;var f=function(){function t(){this._head=null,this._tail=null}return t.prototype.add=function(t){null===this._head?(this._head=this._tail=t,t._nextDup=null,t._prevDup=null):(this._tail._nextDup=t,t._prevDup=this._tail,t._nextDup=null,this._tail=t)},t.prototype.get=function(t,e){var n;for(n=this._head;null!==n;n=n._nextDup)if((null===e||eo?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(12),a=n(15),u=n(6),c=function(){function t(t){this.factories=t}return t.create=function(e,n){if(o.isPresent(n)){var r=a.ListWrapper.clone(n.factories);return e=e.concat(r),new t(e)}return new t(e)},t.extend=function(e){return new u.Provider(t,{useFactory:function(n){if(o.isBlank(n))throw new s.BaseException("Cannot extend KeyValueDiffers without a parent injector");return t.create(e,n)},deps:[[t,new u.SkipSelfMetadata,new u.OptionalMetadata]]})},t.prototype.find=function(t){var e=this.factories.find(function(e){return e.supports(t)});if(o.isPresent(e))return e;throw new s.BaseException("Cannot find a differ supporting object '"+t+"'")},t=r([o.CONST(),i("design:paramtypes",[Array])],t)}();e.KeyValueDiffers=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(15),s=n(5),a=n(12),u=function(){function t(){}return t.prototype.supports=function(t){return t instanceof Map||s.isJsObject(t)},t.prototype.create=function(t){return new c},t=r([s.CONST(),i("design:paramtypes",[])],t)}();e.DefaultKeyValueDifferFactory=u;var c=function(){function t(){this._records=new Map,this._mapHead=null,this._previousMapHead=null,this._changesHead=null,this._changesTail=null,this._additionsHead=null,this._additionsTail=null,this._removalsHead=null,this._removalsTail=null}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return null!==this._additionsHead||null!==this._changesHead||null!==this._removalsHead},enumerable:!0,configurable:!0}),t.prototype.forEachItem=function(t){var e;for(e=this._mapHead;null!==e;e=e._next)t(e)},t.prototype.forEachPreviousItem=function(t){var e;for(e=this._previousMapHead;null!==e;e=e._nextPrevious)t(e)},t.prototype.forEachChangedItem=function(t){var e;for(e=this._changesHead;null!==e;e=e._nextChanged)t(e)},t.prototype.forEachAddedItem=function(t){var e;for(e=this._additionsHead;null!==e;e=e._nextAdded)t(e)},t.prototype.forEachRemovedItem=function(t){var e;for(e=this._removalsHead;null!==e;e=e._nextRemoved)t(e)},t.prototype.diff=function(t){if(s.isBlank(t)&&(t=o.MapWrapper.createFromPairs([])),!(t instanceof Map||s.isJsObject(t)))throw new a.BaseException("Error trying to diff '"+t+"'");return this.check(t)?this:null},t.prototype.onDestroy=function(){},t.prototype.check=function(t){var e=this;this._reset();var n=this._records,r=this._mapHead,i=null,o=null,a=!1;return this._forEach(t,function(t,u){var c;null!==r&&u===r.key?(c=r,s.looseIdentical(t,r.currentValue)||(r.previousValue=r.currentValue,r.currentValue=t,e._addToChanges(r))):(a=!0,null!==r&&(r._next=null,e._removeFromSeq(i,r),e._addToRemovals(r)),n.has(u)?c=n.get(u):(c=new p(u),n.set(u,c),c.currentValue=t,e._addToAdditions(c))),a&&(e._isInRemovals(c)&&e._removeFromRemovals(c),null==o?e._mapHead=c:o._next=c),i=r,o=c,r=null===r?null:r._next}),this._truncate(i,r),this.isDirty},t.prototype._reset=function(){if(this.isDirty){var t;for(t=this._previousMapHead=this._mapHead;null!==t;t=t._next)t._nextPrevious=t._next;for(t=this._changesHead;null!==t;t=t._nextChanged)t.previousValue=t.currentValue;for(t=this._additionsHead;null!=t;t=t._nextAdded)t.previousValue=t.currentValue;this._changesHead=this._changesTail=null,this._additionsHead=this._additionsTail=null,this._removalsHead=this._removalsTail=null}},t.prototype._truncate=function(t,e){for(;null!==e;){null===t?this._mapHead=null:t._next=null;var n=e._next;this._addToRemovals(e),t=e,e=n}for(var r=this._removalsHead;null!==r;r=r._nextRemoved)r.previousValue=r.currentValue,r.currentValue=null,this._records["delete"](r.key)},t.prototype._isInRemovals=function(t){return t===this._removalsHead||null!==t._nextRemoved||null!==t._prevRemoved},t.prototype._addToRemovals=function(t){null===this._removalsHead?this._removalsHead=this._removalsTail=t:(this._removalsTail._nextRemoved=t,t._prevRemoved=this._removalsTail,this._removalsTail=t)},t.prototype._removeFromSeq=function(t,e){var n=e._next;null===t?this._mapHead=n:t._next=n},t.prototype._removeFromRemovals=function(t){var e=t._prevRemoved,n=t._nextRemoved;null===e?this._removalsHead=n:e._nextRemoved=n,null===n?this._removalsTail=e:n._prevRemoved=e,t._prevRemoved=t._nextRemoved=null},t.prototype._addToAdditions=function(t){null===this._additionsHead?this._additionsHead=this._additionsTail=t:(this._additionsTail._nextAdded=t,this._additionsTail=t)},t.prototype._addToChanges=function(t){null===this._changesHead?this._changesHead=this._changesTail=t:(this._changesTail._nextChanged=t,this._changesTail=t)},t.prototype.toString=function(){var t,e=[],n=[],r=[],i=[],o=[];for(t=this._mapHead;null!==t;t=t._next)e.push(s.stringify(t));for(t=this._previousMapHead;null!==t;t=t._nextPrevious)n.push(s.stringify(t));for(t=this._changesHead;null!==t;t=t._nextChanged)r.push(s.stringify(t));for(t=this._additionsHead;null!==t;t=t._nextAdded)i.push(s.stringify(t));for(t=this._removalsHead;null!==t;t=t._nextRemoved)o.push(s.stringify(t));return"map: "+e.join(", ")+"\nprevious: "+n.join(", ")+"\nadditions: "+i.join(", ")+"\nchanges: "+r.join(", ")+"\nremovals: "+o.join(", ")+"\n"},t.prototype._forEach=function(t,e){t instanceof Map?t.forEach(e):o.StringMapWrapper.forEach(t,e)},t}();e.DefaultKeyValueDiffer=c;var p=function(){function t(t){this.key=t,this.previousValue=null,this.currentValue=null,this._nextPrevious=null,this._next=null,this._nextAdded=null,this._nextRemoved=null,this._prevRemoved=null,this._nextChanged=null}return t.prototype.toString=function(){return s.looseIdentical(this.previousValue,this.currentValue)?s.stringify(this.key):s.stringify(this.key)+"["+s.stringify(this.previousValue)+"->"+s.stringify(this.currentValue)+"]"},t}();e.KeyValueChangeRecord=p},function(t,e,n){"use strict";function r(t){return i.isBlank(t)||t===s.Default}var i=n(5);!function(t){t[t.NeverChecked=0]="NeverChecked",t[t.CheckedBefore=1]="CheckedBefore",t[t.Errored=2]="Errored"}(e.ChangeDetectorState||(e.ChangeDetectorState={}));var o=e.ChangeDetectorState;!function(t){t[t.CheckOnce=0]="CheckOnce",t[t.Checked=1]="Checked",t[t.CheckAlways=2]="CheckAlways",t[t.Detached=3]="Detached",t[t.OnPush=4]="OnPush",t[t.Default=5]="Default"}(e.ChangeDetectionStrategy||(e.ChangeDetectionStrategy={}));var s=e.ChangeDetectionStrategy;e.CHANGE_DETECTION_STRATEGY_VALUES=[s.CheckOnce,s.Checked,s.CheckAlways,s.Detached,s.OnPush,s.Default],e.CHANGE_DETECTOR_STATE_VALUES=[o.NeverChecked,o.CheckedBefore,o.Errored],e.isDefaultChangeDetectionStrategy=r},function(t,e){"use strict";var n=function(){function t(){}return t}();e.ChangeDetectorRef=n},function(t,e,n){"use strict";function r(t,e){return o.isListLikeIterable(t)&&o.isListLikeIterable(e)?o.areIterablesEqual(t,e,r):o.isListLikeIterable(t)||i.isPrimitive(t)||o.isListLikeIterable(e)||i.isPrimitive(e)?i.looseIdentical(t,e):!0}var i=n(5),o=n(15),s=n(5);e.looseIdentical=s.looseIdentical,e.uninitialized=i.CONST_EXPR(new Object),e.devModeEqual=r;var a=function(){function t(t){this.wrapped=t}return t.wrap=function(e){return new t(e)},t}();e.WrappedValue=a;var u=function(){function t(){this.hasWrappedValue=!1}return t.prototype.unwrap=function(t){return t instanceof a?(this.hasWrappedValue=!0,t.wrapped):t},t.prototype.reset=function(){this.hasWrappedValue=!1},t}();e.ValueUnwrapper=u;var c=function(){function t(t,e){this.previousValue=t,this.currentValue=e}return t.prototype.isFirstChange=function(){return this.previousValue===e.uninitialized},t}();e.SimpleChange=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5);!function(t){t[t.Emulated=0]="Emulated",t[t.Native=1]="Native",t[t.None=2]="None"}(e.ViewEncapsulation||(e.ViewEncapsulation={}));var s=e.ViewEncapsulation;e.VIEW_ENCAPSULATION_VALUES=[s.Emulated,s.Native,s.None];var a=function(){function t(t){var e=void 0===t?{}:t,n=e.templateUrl,r=e.template,i=e.directives,o=e.pipes,s=e.encapsulation,a=e.styles,u=e.styleUrls;this.templateUrl=n,this.template=r,this.styleUrls=u,this.styles=a,this.directives=i,this.pipes=o,this.encapsulation=s}return t=r([o.CONST(),i("design:paramtypes",[Object])],t)}();e.ViewMetadata=a},function(t,e,n){"use strict";var r=n(9);e.Class=r.Class},function(t,e,n){"use strict";var r=n(5);e.enableProdMode=r.enableProdMode},function(t,e,n){"use strict";var r=n(5);e.Type=r.Type;var i=n(40);e.EventEmitter=i.EventEmitter;var o=n(12);e.WrappedException=o.WrappedException;var s=n(14);e.ExceptionHandler=s.ExceptionHandler},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(41);e.PromiseWrapper=o.PromiseWrapper,e.PromiseCompleter=o.PromiseCompleter;var s=n(42),a=n(43),u=n(58),c=n(42);e.Observable=c.Observable;var p=n(42);e.Subject=p.Subject;var l=function(){function t(){}return t.setTimeout=function(t,e){return i.global.setTimeout(t,e)},t.clearTimeout=function(t){i.global.clearTimeout(t)},t.setInterval=function(t,e){return i.global.setInterval(t,e)},t.clearInterval=function(t){i.global.clearInterval(t)},t}();e.TimerWrapper=l;var h=function(){function t(){}return t.subscribe=function(t,e,n,r){return void 0===r&&(r=function(){}),n="function"==typeof n&&n||i.noop,r="function"==typeof r&&r||i.noop,t.subscribe({next:e,error:n,complete:r})},t.isObservable=function(t){return!!t.subscribe},t.hasSubscribers=function(t){return t.observers.length>0},t.dispose=function(t){t.unsubscribe()},t.callNext=function(t,e){t.next(e)},t.callEmit=function(t,e){t.emit(e)},t.callError=function(t,e){t.error(e)},t.callComplete=function(t){t.complete()},t.fromPromise=function(t){return a.PromiseObservable.create(t)},t.toPromise=function(t){return u.toPromise.call(t)},t}();e.ObservableWrapper=h;var f=function(t){function e(e){void 0===e&&(e=!0),t.call(this),this._isAsync=e}return r(e,t),e.prototype.emit=function(e){t.prototype.next.call(this,e)},e.prototype.next=function(e){t.prototype.next.call(this,e)},e.prototype.subscribe=function(e,n,r){var i,o=function(t){return null},s=function(){return null};return e&&"object"==typeof e?(i=this._isAsync?function(t){setTimeout(function(){return e.next(t)})}:function(t){e.next(t)},e.error&&(o=this._isAsync?function(t){setTimeout(function(){return e.error(t)})}:function(t){e.error(t)}),e.complete&&(s=this._isAsync?function(){setTimeout(function(){return e.complete()})}:function(){e.complete()})):(i=this._isAsync?function(t){setTimeout(function(){return e(t)})}:function(t){e(t)},n&&(o=this._isAsync?function(t){setTimeout(function(){return n(t)})}:function(t){n(t)}),r&&(s=this._isAsync?function(){setTimeout(function(){return r()})}:function(){r()})),t.prototype.subscribe.call(this,i,o,s)},e}(s.Subject);e.EventEmitter=f},function(t,e){"use strict";var n=function(){function t(){var t=this;this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})}return t}();e.PromiseCompleter=n;var r=function(){function t(){}return t.resolve=function(t){return Promise.resolve(t)},t.reject=function(t,e){return Promise.reject(t)},t.catchError=function(t,e){return t["catch"](e)},t.all=function(t){return 0==t.length?Promise.resolve([]):Promise.all(t)},t.then=function(t,e,n){return t.then(e,n)},t.wrap=function(t){return new Promise(function(e,n){try{e(t())}catch(r){n(r)}})},t.scheduleMicrotask=function(e){t.then(t.resolve(null),e,function(t){})},t.isPromise=function(t){return t instanceof Promise},t.completer=function(){return new n},t}();e.PromiseWrapper=r},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){var e=t.value,n=t.subscriber;n.isUnsubscribed||(n.next(e),n.complete())}function i(t){var e=t.err,n=t.subscriber;n.isUnsubscribed||n.error(e)}var o=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},s=n(44),a=n(46),u=function(t){function e(e,n){void 0===n&&(n=null),t.call(this),this.promise=e,this.scheduler=n}return o(e,t),e.create=function(t,n){return void 0===n&&(n=null),new e(t,n)},e.prototype._subscribe=function(t){var e=this,n=this.promise,o=this.scheduler;if(null==o)this._isScalar?t.isUnsubscribed||(t.next(this.value),t.complete()):n.then(function(n){e.value=n,e._isScalar=!0,t.isUnsubscribed||(t.next(n),t.complete())},function(e){t.isUnsubscribed||t.error(e)}).then(null,function(t){s.root.setTimeout(function(){throw t})});else if(this._isScalar){if(!t.isUnsubscribed)return o.schedule(r,0,{value:this.value,subscriber:t})}else n.then(function(n){e.value=n,e._isScalar=!0,t.isUnsubscribed||t.add(o.schedule(r,0,{value:n,subscriber:t}))},function(e){t.isUnsubscribed||t.add(o.schedule(i,0,{err:e,subscriber:t}))}).then(null,function(t){s.root.setTimeout(function(){throw t})})},e}(a.Observable);e.PromiseObservable=u},function(t,e,n){(function(t,n){"use strict";var r={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1};e.root=r[typeof self]&&self||r[typeof window]&&window;var i=(r[typeof e]&&e&&!e.nodeType&&e,r[typeof t]&&t&&!t.nodeType&&t,r[typeof n]&&n);!i||i.global!==i&&i.window!==i||(e.root=i)}).call(e,n(45)(t),function(){return this}())},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,n){"use strict";var r=n(44),i=n(47),o=n(48),s=n(54),a=n(55),u=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var r=this.operator,i=o.toSubscriber(t,e,n);if(r?i.add(this._subscribe(r.call(i))):i.add(this._subscribe(i)),i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},t.prototype.forEach=function(t,e,n){if(n||(r.root.Rx&&r.root.Rx.config&&r.root.Rx.config.Promise?n=r.root.Rx.config.Promise:r.root.Promise&&(n=r.root.Promise)),!n)throw new Error("no Promise impl found");var i=this;return new n(function(n,r){i.subscribe(function(n){var i=s.tryCatch(t).call(e,n);i===a.errorObject&&r(a.errorObject.e)},r,n)})},t.prototype._subscribe=function(t){return this.source.subscribe(t)},t.prototype[i.SymbolShim.observable]=function(){return this},t.create=function(e){return new t(e)},t}();e.Observable=u},function(t,e,n){"use strict";function r(t){var e=o(t);return a(e,t),u(e),i(e),e}function i(t){t["for"]||(t["for"]=s)}function o(t){return t.Symbol||(t.Symbol=function(t){return"@@Symbol("+t+"):"+p++}),t.Symbol}function s(t){return"@@"+t}function a(t,e){if(!t.iterator)if("function"==typeof t["for"])t.iterator=t["for"]("iterator");else if(e.Set&&"function"==typeof(new e.Set)["@@iterator"])t.iterator="@@iterator";else if(e.Map)for(var n=Object.getOwnPropertyNames(e.Map.prototype),r=0;ro?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},h=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},f=n(60),d=n(5),v=n(6),y=n(62),m=n(40),g=n(15),_=n(63),b=n(64),P=n(12),E=n(75),w=n(71);e.createNgZone=r;var C,R=!1;e.createPlatform=i,e.assertPlatform=o,e.disposePlatform=s,e.getPlatform=a,e.coreBootstrap=u,e.coreLoadAndBootstrap=c;var S=function(){function t(){}return Object.defineProperty(t.prototype,"injector",{get:function(){throw P.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"disposed",{get:function(){throw P.unimplemented()},enumerable:!0,configurable:!0}),t}();e.PlatformRef=S;var O=function(t){function e(e){if(t.call(this),this._injector=e,this._applications=[],this._disposeListeners=[],this._disposed=!1,!R)throw new P.BaseException("Platforms have to be created via `createPlatform`!");var n=e.get(y.PLATFORM_INITIALIZER,null);d.isPresent(n)&&n.forEach(function(t){return t()})}return p(e,t),e.prototype.registerDisposeListener=function(t){this._disposeListeners.push(t)},Object.defineProperty(e.prototype,"injector",{get:function(){return this._injector},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disposed",{get:function(){return this._disposed},enumerable:!0,configurable:!0}),e.prototype.addApplication=function(t){this._applications.push(t)},e.prototype.dispose=function(){g.ListWrapper.clone(this._applications).forEach(function(t){return t.dispose()}),this._disposeListeners.forEach(function(t){return t()}),this._disposed=!0},e.prototype._applicationDisposed=function(t){g.ListWrapper.remove(this._applications,t)},e=l([v.Injectable(),h("design:paramtypes",[v.Injector])],e)}(S);e.PlatformRef_=O;var T=function(){function t(){}return Object.defineProperty(t.prototype,"injector",{get:function(){return P.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zone",{get:function(){return P.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"componentTypes",{get:function(){return P.unimplemented()},enumerable:!0,configurable:!0}),t}();e.ApplicationRef=T;var x=function(t){function e(e,n,r){var i=this;t.call(this),this._platform=e,this._zone=n,this._injector=r,this._bootstrapListeners=[],this._disposeListeners=[],this._rootComponents=[],this._rootComponentTypes=[],this._changeDetectorRefs=[],this._runningTick=!1,this._enforceNoNewChanges=!1;var o=r.get(f.NgZone);this._enforceNoNewChanges=d.assertionsEnabled(),o.run(function(){i._exceptionHandler=r.get(P.ExceptionHandler)}),this._asyncInitDonePromise=this.run(function(){var t,e=r.get(y.APP_INITIALIZER,null),n=[];if(d.isPresent(e))for(var o=0;o0?(t=m.PromiseWrapper.all(n).then(function(t){return i._asyncInitDone=!0}),i._asyncInitDone=!1):(i._asyncInitDone=!0,t=m.PromiseWrapper.resolve(!0)),t}),m.ObservableWrapper.subscribe(o.onError,function(t){i._exceptionHandler.call(t.error,t.stackTrace)}),m.ObservableWrapper.subscribe(this._zone.onMicrotaskEmpty,function(t){i._zone.run(function(){i.tick()})})}return p(e,t),e.prototype.registerBootstrapListener=function(t){this._bootstrapListeners.push(t)},e.prototype.registerDisposeListener=function(t){this._disposeListeners.push(t)},e.prototype.registerChangeDetector=function(t){this._changeDetectorRefs.push(t)},e.prototype.unregisterChangeDetector=function(t){g.ListWrapper.remove(this._changeDetectorRefs,t)},e.prototype.waitForAsyncInitializers=function(){return this._asyncInitDonePromise},e.prototype.run=function(t){var e,n=this,r=this.injector.get(f.NgZone),i=m.PromiseWrapper.completer();return r.run(function(){try{e=t(),d.isPromise(e)&&m.PromiseWrapper.then(e,function(t){i.resolve(t)},function(t,e){i.reject(t,e),n._exceptionHandler.call(t,e)})}catch(r){throw n._exceptionHandler.call(r,r.stack),r}}),d.isPromise(e)?i.promise:e},e.prototype.bootstrap=function(t){var e=this;if(!this._asyncInitDone)throw new P.BaseException("Cannot bootstrap as there are still asynchronous initializers running. Wait for them using waitForAsyncInitializers().");return this.run(function(){e._rootComponentTypes.push(t.componentType);var n=t.create(e._injector,[],t.selector);n.onDestroy(function(){e._unloadComponent(n)});var r=n.injector.get(_.Testability,null);d.isPresent(r)&&n.injector.get(_.TestabilityRegistry).registerApplication(n.location.nativeElement,r),e._loadComponent(n);var i=e._injector.get(E.Console);return d.assertionsEnabled()&&i.log("Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode."),n})},e.prototype._loadComponent=function(t){this._changeDetectorRefs.push(t.changeDetectorRef),this.tick(),this._rootComponents.push(t),this._bootstrapListeners.forEach(function(e){return e(t)})},e.prototype._unloadComponent=function(t){g.ListWrapper.contains(this._rootComponents,t)&&(this.unregisterChangeDetector(t.changeDetectorRef),g.ListWrapper.remove(this._rootComponents,t))},Object.defineProperty(e.prototype,"injector",{get:function(){return this._injector},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),e.prototype.tick=function(){if(this._runningTick)throw new P.BaseException("ApplicationRef.tick is called recursively");var t=e._tickScope();try{this._runningTick=!0,this._changeDetectorRefs.forEach(function(t){return t.detectChanges()}),this._enforceNoNewChanges&&this._changeDetectorRefs.forEach(function(t){return t.checkNoChanges()})}finally{this._runningTick=!1,w.wtfLeave(t)}},e.prototype.dispose=function(){g.ListWrapper.clone(this._rootComponents).forEach(function(t){return t.destroy()}),this._disposeListeners.forEach(function(t){return t()}),this._platform._applicationDisposed(this)},Object.defineProperty(e.prototype,"componentTypes",{get:function(){return this._rootComponentTypes},enumerable:!0,configurable:!0}),e._tickScope=w.wtfCreateScope("ApplicationRef#tick()"),e=l([v.Injectable(),h("design:paramtypes",[O,f.NgZone,v.Injector])],e)}(T);e.ApplicationRef_=x,e.PLATFORM_CORE_PROVIDERS=d.CONST_EXPR([O,d.CONST_EXPR(new v.Provider(S,{useExisting:O}))]),e.APPLICATION_CORE_PROVIDERS=d.CONST_EXPR([d.CONST_EXPR(new v.Provider(f.NgZone,{useFactory:r,deps:d.CONST_EXPR([])})),x,d.CONST_EXPR(new v.Provider(T,{useExisting:x}))])},function(t,e,n){"use strict";var r=n(40),i=n(61),o=n(12),s=n(61);e.NgZoneError=s.NgZoneError;var a=function(){function t(t){var e=this,n=t.enableLongStackTrace,o=void 0===n?!1:n;this._hasPendingMicrotasks=!1,this._hasPendingMacrotasks=!1,this._isStable=!0,this._nesting=0,this._onUnstable=new r.EventEmitter(!1),this._onMicrotaskEmpty=new r.EventEmitter(!1),this._onStable=new r.EventEmitter(!1),this._onErrorEvents=new r.EventEmitter(!1),this._zoneImpl=new i.NgZoneImpl({trace:o,onEnter:function(){e._nesting++,e._isStable&&(e._isStable=!1,e._onUnstable.emit(null))},onLeave:function(){e._nesting--,e._checkStable()},setMicrotask:function(t){e._hasPendingMicrotasks=t,e._checkStable()},setMacrotask:function(t){e._hasPendingMacrotasks=t},onError:function(t){return e._onErrorEvents.emit(t)}})}return t.isInAngularZone=function(){return i.NgZoneImpl.isInAngularZone()},t.assertInAngularZone=function(){if(!i.NgZoneImpl.isInAngularZone())throw new o.BaseException("Expected to be in Angular Zone, but it is not!")},t.assertNotInAngularZone=function(){if(i.NgZoneImpl.isInAngularZone())throw new o.BaseException("Expected to not be in Angular Zone, but it is!")},t.prototype._checkStable=function(){var t=this;if(0==this._nesting&&!this._hasPendingMicrotasks&&!this._isStable)try{this._nesting++,this._onMicrotaskEmpty.emit(null)}finally{if(this._nesting--,!this._hasPendingMicrotasks)try{this.runOutsideAngular(function(){return t._onStable.emit(null)})}finally{this._isStable=!0}}},Object.defineProperty(t.prototype,"onUnstable",{get:function(){return this._onUnstable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onMicrotaskEmpty",{get:function(){return this._onMicrotaskEmpty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onStable",{get:function(){return this._onStable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onError",{get:function(){return this._onErrorEvents},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPendingMicrotasks",{get:function(){return this._hasPendingMicrotasks},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPendingMacrotasks",{get:function(){return this._hasPendingMacrotasks},enumerable:!0,configurable:!0}),t.prototype.run=function(t){return this._zoneImpl.runInner(t)},t.prototype.runGuarded=function(t){return this._zoneImpl.runInnerGuarded(t)},t.prototype.runOutsideAngular=function(t){return this._zoneImpl.runOuter(t)},t}();e.NgZone=a},function(t,e){"use strict";var n=function(){function t(t,e){this.error=t,this.stackTrace=e}return t}();e.NgZoneError=n;var r=function(){function t(t){var e=this,r=t.trace,i=t.onEnter,o=t.onLeave,s=t.setMicrotask,a=t.setMacrotask,u=t.onError;if(this.onEnter=i,this.onLeave=o,this.setMicrotask=s,this.setMacrotask=a,this.onError=u,!Zone)throw new Error("Angular2 needs to be run with Zone.js polyfill.");this.outer=this.inner=Zone.current,Zone.wtfZoneSpec&&(this.inner=this.inner.fork(Zone.wtfZoneSpec)),r&&Zone.longStackTraceZoneSpec&&(this.inner=this.inner.fork(Zone.longStackTraceZoneSpec)),this.inner=this.inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:function(t,n,r,i,o,s){try{return e.onEnter(),t.invokeTask(r,i,o,s)}finally{e.onLeave()}},onInvoke:function(t,n,r,i,o,s,a){try{return e.onEnter(),t.invoke(r,i,o,s,a)}finally{e.onLeave()}},onHasTask:function(t,n,r,i){t.hasTask(r,i),n==r&&("microTask"==i.change?e.setMicrotask(i.microTask):"macroTask"==i.change&&e.setMacrotask(i.macroTask))},onHandleError:function(t,r,i,o){return t.handleError(i,o),e.onError(new n(o,o.stack)),!1}})}return t.isInAngularZone=function(){return Zone.current.get("isAngularZone")===!0},t.prototype.runInner=function(t){return this.inner.run(t)},t.prototype.runInnerGuarded=function(t){return this.inner.runGuarded(t)},t.prototype.runOuter=function(t){return this.outer.run(t)},t}();e.NgZoneImpl=r},function(t,e,n){"use strict";function r(){return""+i()+i()+i()}function i(){return s.StringWrapper.fromCharCode(97+s.Math.floor(25*s.Math.random()))}var o=n(6),s=n(5);e.APP_ID=s.CONST_EXPR(new o.OpaqueToken("AppId")),e.APP_ID_RANDOM_PROVIDER=s.CONST_EXPR(new o.Provider(e.APP_ID,{useFactory:r,deps:[]})),e.PLATFORM_INITIALIZER=s.CONST_EXPR(new o.OpaqueToken("Platform Initializer")),e.APP_INITIALIZER=s.CONST_EXPR(new o.OpaqueToken("Application Initializer")),e.PACKAGE_ROOT_URL=s.CONST_EXPR(new o.OpaqueToken("Application Packages Root URL"))},function(t,e,n){"use strict";function r(t){v=t}var i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(6),a=n(15),u=n(5),c=n(12),p=n(60),l=n(40),h=function(){function t(t){this._ngZone=t,this._pendingCount=0,this._isZoneStable=!0,this._didWork=!1,this._callbacks=[],this._watchAngularEvents()}return t.prototype._watchAngularEvents=function(){var t=this;l.ObservableWrapper.subscribe(this._ngZone.onUnstable,function(e){t._didWork=!0,t._isZoneStable=!1}),this._ngZone.runOutsideAngular(function(){l.ObservableWrapper.subscribe(t._ngZone.onStable,function(e){p.NgZone.assertNotInAngularZone(),u.scheduleMicroTask(function(){t._isZoneStable=!0,t._runCallbacksIfReady()})})})},t.prototype.increasePendingRequestCount=function(){return this._pendingCount+=1,this._didWork=!0,this._pendingCount},t.prototype.decreasePendingRequestCount=function(){if(this._pendingCount-=1,this._pendingCount<0)throw new c.BaseException("pending async requests below zero");return this._runCallbacksIfReady(),this._pendingCount},t.prototype.isStable=function(){return this._isZoneStable&&0==this._pendingCount&&!this._ngZone.hasPendingMacrotasks},t.prototype._runCallbacksIfReady=function(){var t=this;this.isStable()?u.scheduleMicroTask(function(){for(;0!==t._callbacks.length;)t._callbacks.pop()(t._didWork);t._didWork=!1}):this._didWork=!0},t.prototype.whenStable=function(t){this._callbacks.push(t),this._runCallbacksIfReady()},t.prototype.getPendingRequestCount=function(){return this._pendingCount},t.prototype.findBindings=function(t,e,n){return[]},t.prototype.findProviders=function(t,e,n){return[]},t=i([s.Injectable(),o("design:paramtypes",[p.NgZone])],t)}();e.Testability=h;var f=function(){function t(){this._applications=new a.Map,v.addToWindow(this)}return t.prototype.registerApplication=function(t,e){this._applications.set(t,e)},t.prototype.getTestability=function(t){return this._applications.get(t)},t.prototype.getAllTestabilities=function(){return a.MapWrapper.values(this._applications)},t.prototype.getAllRootElements=function(){return a.MapWrapper.keys(this._applications)},t.prototype.findTestabilityInTree=function(t,e){return void 0===e&&(e=!0),v.findTestabilityInTree(this,t,e)},t=i([s.Injectable(),o("design:paramtypes",[])],t)}();e.TestabilityRegistry=f;var d=function(){function t(){}return t.prototype.addToWindow=function(t){},t.prototype.findTestabilityInTree=function(t,e,n){return null},t=i([u.CONST(),o("design:paramtypes",[])],t)}();e.setTestabilityGetter=r;var v=u.CONST_EXPR(new d)},function(t,e,n){"use strict";function r(t){return t instanceof h.ComponentFactory}var i=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},o=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},s=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},a=n(6),u=n(5),c=n(12),p=n(40),l=n(18),h=n(65),f=function(){function t(){}return t}();e.ComponentResolver=f;var d=function(t){function e(){t.apply(this,arguments)}return i(e,t),e.prototype.resolveComponent=function(t){var e=l.reflector.annotations(t),n=e.find(r);if(u.isBlank(n))throw new c.BaseException("No precompiled component "+u.stringify(t)+" found");return p.PromiseWrapper.resolve(n)},e.prototype.clearCache=function(){},e=o([a.Injectable(),s("design:paramtypes",[])],e)}(f);e.ReflectorComponentResolver=d},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(5),a=n(12),u=n(66),c=function(){function t(){}return Object.defineProperty(t.prototype,"location",{get:function(){return a.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"injector",{get:function(){return a.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"instance",{get:function(){return a.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hostView",{get:function(){return a.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"changeDetectorRef",{get:function(){return a.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"componentType",{get:function(){return a.unimplemented()},enumerable:!0,configurable:!0}),t}();e.ComponentRef=c;var p=function(t){function e(e,n){t.call(this),this._hostElement=e,this._componentType=n}return r(e,t),Object.defineProperty(e.prototype,"location",{get:function(){return this._hostElement.elementRef},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"injector",{get:function(){return this._hostElement.injector},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"instance",{get:function(){return this._hostElement.component},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hostView",{get:function(){return this._hostElement.parentView.ref},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"changeDetectorRef",{get:function(){return this.hostView},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"componentType",{get:function(){return this._componentType},enumerable:!0,configurable:!0}),e.prototype.destroy=function(){this._hostElement.parentView.destroy()},e.prototype.onDestroy=function(t){this.hostView.onDestroy(t)},e}(c);e.ComponentRef_=p;var l=function(){function t(t,e,n){this.selector=t,this._viewFactory=e,this._componentType=n}return Object.defineProperty(t.prototype,"componentType",{get:function(){return this._componentType},enumerable:!0,configurable:!0}),t.prototype.create=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null);var r=t.get(u.ViewUtils);s.isBlank(e)&&(e=[]);var i=this._viewFactory(r,t,null),o=i.create(e,n);return new p(o,this._componentType)},t=i([s.CONST(),o("design:paramtypes",[String,Function,s.Type])],t)}();e.ComponentFactory=l},function(t,e,n){"use strict";function r(t){return i(t,[])}function i(t,e){for(var n=0;ni;i++)n[i]=r>i?t[i]:D}else n=t;return n}function s(t,e,n,r,i,o,s,u,c,p,l,h,f,d,v,y,m,g,_,b){switch(t){case 1:return e+a(n)+r;case 2:return e+a(n)+r+a(i)+o;case 3:return e+a(n)+r+a(i)+o+a(s)+u;case 4:return e+a(n)+r+a(i)+o+a(s)+u+a(c)+p;case 5:return e+a(n)+r+a(i)+o+a(s)+u+a(c)+p+a(l)+h;case 6:return e+a(n)+r+a(i)+o+a(s)+u+a(c)+p+a(l)+h+a(f)+d;case 7:return e+a(n)+r+a(i)+o+a(s)+u+a(c)+p+a(l)+h+a(f)+d+a(v)+y;case 8:return e+a(n)+r+a(i)+o+a(s)+u+a(c)+p+a(l)+h+a(f)+d+a(v)+y+a(m)+g;case 9:return e+a(n)+r+a(i)+o+a(s)+u+a(c)+p+a(l)+h+a(f)+d+a(v)+y+a(m)+g+a(_)+b;default:throw new O.BaseException("Does not support more than 9 expressions")}}function a(t){return null!=t?t.toString():""}function u(t,e,n){if(t){if(!A.devModeEqual(e,n))throw new x.ExpressionChangedAfterItHasBeenCheckedException(e,n,null);return!1}return!R.looseIdentical(e,n)}function c(t,e){if(t.length!=e.length)return!1;for(var n=0;no?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},w=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},C=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},R=n(5),S=n(15),O=n(12),T=n(67),x=n(73),A=n(28),I=n(6),M=n(74),k=n(62),N=function(){function t(t,e){this._renderer=t,this._appId=e,this._nextCompTypeId=0}return t.prototype.createRenderComponentType=function(t,e,n,r){return new M.RenderComponentType(this._appId+"-"+this._nextCompTypeId++,t,e,n,r)},t.prototype.renderComponent=function(t){return this._renderer.renderComponent(t)},t=E([I.Injectable(),C(1,I.Inject(k.APP_ID)),w("design:paramtypes",[M.RootRenderer,String])],t)}();e.ViewUtils=N,e.flattenNestedViewRenderNodes=r;var D=R.CONST_EXPR([]);e.ensureSlotCount=o,e.MAX_INTERPOLATION_VALUES=9,e.interpolate=s,e.checkBinding=u,e.arrayLooseIdentical=c,e.mapLooseIdentical=p,e.castByValue=l,e.pureProxy1=h,e.pureProxy2=f,e.pureProxy3=d,e.pureProxy4=v,e.pureProxy5=y,e.pureProxy6=m,e.pureProxy7=g,e.pureProxy8=_,e.pureProxy9=b,e.pureProxy10=P},function(t,e,n){"use strict";var r=n(5),i=n(15),o=n(12),s=n(68),a=n(69),u=n(70),c=function(){function t(t,e,n,r){this.index=t,this.parentIndex=e,this.parentView=n,this.nativeElement=r,this.nestedViews=null,this.componentView=null}return Object.defineProperty(t.prototype,"elementRef",{get:function(){return new a.ElementRef(this.nativeElement)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vcRef",{get:function(){return new u.ViewContainerRef_(this)},enumerable:!0,configurable:!0}),t.prototype.initComponent=function(t,e,n){this.component=t,this.componentConstructorViewQueries=e,this.componentView=n},Object.defineProperty(t.prototype,"parentInjector",{get:function(){return this.parentView.injector(this.parentIndex)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"injector",{get:function(){return this.parentView.injector(this.index)},enumerable:!0,configurable:!0}),t.prototype.mapNestedViews=function(t,e){var n=[];return r.isPresent(this.nestedViews)&&this.nestedViews.forEach(function(r){r.clazz===t&&n.push(e(r))}),n},t.prototype.attachView=function(t,e){if(t.type===s.ViewType.COMPONENT)throw new o.BaseException("Component views can't be moved!");var n=this.nestedViews;null==n&&(n=[],this.nestedViews=n),i.ListWrapper.insert(n,e,t);var a;if(e>0){var u=n[e-1];a=u.lastRootNode}else a=this.nativeElement;r.isPresent(a)&&t.renderer.attachViewAfter(a,t.flatRootNodes),t.addToContentChildren(this)},t.prototype.detachView=function(t){var e=i.ListWrapper.removeAt(this.nestedViews,t);if(e.type===s.ViewType.COMPONENT)throw new o.BaseException("Component views can't be moved!");return e.renderer.detachView(e.flatRootNodes),e.removeFromContentChildren(this),e},t}();e.AppElement=c},function(t,e){"use strict";!function(t){t[t.HOST=0]="HOST",t[t.COMPONENT=1]="COMPONENT",t[t.EMBEDDED=2]="EMBEDDED"}(e.ViewType||(e.ViewType={}));e.ViewType},function(t,e){"use strict";var n=function(){function t(t){this.nativeElement=t}return t}();e.ElementRef=n},function(t,e,n){"use strict";var r=n(15),i=n(12),o=n(5),s=n(71),a=function(){function t(){}return Object.defineProperty(t.prototype,"element",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"injector",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parentInjector",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),t}();e.ViewContainerRef=a;var u=function(){function t(t){this._element=t,this._createComponentInContainerScope=s.wtfCreateScope("ViewContainerRef#createComponent()"),this._insertScope=s.wtfCreateScope("ViewContainerRef#insert()"),this._removeScope=s.wtfCreateScope("ViewContainerRef#remove()"),this._detachScope=s.wtfCreateScope("ViewContainerRef#detach()")}return t.prototype.get=function(t){return this._element.nestedViews[t].ref},Object.defineProperty(t.prototype,"length",{get:function(){var t=this._element.nestedViews;return o.isPresent(t)?t.length:0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._element.elementRef},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"injector",{get:function(){return this._element.injector},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parentInjector",{get:function(){return this._element.parentInjector},enumerable:!0,configurable:!0}),t.prototype.createEmbeddedView=function(t,e){void 0===e&&(e=-1);var n=t.createEmbeddedView();return this.insert(n,e),n},t.prototype.createComponent=function(t,e,n,r){void 0===e&&(e=-1),void 0===n&&(n=null),void 0===r&&(r=null);var i=this._createComponentInContainerScope(),a=o.isPresent(n)?n:this._element.parentInjector,u=t.create(a,r);return this.insert(u.hostView,e),s.wtfLeave(i,u)},t.prototype.insert=function(t,e){void 0===e&&(e=-1);var n=this._insertScope();-1==e&&(e=this.length);var r=t;return this._element.attachView(r.internalView,e),s.wtfLeave(n,r)},t.prototype.indexOf=function(t){return r.ListWrapper.indexOf(this._element.nestedViews,t.internalView)},t.prototype.remove=function(t){void 0===t&&(t=-1);var e=this._removeScope();-1==t&&(t=this.length-1);var n=this._element.detachView(t);n.destroy(),s.wtfLeave(e)},t.prototype.detach=function(t){void 0===t&&(t=-1);var e=this._detachScope();-1==t&&(t=this.length-1);var n=this._element.detachView(t);return s.wtfLeave(e,n.ref)},t.prototype.clear=function(){for(var t=this.length-1;t>=0;t--)this.remove(t)},t}();e.ViewContainerRef_=u},function(t,e,n){"use strict";function r(t,e){return null}var i=n(72);e.wtfEnabled=i.detectWTF(),e.wtfCreateScope=e.wtfEnabled?i.createScope:function(t,e){return r},e.wtfLeave=e.wtfEnabled?i.leave:function(t,e){return e},e.wtfStartTimeRange=e.wtfEnabled?i.startTimeRange:function(t,e){return null},e.wtfEndTimeRange=e.wtfEnabled?i.endTimeRange:function(t){return null}},function(t,e,n){"use strict";function r(){var t=p.global.wtf;return t&&(u=t.trace)?(c=u.events,!0):!1}function i(t,e){return void 0===e&&(e=null),c.createScope(t,e)}function o(t,e){return u.leaveScope(t,e),e}function s(t,e){return u.beginTimeRange(t,e)}function a(t){u.endTimeRange(t)}var u,c,p=n(5);e.detectWTF=r,e.createScope=i,e.leave=o,e.startTimeRange=s,e.endTimeRange=a},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(12),o=function(t){function e(e,n,r){t.call(this,"Expression has changed after it was checked. "+("Previous value: '"+e+"'. Current value: '"+n+"'"))}return r(e,t),e}(i.BaseException);e.ExpressionChangedAfterItHasBeenCheckedException=o;var s=function(t){function e(e,n,r){t.call(this,"Error in "+r.source,e,n,r)}return r(e,t),e}(i.WrappedException);e.ViewWrappedException=s;var a=function(t){function e(e){t.call(this,"Attempt to use a destroyed view: "+e)}return r(e,t),e}(i.BaseException);e.ViewDestroyedException=a},function(t,e,n){"use strict";var r=n(12),i=function(){function t(t,e,n,r,i){this.id=t,this.templateUrl=e,this.slotCount=n,this.encapsulation=r,this.styles=i}return t}();e.RenderComponentType=i;var o=function(){function t(){}return Object.defineProperty(t.prototype,"injector",{get:function(){return r.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"component",{get:function(){ -return r.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"providerTokens",{get:function(){return r.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"locals",{get:function(){return r.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return r.unimplemented()},enumerable:!0,configurable:!0}),t}();e.RenderDebugInfo=o;var s=function(){function t(){}return t}();e.Renderer=s;var a=function(){function t(){}return t}();e.RootRenderer=a},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(6),s=n(5),a=function(){function t(){}return t.prototype.log=function(t){s.print(t)},t=r([o.Injectable(),i("design:paramtypes",[])],t)}();e.Console=a},function(t,e,n){"use strict";var r=n(60);e.NgZone=r.NgZone,e.NgZoneError=r.NgZoneError},function(t,e,n){"use strict";var r=n(74);e.RootRenderer=r.RootRenderer,e.Renderer=r.Renderer,e.RenderComponentType=r.RenderComponentType},function(t,e,n){"use strict";var r=n(64);e.ComponentResolver=r.ComponentResolver;var i=n(79);e.QueryList=i.QueryList;var o=n(80);e.DynamicComponentLoader=o.DynamicComponentLoader;var s=n(69);e.ElementRef=s.ElementRef;var a=n(81);e.TemplateRef=a.TemplateRef;var u=n(82);e.EmbeddedViewRef=u.EmbeddedViewRef,e.ViewRef=u.ViewRef;var c=n(70);e.ViewContainerRef=c.ViewContainerRef;var p=n(65);e.ComponentRef=p.ComponentRef,e.ComponentFactory=p.ComponentFactory;var l=n(73);e.ExpressionChangedAfterItHasBeenCheckedException=l.ExpressionChangedAfterItHasBeenCheckedException},function(t,e,n){"use strict";var r=n(15),i=n(5),o=n(40),s=function(){function t(){this._dirty=!0,this._results=[],this._emitter=new o.EventEmitter}return Object.defineProperty(t.prototype,"changes",{get:function(){return this._emitter},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._results.length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"first",{get:function(){return r.ListWrapper.first(this._results)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"last",{get:function(){return r.ListWrapper.last(this._results)},enumerable:!0,configurable:!0}),t.prototype.map=function(t){return this._results.map(t)},t.prototype.filter=function(t){return this._results.filter(t)},t.prototype.reduce=function(t,e){return this._results.reduce(t,e)},t.prototype.forEach=function(t){this._results.forEach(t)},t.prototype.toArray=function(){return r.ListWrapper.clone(this._results)},t.prototype[i.getSymbolIterator()]=function(){return this._results[i.getSymbolIterator()]()},t.prototype.toString=function(){return this._results.toString()},t.prototype.reset=function(t){this._results=r.ListWrapper.flatten(t),this._dirty=!1},t.prototype.notifyOnChanges=function(){this._emitter.emit(this)},t.prototype.setDirty=function(){this._dirty=!0},Object.defineProperty(t.prototype,"dirty",{get:function(){return this._dirty},enumerable:!0,configurable:!0}),t}();e.QueryList=s},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(6),a=n(64),u=n(5),c=function(){function t(){}return t}();e.DynamicComponentLoader=c;var p=function(t){function e(e){t.call(this),this._compiler=e}return r(e,t),e.prototype.loadAsRoot=function(t,e,n,r,i){return this._compiler.resolveComponent(t).then(function(t){var o=t.create(n,i,u.isPresent(e)?e:t.selector);return u.isPresent(r)&&o.onDestroy(r),o})},e.prototype.loadNextToLocation=function(t,e,n,r){return void 0===n&&(n=null),void 0===r&&(r=null),this._compiler.resolveComponent(t).then(function(t){var i=e.parentInjector,o=u.isPresent(n)&&n.length>0?s.ReflectiveInjector.fromResolvedProviders(n,i):i;return e.createComponent(t,e.length,o,r)})},e=i([s.Injectable(),o("design:paramtypes",[a.ComponentResolver])],e)}(c);e.DynamicComponentLoader_=p},function(t,e){"use strict";var n=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},r=function(){function t(){}return Object.defineProperty(t.prototype,"elementRef",{get:function(){return null},enumerable:!0,configurable:!0}),t}();e.TemplateRef=r;var i=function(t){function e(e,n){t.call(this),this._appElement=e,this._viewFactory=n}return n(e,t),e.prototype.createEmbeddedView=function(){var t=this._viewFactory(this._appElement.parentView.viewUtils,this._appElement.parentInjector,this._appElement);return t.create(null,null),t.ref},Object.defineProperty(e.prototype,"elementRef",{get:function(){return this._appElement.elementRef},enumerable:!0,configurable:!0}),e}(r);e.TemplateRef_=i},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(12),o=n(34),s=n(33),a=function(t){function e(){t.apply(this,arguments)}return r(e,t),Object.defineProperty(e.prototype,"changeDetectorRef",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),e}(o.ChangeDetectorRef);e.ViewRef=a;var u=function(t){function e(){t.apply(this,arguments)}return r(e,t),Object.defineProperty(e.prototype,"rootNodes",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),e}(a);e.EmbeddedViewRef=u;var c=function(){function t(t){this._view=t,this._view=t}return Object.defineProperty(t.prototype,"internalView",{get:function(){return this._view},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"changeDetectorRef",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rootNodes",{get:function(){return this._view.flatRootNodes},enumerable:!0,configurable:!0}),t.prototype.setLocal=function(t,e){this._view.setLocal(t,e)},t.prototype.hasLocal=function(t){return this._view.hasLocal(t)},Object.defineProperty(t.prototype,"destroyed",{get:function(){return this._view.destroyed},enumerable:!0,configurable:!0}),t.prototype.markForCheck=function(){this._view.markPathToRootAsCheckOnce()},t.prototype.detach=function(){this._view.cdMode=s.ChangeDetectionStrategy.Detached},t.prototype.detectChanges=function(){this._view.detectChanges(!1)},t.prototype.checkNoChanges=function(){this._view.detectChanges(!0)},t.prototype.reattach=function(){this._view.cdMode=s.ChangeDetectionStrategy.CheckAlways,this.markForCheck()},t.prototype.onDestroy=function(t){this._view.disposables.push(t)},t.prototype.destroy=function(){this._view.destroy()},t}();e.ViewRef_=c},function(t,e,n){"use strict";function r(t){return t.map(function(t){return t.nativeElement})}function i(t,e,n){t.childNodes.forEach(function(t){t instanceof v&&(e(t)&&n.push(t),i(t,e,n))})}function o(t,e,n){t instanceof v&&t.childNodes.forEach(function(t){e(t)&&n.push(t),t instanceof v&&o(t,e,n)})}function s(t){return y.get(t)}function a(){return h.MapWrapper.values(y)}function u(t){y.set(t.nativeNode,t)}function c(t){y["delete"](t.nativeNode)}var p=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},l=n(5),h=n(15),f=function(){function t(t,e){this.name=t,this.callback=e}return t}();e.EventListener=f;var d=function(){function t(t,e,n){this._debugInfo=n,this.nativeNode=t,l.isPresent(e)&&e instanceof v?e.addChild(this):this.parent=null,this.listeners=[]}return Object.defineProperty(t.prototype,"injector",{get:function(){return l.isPresent(this._debugInfo)?this._debugInfo.injector:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"componentInstance",{get:function(){return l.isPresent(this._debugInfo)?this._debugInfo.component:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"locals",{get:function(){return l.isPresent(this._debugInfo)?this._debugInfo.locals:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"providerTokens",{get:function(){return l.isPresent(this._debugInfo)?this._debugInfo.providerTokens:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return l.isPresent(this._debugInfo)?this._debugInfo.source:null},enumerable:!0,configurable:!0}),t.prototype.inject=function(t){return this.injector.get(t)},t.prototype.getLocal=function(t){return this.locals[t]},t}();e.DebugNode=d;var v=function(t){function e(e,n,r){t.call(this,e,n,r),this.properties={},this.attributes={},this.childNodes=[],this.nativeElement=e}return p(e,t),e.prototype.addChild=function(t){l.isPresent(t)&&(this.childNodes.push(t),t.parent=this)},e.prototype.removeChild=function(t){var e=this.childNodes.indexOf(t);-1!==e&&(t.parent=null,this.childNodes.splice(e,1))},e.prototype.insertChildrenAfter=function(t,e){var n=this.childNodes.indexOf(t);if(-1!==n){var r=this.childNodes.slice(0,n+1),i=this.childNodes.slice(n+1);this.childNodes=h.ListWrapper.concat(h.ListWrapper.concat(r,e),i);for(var o=0;o0?e[0]:null},e.prototype.queryAll=function(t){var e=[];return i(this,t,e),e},e.prototype.queryAllNodes=function(t){var e=[];return o(this,t,e),e},Object.defineProperty(e.prototype,"children",{get:function(){var t=[];return this.childNodes.forEach(function(n){n instanceof e&&t.push(n)}),t},enumerable:!0,configurable:!0}),e.prototype.triggerEventHandler=function(t,e){this.listeners.forEach(function(n){n.name==t&&n.callback(e)})},e}(d);e.DebugElement=v,e.asNativeElements=r;var y=new Map;e.getDebugNode=s,e.getAllDebugNodes=a,e.indexDebugNode=u,e.removeDebugNodeFromIndex=c},function(t,e,n){"use strict";var r=n(6),i=n(5);e.PLATFORM_DIRECTIVES=i.CONST_EXPR(new r.OpaqueToken("Platform Directives")),e.PLATFORM_PIPES=i.CONST_EXPR(new r.OpaqueToken("Platform Pipes"))},function(t,e,n){"use strict";function r(){return a.reflector}var i=n(5),o=n(6),s=n(75),a=n(18),u=n(20),c=n(63),p=n(59);e.PLATFORM_COMMON_PROVIDERS=i.CONST_EXPR([p.PLATFORM_CORE_PROVIDERS,new o.Provider(a.Reflector,{useFactory:r,deps:[]}),new o.Provider(u.ReflectorReader,{useExisting:a.Reflector}),c.TestabilityRegistry,s.Console])},function(t,e,n){"use strict";var r=n(5),i=n(6),o=n(62),s=n(59),a=n(28),u=n(66),c=n(64),p=n(64),l=n(80),h=n(80);e.APPLICATION_COMMON_PROVIDERS=r.CONST_EXPR([s.APPLICATION_CORE_PROVIDERS,new i.Provider(c.ComponentResolver,{useClass:p.ReflectorComponentResolver}),o.APP_ID_RANDOM_PROVIDER,u.ViewUtils,new i.Provider(a.IterableDiffers,{useValue:a.defaultIterableDiffers}),new i.Provider(a.KeyValueDiffers,{useValue:a.defaultKeyValueDiffers}),new i.Provider(l.DynamicComponentLoader,{useClass:h.DynamicComponentLoader_})])},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}r(n(88)),r(n(102)),r(n(112)),r(n(136))},function(t,e,n){"use strict";var r=n(89);e.AsyncPipe=r.AsyncPipe;var i=n(91);e.DatePipe=i.DatePipe;var o=n(93);e.JsonPipe=o.JsonPipe;var s=n(94);e.SlicePipe=s.SlicePipe;var a=n(95);e.LowerCasePipe=a.LowerCasePipe;var u=n(96);e.NumberPipe=u.NumberPipe,e.DecimalPipe=u.DecimalPipe,e.PercentPipe=u.PercentPipe,e.CurrencyPipe=u.CurrencyPipe;var c=n(97);e.UpperCasePipe=c.UpperCasePipe;var p=n(98);e.ReplacePipe=p.ReplacePipe;var l=n(99);e.I18nPluralPipe=l.I18nPluralPipe;var h=n(100);e.I18nSelectPipe=h.I18nSelectPipe;var f=n(101);e.COMMON_PIPES=f.COMMON_PIPES},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(40),a=n(2),u=n(90),c=function(){function t(){}return t.prototype.createSubscription=function(t,e){return s.ObservableWrapper.subscribe(t,e,function(t){throw t})},t.prototype.dispose=function(t){s.ObservableWrapper.dispose(t)},t.prototype.onDestroy=function(t){s.ObservableWrapper.dispose(t)},t}(),p=function(){function t(){}return t.prototype.createSubscription=function(t,e){return t.then(e)},t.prototype.dispose=function(t){},t.prototype.onDestroy=function(t){},t}(),l=new p,h=new c,f=function(){function t(t){this._latestValue=null,this._latestReturnedValue=null,this._subscription=null,this._obj=null,this._strategy=null,this._ref=t}return t.prototype.ngOnDestroy=function(){o.isPresent(this._subscription)&&this._dispose()},t.prototype.transform=function(t){return o.isBlank(this._obj)?(o.isPresent(t)&&this._subscribe(t),this._latestReturnedValue=this._latestValue,this._latestValue):t!==this._obj?(this._dispose(),this.transform(t)):this._latestValue===this._latestReturnedValue?this._latestReturnedValue:(this._latestReturnedValue=this._latestValue,a.WrappedValue.wrap(this._latestValue))},t.prototype._subscribe=function(t){var e=this;this._obj=t,this._strategy=this._selectStrategy(t),this._subscription=this._strategy.createSubscription(t,function(n){return e._updateLatestValue(t,n)})},t.prototype._selectStrategy=function(e){if(o.isPromise(e))return l;if(s.ObservableWrapper.isObservable(e))return h;throw new u.InvalidPipeArgumentException(t,e)},t.prototype._dispose=function(){this._strategy.dispose(this._subscription),this._latestValue=null,this._latestReturnedValue=null,this._subscription=null,this._obj=null},t.prototype._updateLatestValue=function(t,e){t===this._obj&&(this._latestValue=e,this._ref.markForCheck())},t=r([a.Pipe({name:"async",pure:!1}),a.Injectable(),i("design:paramtypes",[a.ChangeDetectorRef])],t)}();e.AsyncPipe=f},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(12),s=function(t){function e(e,n){t.call(this,"Invalid argument '"+n+"' for pipe '"+i.stringify(e)+"'")}return r(e,t),e}(o.BaseException);e.InvalidPipeArgumentException=s},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(92),a=n(2),u=n(15),c=n(90),p="en-US",l=function(){function t(){}return t.prototype.transform=function(e,n){if(void 0===n&&(n="mediumDate"),o.isBlank(e))return null;if(!this.supports(e))throw new c.InvalidPipeArgumentException(t,e);return o.isNumber(e)&&(e=o.DateWrapper.fromMillis(e)),u.StringMapWrapper.contains(t._ALIASES,n)&&(n=u.StringMapWrapper.get(t._ALIASES,n)),s.DateFormatter.format(e,p,n)},t.prototype.supports=function(t){return o.isDate(t)||o.isNumber(t)},t._ALIASES={medium:"yMMMdjms","short":"yMdjm",fullDate:"yMMMMEEEEd",longDate:"yMMMMd",mediumDate:"yMMMd",shortDate:"yMd",mediumTime:"jms",shortTime:"jm"},t=r([o.CONST(),a.Pipe({name:"date",pure:!0}),a.Injectable(),i("design:paramtypes",[])],t)}();e.DatePipe=l},function(t,e){"use strict";function n(t){return 2==t?"2-digit":"numeric"}function r(t){return 4>t?"short":"long"}function i(t){for(var e,i={},o=0;o=3?i.month=r(s):i.month=n(s);break;case"d":i.day=n(s);break;case"E":i.weekday=r(s);break;case"j":i.hour=n(s);break;case"h":i.hour=n(s),i.hour12=!0;break;case"H":i.hour=n(s),i.hour12=!1;break;case"m":i.minute=n(s);break;case"s":i.second=n(s);break;case"z":i.timeZoneName="long";break;case"Z":i.timeZoneName="short"}o=e}return i}!function(t){t[t.Decimal=0]="Decimal",t[t.Percent=1]="Percent",t[t.Currency=2]="Currency"}(e.NumberFormatStyle||(e.NumberFormatStyle={}));var o=e.NumberFormatStyle,s=function(){function t(){}return t.format=function(t,e,n,r){var i=void 0===r?{}:r,s=i.minimumIntegerDigits,a=void 0===s?1:s,u=i.minimumFractionDigits,c=void 0===u?0:u,p=i.maximumFractionDigits,l=void 0===p?3:p,h=i.currency,f=i.currencyAsSymbol,d=void 0===f?!1:f,v={minimumIntegerDigits:a,minimumFractionDigits:c,maximumFractionDigits:l};return v.style=o[n].toLowerCase(),n==o.Currency&&(v.currency=h,v.currencyDisplay=d?"symbol":"code"),new Intl.NumberFormat(e,v).format(t)},t}();e.NumberFormatter=s;var a=new Map,u=function(){function t(){}return t.format=function(t,e,n){var r=e+n;if(a.has(r))return a.get(r).format(t);var o=new Intl.DateTimeFormat(e,i(n));return a.set(r,o),o.format(t)},t}();e.DateFormatter=u},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(2),a=function(){function t(){}return t.prototype.transform=function(t){return o.Json.stringify(t)},t=r([o.CONST(),s.Pipe({name:"json",pure:!1}),s.Injectable(),i("design:paramtypes",[])],t)}();e.JsonPipe=a},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(15),a=n(2),u=n(90),c=function(){function t(){}return t.prototype.transform=function(e,n,r){if(void 0===r&&(r=null),!this.supports(e))throw new u.InvalidPipeArgumentException(t,e);return o.isBlank(e)?e:o.isString(e)?o.StringWrapper.slice(e,n,r):s.ListWrapper.slice(e,n,r)},t.prototype.supports=function(t){return o.isString(t)||o.isArray(t)},t=r([a.Pipe({name:"slice",pure:!1}),a.Injectable(),i("design:paramtypes",[])],t)}();e.SlicePipe=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(2),a=n(90),u=function(){function t(){}return t.prototype.transform=function(e){if(o.isBlank(e))return e;if(!o.isString(e))throw new a.InvalidPipeArgumentException(t,e);return e.toLowerCase()},t=r([o.CONST(),s.Pipe({name:"lowercase"}),s.Injectable(),i("design:paramtypes",[])],t)}();e.LowerCasePipe=u},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(5),a=n(12),u=n(92),c=n(2),p=n(90),l="en-US",h=s.RegExpWrapper.create("^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$"),f=function(){function t(){}return t._format=function(e,n,r,i,o){if(void 0===i&&(i=null),void 0===o&&(o=!1),s.isBlank(e))return null;if(!s.isNumber(e))throw new p.InvalidPipeArgumentException(t,e);var c=1,f=0,d=3;if(s.isPresent(r)){var v=s.RegExpWrapper.firstMatch(h,r);if(s.isBlank(v))throw new a.BaseException(r+" is not a valid digit info for number pipes");s.isPresent(v[1])&&(c=s.NumberWrapper.parseIntAutoRadix(v[1])),s.isPresent(v[3])&&(f=s.NumberWrapper.parseIntAutoRadix(v[3])),s.isPresent(v[5])&&(d=s.NumberWrapper.parseIntAutoRadix(v[5]))}return u.NumberFormatter.format(e,l,n,{minimumIntegerDigits:c,minimumFractionDigits:f,maximumFractionDigits:d,currency:i,currencyAsSymbol:o})},t=i([s.CONST(),c.Injectable(),o("design:paramtypes",[])],t)}();e.NumberPipe=f;var d=function(t){function e(){t.apply(this,arguments)}return r(e,t),e.prototype.transform=function(t,e){return void 0===e&&(e=null),f._format(t,u.NumberFormatStyle.Decimal,e)},e=i([s.CONST(),c.Pipe({name:"number"}),c.Injectable(),o("design:paramtypes",[])],e)}(f);e.DecimalPipe=d;var v=function(t){function e(){t.apply(this,arguments)}return r(e,t),e.prototype.transform=function(t,e){return void 0===e&&(e=null),f._format(t,u.NumberFormatStyle.Percent,e)},e=i([s.CONST(),c.Pipe({name:"percent"}),c.Injectable(),o("design:paramtypes",[])],e)}(f);e.PercentPipe=v;var y=function(t){function e(){t.apply(this,arguments)}return r(e,t),e.prototype.transform=function(t,e,n,r){return void 0===e&&(e="USD"),void 0===n&&(n=!1),void 0===r&&(r=null),f._format(t,u.NumberFormatStyle.Currency,r,e,n)},e=i([s.CONST(),c.Pipe({name:"currency"}),c.Injectable(),o("design:paramtypes",[])],e)}(f);e.CurrencyPipe=y},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(2),a=n(90),u=function(){function t(){}return t.prototype.transform=function(e){if(o.isBlank(e))return e;if(!o.isString(e))throw new a.InvalidPipeArgumentException(t,e);return e.toUpperCase()},t=r([o.CONST(),s.Pipe({name:"uppercase"}),s.Injectable(),i("design:paramtypes",[])],t)}();e.UpperCasePipe=u},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(2),a=n(90),u=function(){function t(){}return t.prototype.transform=function(e,n,r){if(o.isBlank(e))return e;if(!this._supportedInput(e))throw new a.InvalidPipeArgumentException(t,e);var i=e.toString();if(!this._supportedPattern(n))throw new a.InvalidPipeArgumentException(t,n);if(!this._supportedReplacement(r))throw new a.InvalidPipeArgumentException(t,r);if(o.isFunction(r)){var s=o.isString(n)?o.RegExpWrapper.create(n):n;return o.StringWrapper.replaceAllMapped(i,s,r)}return n instanceof RegExp?o.StringWrapper.replaceAll(i,n,r):o.StringWrapper.replace(i,n,r)},t.prototype._supportedInput=function(t){return o.isString(t)||o.isNumber(t)},t.prototype._supportedPattern=function(t){return o.isString(t)||t instanceof RegExp},t.prototype._supportedReplacement=function(t){return o.isString(t)||o.isFunction(t)},t=r([s.Pipe({name:"replace"}),s.Injectable(),i("design:paramtypes",[])],t)}();e.ReplacePipe=u},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(2),a=n(90),u=o.RegExpWrapper.create("#"),c=function(){function t(){}return t.prototype.transform=function(e,n){var r,i;if(!o.isStringMap(n))throw new a.InvalidPipeArgumentException(t,n);return r=0===e||1===e?"="+e:"other",i=o.isPresent(e)?e.toString():"",o.StringWrapper.replaceAll(n[r],u,i)},t=r([o.CONST(),s.Pipe({name:"i18nPlural",pure:!0}),s.Injectable(),i("design:paramtypes",[])],t)}();e.I18nPluralPipe=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(15),a=n(2),u=n(90),c=function(){function t(){}return t.prototype.transform=function(e,n){if(!o.isStringMap(n))throw new u.InvalidPipeArgumentException(t,n);return s.StringMapWrapper.contains(n,e)?n[e]:n.other},t=r([o.CONST(),a.Pipe({name:"i18nSelect",pure:!0}),a.Injectable(),i("design:paramtypes",[])],t)}();e.I18nSelectPipe=c},function(t,e,n){"use strict";var r=n(89),i=n(97),o=n(95),s=n(93),a=n(94),u=n(91),c=n(96),p=n(98),l=n(99),h=n(100),f=n(5);e.COMMON_PIPES=f.CONST_EXPR([r.AsyncPipe,i.UpperCasePipe,o.LowerCasePipe,s.JsonPipe,a.SlicePipe,c.DecimalPipe,c.PercentPipe,c.CurrencyPipe,u.DatePipe,p.ReplacePipe,l.I18nPluralPipe,h.I18nSelectPipe])},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var i=n(103);e.NgClass=i.NgClass;var o=n(104);e.NgFor=o.NgFor;var s=n(105);e.NgIf=s.NgIf;var a=n(106);e.NgTemplateOutlet=a.NgTemplateOutlet;var u=n(107);e.NgStyle=u.NgStyle;var c=n(108);e.NgSwitch=c.NgSwitch,e.NgSwitchWhen=c.NgSwitchWhen,e.NgSwitchDefault=c.NgSwitchDefault;var p=n(109);e.NgPlural=p.NgPlural,e.NgPluralCase=p.NgPluralCase,e.NgLocalization=p.NgLocalization,r(n(110));var l=n(111);e.CORE_DIRECTIVES=l.CORE_DIRECTIVES},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(2),a=n(15),u=function(){function t(t,e,n,r){this._iterableDiffers=t,this._keyValueDiffers=e,this._ngEl=n,this._renderer=r,this._initialClasses=[]}return Object.defineProperty(t.prototype,"initialClasses",{set:function(t){this._applyInitialClasses(!0),this._initialClasses=o.isPresent(t)&&o.isString(t)?t.split(" "):[],this._applyInitialClasses(!1),this._applyClasses(this._rawClass,!1)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rawClass",{set:function(t){this._cleanupClasses(this._rawClass),o.isString(t)&&(t=t.split(" ")),this._rawClass=t,this._iterableDiffer=null,this._keyValueDiffer=null,o.isPresent(t)&&(a.isListLikeIterable(t)?this._iterableDiffer=this._iterableDiffers.find(t).create(null):this._keyValueDiffer=this._keyValueDiffers.find(t).create(null))},enumerable:!0,configurable:!0}),t.prototype.ngDoCheck=function(){if(o.isPresent(this._iterableDiffer)){var t=this._iterableDiffer.diff(this._rawClass);o.isPresent(t)&&this._applyIterableChanges(t)}if(o.isPresent(this._keyValueDiffer)){var t=this._keyValueDiffer.diff(this._rawClass);o.isPresent(t)&&this._applyKeyValueChanges(t)}},t.prototype.ngOnDestroy=function(){this._cleanupClasses(this._rawClass)},t.prototype._cleanupClasses=function(t){this._applyClasses(t,!0),this._applyInitialClasses(!1)},t.prototype._applyKeyValueChanges=function(t){var e=this;t.forEachAddedItem(function(t){e._toggleClass(t.key,t.currentValue)}),t.forEachChangedItem(function(t){e._toggleClass(t.key,t.currentValue)}),t.forEachRemovedItem(function(t){t.previousValue&&e._toggleClass(t.key,!1)})},t.prototype._applyIterableChanges=function(t){var e=this;t.forEachAddedItem(function(t){e._toggleClass(t.item,!0)}),t.forEachRemovedItem(function(t){e._toggleClass(t.item,!1)})},t.prototype._applyInitialClasses=function(t){var e=this;this._initialClasses.forEach(function(n){return e._toggleClass(n,!t)})},t.prototype._applyClasses=function(t,e){var n=this;o.isPresent(t)&&(o.isArray(t)?t.forEach(function(t){return n._toggleClass(t,!e)}):t instanceof Set?t.forEach(function(t){return n._toggleClass(t,!e)}):a.StringMapWrapper.forEach(t,function(t,r){o.isPresent(t)&&n._toggleClass(r,!e)}))},t.prototype._toggleClass=function(t,e){if(t=t.trim(),t.length>0)if(t.indexOf(" ")>-1)for(var n=t.split(/\s+/g),r=0,i=n.length;i>r;r++)this._renderer.setElementClass(this._ngEl.nativeElement,n[r],e);else this._renderer.setElementClass(this._ngEl.nativeElement,t,e)},t=r([s.Directive({selector:"[ngClass]",inputs:["rawClass: ngClass","initialClasses: class"]}),i("design:paramtypes",[s.IterableDiffers,s.KeyValueDiffers,s.ElementRef,s.Renderer])],t)}();e.NgClass=u},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(5),a=n(12),u=function(){function t(t,e,n,r){this._viewContainer=t,this._templateRef=e,this._iterableDiffers=n,this._cdr=r}return Object.defineProperty(t.prototype,"ngForOf",{ -set:function(t){if(this._ngForOf=t,s.isBlank(this._differ)&&s.isPresent(t))try{this._differ=this._iterableDiffers.find(t).create(this._cdr,this._ngForTrackBy)}catch(e){throw new a.BaseException("Cannot find a differ supporting object '"+t+"' of type '"+s.getTypeNameForDebugging(t)+"'. NgFor only supports binding to Iterables such as Arrays.")}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngForTemplate",{set:function(t){s.isPresent(t)&&(this._templateRef=t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngForTrackBy",{set:function(t){this._ngForTrackBy=t},enumerable:!0,configurable:!0}),t.prototype.ngDoCheck=function(){if(s.isPresent(this._differ)){var t=this._differ.diff(this._ngForOf);s.isPresent(t)&&this._applyChanges(t)}},t.prototype._applyChanges=function(t){var e=this,n=[];t.forEachRemovedItem(function(t){return n.push(new c(t,null))}),t.forEachMovedItem(function(t){return n.push(new c(t,null))});var r=this._bulkRemove(n);t.forEachAddedItem(function(t){return r.push(new c(t,null))}),this._bulkInsert(r);for(var i=0;ii;i++){var s=this._viewContainer.get(i);s.setLocal("first",0===i),s.setLocal("last",i===o-1)}t.forEachIdentityChange(function(t){var n=e._viewContainer.get(t.currentIndex);n.setLocal("$implicit",t.item)})},t.prototype._perViewChange=function(t,e){t.setLocal("$implicit",e.item),t.setLocal("index",e.currentIndex),t.setLocal("even",e.currentIndex%2==0),t.setLocal("odd",e.currentIndex%2==1)},t.prototype._bulkRemove=function(t){t.sort(function(t,e){return t.record.previousIndex-e.record.previousIndex});for(var e=[],n=t.length-1;n>=0;n--){var r=t[n];s.isPresent(r.record.currentIndex)?(r.view=this._viewContainer.detach(r.record.previousIndex),e.push(r)):this._viewContainer.remove(r.record.previousIndex)}return e},t.prototype._bulkInsert=function(t){t.sort(function(t,e){return t.record.currentIndex-e.record.currentIndex});for(var e=0;eo?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(5),a=function(){function t(t,e){this._viewContainer=t,this._templateRef=e,this._prevCondition=null}return Object.defineProperty(t.prototype,"ngIf",{set:function(t){!t||!s.isBlank(this._prevCondition)&&this._prevCondition?t||!s.isBlank(this._prevCondition)&&!this._prevCondition||(this._prevCondition=!1,this._viewContainer.clear()):(this._prevCondition=!0,this._viewContainer.createEmbeddedView(this._templateRef))},enumerable:!0,configurable:!0}),t=r([o.Directive({selector:"[ngIf]",inputs:["ngIf"]}),i("design:paramtypes",[o.ViewContainerRef,o.TemplateRef])],t)}();e.NgIf=a},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(5),a=function(){function t(t){this._viewContainerRef=t}return Object.defineProperty(t.prototype,"ngTemplateOutlet",{set:function(t){s.isPresent(this._insertedViewRef)&&this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._insertedViewRef)),s.isPresent(t)&&(this._insertedViewRef=this._viewContainerRef.createEmbeddedView(t))},enumerable:!0,configurable:!0}),r([o.Input(),i("design:type",o.TemplateRef),i("design:paramtypes",[o.TemplateRef])],t.prototype,"ngTemplateOutlet",null),t=r([o.Directive({selector:"[ngTemplateOutlet]"}),i("design:paramtypes",[o.ViewContainerRef])],t)}();e.NgTemplateOutlet=a},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(5),a=function(){function t(t,e,n){this._differs=t,this._ngEl=e,this._renderer=n}return Object.defineProperty(t.prototype,"rawStyle",{set:function(t){this._rawStyle=t,s.isBlank(this._differ)&&s.isPresent(t)&&(this._differ=this._differs.find(this._rawStyle).create(null))},enumerable:!0,configurable:!0}),t.prototype.ngDoCheck=function(){if(s.isPresent(this._differ)){var t=this._differ.diff(this._rawStyle);s.isPresent(t)&&this._applyChanges(t)}},t.prototype._applyChanges=function(t){var e=this;t.forEachAddedItem(function(t){e._setStyle(t.key,t.currentValue)}),t.forEachChangedItem(function(t){e._setStyle(t.key,t.currentValue)}),t.forEachRemovedItem(function(t){e._setStyle(t.key,null)})},t.prototype._setStyle=function(t,e){this._renderer.setElementStyle(this._ngEl.nativeElement,t,e)},t=r([o.Directive({selector:"[ngStyle]",inputs:["rawStyle: ngStyle"]}),i("design:paramtypes",[o.KeyValueDiffers,o.ElementRef,o.Renderer])],t)}();e.NgStyle=a},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},s=n(2),a=n(5),u=n(15),c=a.CONST_EXPR(new Object),p=function(){function t(t,e){this._viewContainerRef=t,this._templateRef=e}return t.prototype.create=function(){this._viewContainerRef.createEmbeddedView(this._templateRef)},t.prototype.destroy=function(){this._viewContainerRef.clear()},t}();e.SwitchView=p;var l=function(){function t(){this._useDefault=!1,this._valueViews=new u.Map,this._activeViews=[]}return Object.defineProperty(t.prototype,"ngSwitch",{set:function(t){this._emptyAllActiveViews(),this._useDefault=!1;var e=this._valueViews.get(t);a.isBlank(e)&&(this._useDefault=!0,e=a.normalizeBlank(this._valueViews.get(c))),this._activateViews(e),this._switchValue=t},enumerable:!0,configurable:!0}),t.prototype._onWhenValueChanged=function(t,e,n){this._deregisterView(t,n),this._registerView(e,n),t===this._switchValue?(n.destroy(),u.ListWrapper.remove(this._activeViews,n)):e===this._switchValue&&(this._useDefault&&(this._useDefault=!1,this._emptyAllActiveViews()),n.create(),this._activeViews.push(n)),0!==this._activeViews.length||this._useDefault||(this._useDefault=!0,this._activateViews(this._valueViews.get(c)))},t.prototype._emptyAllActiveViews=function(){for(var t=this._activeViews,e=0;eo?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},s=n(2),a=n(5),u=n(15),c=n(108),p="other",l=function(){function t(){}return t}();e.NgLocalization=l;var h=function(){function t(t,e,n){this.value=t,this._view=new c.SwitchView(n,e)}return t=r([s.Directive({selector:"[ngPluralCase]"}),o(0,s.Attribute("ngPluralCase")),i("design:paramtypes",[String,s.TemplateRef,s.ViewContainerRef])],t)}();e.NgPluralCase=h;var f=function(){function t(t){this._localization=t,this._caseViews=new u.Map,this.cases=null}return Object.defineProperty(t.prototype,"ngPlural",{set:function(t){this._switchValue=t,this._updateView()},enumerable:!0,configurable:!0}),t.prototype.ngAfterContentInit=function(){var t=this;this.cases.forEach(function(e){t._caseViews.set(t._formatValue(e),e._view)}),this._updateView()},t.prototype._updateView=function(){this._clearViews();var t=this._caseViews.get(this._switchValue);a.isPresent(t)||(t=this._getCategoryView(this._switchValue)),this._activateView(t)},t.prototype._clearViews=function(){a.isPresent(this._activeView)&&this._activeView.destroy()},t.prototype._activateView=function(t){a.isPresent(t)&&(this._activeView=t,this._activeView.create())},t.prototype._getCategoryView=function(t){var e=this._localization.getPluralCategory(t),n=this._caseViews.get(e);return a.isPresent(n)?n:this._caseViews.get(p)},t.prototype._isValueView=function(t){return"="===t.value[0]},t.prototype._formatValue=function(t){return this._isValueView(t)?this._stripValue(t.value):t.value},t.prototype._stripValue=function(t){return a.NumberWrapper.parseInt(t.substring(1),10)},r([s.ContentChildren(h),i("design:type",s.QueryList)],t.prototype,"cases",void 0),r([s.Input(),i("design:type",Number),i("design:paramtypes",[Number])],t.prototype,"ngPlural",null),t=r([s.Directive({selector:"[ngPlural]"}),i("design:paramtypes",[l])],t)}();e.NgPlural=f},function(t,e){"use strict"},function(t,e,n){"use strict";var r=n(5),i=n(103),o=n(104),s=n(105),a=n(106),u=n(107),c=n(108),p=n(109);e.CORE_DIRECTIVES=r.CONST_EXPR([i.NgClass,o.NgFor,s.NgIf,a.NgTemplateOutlet,u.NgStyle,c.NgSwitch,c.NgSwitchWhen,c.NgSwitchDefault,p.NgPlural,p.NgPluralCase])},function(t,e,n){"use strict";var r=n(113);e.AbstractControl=r.AbstractControl,e.Control=r.Control,e.ControlGroup=r.ControlGroup,e.ControlArray=r.ControlArray;var i=n(114);e.AbstractControlDirective=i.AbstractControlDirective;var o=n(115);e.ControlContainer=o.ControlContainer;var s=n(116);e.NgControlName=s.NgControlName;var a=n(127);e.NgFormControl=a.NgFormControl;var u=n(128);e.NgModel=u.NgModel;var c=n(117);e.NgControl=c.NgControl;var p=n(129);e.NgControlGroup=p.NgControlGroup;var l=n(130);e.NgFormModel=l.NgFormModel;var h=n(131);e.NgForm=h.NgForm;var f=n(118);e.NG_VALUE_ACCESSOR=f.NG_VALUE_ACCESSOR;var d=n(121);e.DefaultValueAccessor=d.DefaultValueAccessor;var v=n(132);e.NgControlStatus=v.NgControlStatus;var y=n(123);e.CheckboxControlValueAccessor=y.CheckboxControlValueAccessor;var m=n(124);e.NgSelectOption=m.NgSelectOption,e.SelectControlValueAccessor=m.SelectControlValueAccessor;var g=n(133);e.FORM_DIRECTIVES=g.FORM_DIRECTIVES,e.RadioButtonState=g.RadioButtonState;var _=n(120);e.NG_VALIDATORS=_.NG_VALIDATORS,e.NG_ASYNC_VALIDATORS=_.NG_ASYNC_VALIDATORS,e.Validators=_.Validators;var b=n(134);e.RequiredValidator=b.RequiredValidator,e.MinLengthValidator=b.MinLengthValidator,e.MaxLengthValidator=b.MaxLengthValidator,e.PatternValidator=b.PatternValidator;var P=n(135);e.FormBuilder=P.FormBuilder;var E=n(135),w=n(125),C=n(5);e.FORM_PROVIDERS=C.CONST_EXPR([E.FormBuilder,w.RadioControlRegistry]),e.FORM_BINDINGS=e.FORM_PROVIDERS},function(t,e,n){"use strict";function r(t){return t instanceof l}function i(t,e){return a.isBlank(e)?null:(e instanceof Array||(e=e.split("/")),e instanceof Array&&p.ListWrapper.isEmpty(e)?null:e.reduce(function(t,e){if(t instanceof f)return a.isPresent(t.controls[e])?t.controls[e]:null;if(t instanceof d){var n=e;return a.isPresent(t.at(n))?t.at(n):null}return null},t))}function o(t){return c.PromiseWrapper.isPromise(t)?u.ObservableWrapper.fromPromise(t):t}var s=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},a=n(5),u=n(40),c=n(41),p=n(15);e.VALID="VALID",e.INVALID="INVALID",e.PENDING="PENDING",e.isControl=r;var l=function(){function t(t,e){this.validator=t,this.asyncValidator=e,this._pristine=!0,this._touched=!1}return Object.defineProperty(t.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this._status},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"valid",{get:function(){return this._status===e.VALID},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errors",{get:function(){return this._errors},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pristine",{get:function(){return this._pristine},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dirty",{get:function(){return!this.pristine},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touched",{get:function(){return this._touched},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"untouched",{get:function(){return!this._touched},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"valueChanges",{get:function(){return this._valueChanges},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"statusChanges",{get:function(){return this._statusChanges},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pending",{get:function(){return this._status==e.PENDING},enumerable:!0,configurable:!0}),t.prototype.markAsTouched=function(){this._touched=!0},t.prototype.markAsDirty=function(t){var e=(void 0===t?{}:t).onlySelf;e=a.normalizeBool(e),this._pristine=!1,a.isPresent(this._parent)&&!e&&this._parent.markAsDirty({onlySelf:e})},t.prototype.markAsPending=function(t){var n=(void 0===t?{}:t).onlySelf;n=a.normalizeBool(n),this._status=e.PENDING,a.isPresent(this._parent)&&!n&&this._parent.markAsPending({onlySelf:n})},t.prototype.setParent=function(t){this._parent=t},t.prototype.updateValueAndValidity=function(t){var n=void 0===t?{}:t,r=n.onlySelf,i=n.emitEvent;r=a.normalizeBool(r),i=a.isPresent(i)?i:!0,this._updateValue(),this._errors=this._runValidator(),this._status=this._calculateStatus(),(this._status==e.VALID||this._status==e.PENDING)&&this._runAsyncValidator(i),i&&(u.ObservableWrapper.callEmit(this._valueChanges,this._value),u.ObservableWrapper.callEmit(this._statusChanges,this._status)),a.isPresent(this._parent)&&!r&&this._parent.updateValueAndValidity({onlySelf:r,emitEvent:i})},t.prototype._runValidator=function(){return a.isPresent(this.validator)?this.validator(this):null},t.prototype._runAsyncValidator=function(t){var n=this;if(a.isPresent(this.asyncValidator)){this._status=e.PENDING,this._cancelExistingSubscription();var r=o(this.asyncValidator(this));this._asyncValidationSubscription=u.ObservableWrapper.subscribe(r,function(e){return n.setErrors(e,{emitEvent:t})})}},t.prototype._cancelExistingSubscription=function(){a.isPresent(this._asyncValidationSubscription)&&u.ObservableWrapper.dispose(this._asyncValidationSubscription)},t.prototype.setErrors=function(t,e){var n=(void 0===e?{}:e).emitEvent;n=a.isPresent(n)?n:!0,this._errors=t,this._status=this._calculateStatus(),n&&u.ObservableWrapper.callEmit(this._statusChanges,this._status),a.isPresent(this._parent)&&this._parent._updateControlsErrors()},t.prototype.find=function(t){return i(this,t)},t.prototype.getError=function(t,e){void 0===e&&(e=null);var n=a.isPresent(e)&&!p.ListWrapper.isEmpty(e)?this.find(e):this;return a.isPresent(n)&&a.isPresent(n._errors)?p.StringMapWrapper.get(n._errors,t):null},t.prototype.hasError=function(t,e){return void 0===e&&(e=null),a.isPresent(this.getError(t,e))},Object.defineProperty(t.prototype,"root",{get:function(){for(var t=this;a.isPresent(t._parent);)t=t._parent;return t},enumerable:!0,configurable:!0}),t.prototype._updateControlsErrors=function(){this._status=this._calculateStatus(),a.isPresent(this._parent)&&this._parent._updateControlsErrors()},t.prototype._initObservables=function(){this._valueChanges=new u.EventEmitter,this._statusChanges=new u.EventEmitter},t.prototype._calculateStatus=function(){return a.isPresent(this._errors)?e.INVALID:this._anyControlsHaveStatus(e.PENDING)?e.PENDING:this._anyControlsHaveStatus(e.INVALID)?e.INVALID:e.VALID},t}();e.AbstractControl=l;var h=function(t){function e(e,n,r){void 0===e&&(e=null),void 0===n&&(n=null),void 0===r&&(r=null),t.call(this,n,r),this._value=e,this.updateValueAndValidity({onlySelf:!0,emitEvent:!1}),this._initObservables()}return s(e,t),e.prototype.updateValue=function(t,e){var n=void 0===e?{}:e,r=n.onlySelf,i=n.emitEvent,o=n.emitModelToViewChange;o=a.isPresent(o)?o:!0,this._value=t,a.isPresent(this._onChange)&&o&&this._onChange(this._value),this.updateValueAndValidity({onlySelf:r,emitEvent:i})},e.prototype._updateValue=function(){},e.prototype._anyControlsHaveStatus=function(t){return!1},e.prototype.registerOnChange=function(t){this._onChange=t},e}(l);e.Control=h;var f=function(t){function e(e,n,r,i){void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),t.call(this,r,i),this.controls=e,this._optionals=a.isPresent(n)?n:{},this._initObservables(),this._setParentForControls(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!1})}return s(e,t),e.prototype.addControl=function(t,e){this.controls[t]=e,e.setParent(this)},e.prototype.removeControl=function(t){p.StringMapWrapper["delete"](this.controls,t)},e.prototype.include=function(t){p.StringMapWrapper.set(this._optionals,t,!0),this.updateValueAndValidity()},e.prototype.exclude=function(t){p.StringMapWrapper.set(this._optionals,t,!1),this.updateValueAndValidity()},e.prototype.contains=function(t){var e=p.StringMapWrapper.contains(this.controls,t);return e&&this._included(t)},e.prototype._setParentForControls=function(){var t=this;p.StringMapWrapper.forEach(this.controls,function(e,n){e.setParent(t)})},e.prototype._updateValue=function(){this._value=this._reduceValue()},e.prototype._anyControlsHaveStatus=function(t){var e=this,n=!1;return p.StringMapWrapper.forEach(this.controls,function(r,i){n=n||e.contains(i)&&r.status==t}),n},e.prototype._reduceValue=function(){return this._reduceChildren({},function(t,e,n){return t[n]=e.value,t})},e.prototype._reduceChildren=function(t,e){var n=this,r=t;return p.StringMapWrapper.forEach(this.controls,function(t,i){n._included(i)&&(r=e(r,t,i))}),r},e.prototype._included=function(t){var e=p.StringMapWrapper.contains(this._optionals,t);return!e||p.StringMapWrapper.get(this._optionals,t)},e}(l);e.ControlGroup=f;var d=function(t){function e(e,n,r){void 0===n&&(n=null),void 0===r&&(r=null),t.call(this,n,r),this.controls=e,this._initObservables(),this._setParentForControls(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!1})}return s(e,t),e.prototype.at=function(t){return this.controls[t]},e.prototype.push=function(t){this.controls.push(t),t.setParent(this),this.updateValueAndValidity()},e.prototype.insert=function(t,e){p.ListWrapper.insert(this.controls,t,e),e.setParent(this),this.updateValueAndValidity()},e.prototype.removeAt=function(t){p.ListWrapper.removeAt(this.controls,t),this.updateValueAndValidity()},Object.defineProperty(e.prototype,"length",{get:function(){return this.controls.length},enumerable:!0,configurable:!0}),e.prototype._updateValue=function(){this._value=this.controls.map(function(t){return t.value})},e.prototype._anyControlsHaveStatus=function(t){return this.controls.some(function(e){return e.status==t})},e.prototype._setParentForControls=function(){var t=this;this.controls.forEach(function(e){e.setParent(t)})},e}(l);e.ControlArray=d},function(t,e,n){"use strict";var r=n(5),i=n(12),o=function(){function t(){}return Object.defineProperty(t.prototype,"control",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return r.isPresent(this.control)?this.control.value:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"valid",{get:function(){return r.isPresent(this.control)?this.control.valid:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errors",{get:function(){return r.isPresent(this.control)?this.control.errors:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pristine",{get:function(){return r.isPresent(this.control)?this.control.pristine:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dirty",{get:function(){return r.isPresent(this.control)?this.control.dirty:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touched",{get:function(){return r.isPresent(this.control)?this.control.touched:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"untouched",{get:function(){return r.isPresent(this.control)?this.control.untouched:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return null},enumerable:!0,configurable:!0}),t}();e.AbstractControlDirective=o},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(114),o=function(t){function e(){t.apply(this,arguments)}return r(e,t),Object.defineProperty(e.prototype,"formDirective",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return null},enumerable:!0,configurable:!0}),e}(i.AbstractControlDirective);e.ControlContainer=o},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(5),u=n(40),c=n(2),p=n(115),l=n(117),h=n(118),f=n(119),d=n(120),v=a.CONST_EXPR(new c.Provider(l.NgControl,{useExisting:c.forwardRef(function(){return y})})),y=function(t){function e(e,n,r,i){t.call(this),this._parent=e,this._validators=n,this._asyncValidators=r,this.update=new u.EventEmitter,this._added=!1,this.valueAccessor=f.selectValueAccessor(this,i)}return r(e,t),e.prototype.ngOnChanges=function(t){this._added||(this.formDirective.addControl(this),this._added=!0),f.isPropertyUpdated(t,this.viewModel)&&(this.viewModel=this.model,this.formDirective.updateModel(this,this.model))},e.prototype.ngOnDestroy=function(){this.formDirective.removeControl(this)},e.prototype.viewToModelUpdate=function(t){this.viewModel=t,u.ObservableWrapper.callEmit(this.update,t)},Object.defineProperty(e.prototype,"path",{get:function(){return f.controlPath(this.name,this._parent)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formDirective",{get:function(){return this._parent.formDirective},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validator",{get:function(){return f.composeValidators(this._validators)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"asyncValidator",{get:function(){return f.composeAsyncValidators(this._asyncValidators)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"control",{get:function(){return this.formDirective.getControl(this)},enumerable:!0,configurable:!0}),e=i([c.Directive({selector:"[ngControl]",bindings:[v],inputs:["name: ngControl","model: ngModel"],outputs:["update: ngModelChange"],exportAs:"ngForm"}),s(0,c.Host()),s(0,c.SkipSelf()),s(1,c.Optional()),s(1,c.Self()),s(1,c.Inject(d.NG_VALIDATORS)),s(2,c.Optional()),s(2,c.Self()),s(2,c.Inject(d.NG_ASYNC_VALIDATORS)),s(3,c.Optional()),s(3,c.Self()),s(3,c.Inject(h.NG_VALUE_ACCESSOR)),o("design:paramtypes",[p.ControlContainer,Array,Array,Array])],e)}(l.NgControl);e.NgControlName=y},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(114),o=n(12),s=function(t){function e(){t.apply(this,arguments),this.name=null,this.valueAccessor=null}return r(e,t),Object.defineProperty(e.prototype,"validator",{get:function(){return o.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"asyncValidator",{get:function(){return o.unimplemented()},enumerable:!0,configurable:!0}),e}(i.AbstractControlDirective);e.NgControl=s},function(t,e,n){"use strict";var r=n(2),i=n(5);e.NG_VALUE_ACCESSOR=i.CONST_EXPR(new r.OpaqueToken("NgValueAccessor"))},function(t,e,n){"use strict";function r(t,e){var n=l.ListWrapper.clone(e.path);return n.push(t),n}function i(t,e){h.isBlank(t)&&s(e,"Cannot find control"),h.isBlank(e.valueAccessor)&&s(e,"No value accessor for"),t.validator=d.Validators.compose([t.validator,e.validator]),t.asyncValidator=d.Validators.composeAsync([t.asyncValidator,e.asyncValidator]),e.valueAccessor.writeValue(t.value),e.valueAccessor.registerOnChange(function(n){e.viewToModelUpdate(n),t.updateValue(n,{emitModelToViewChange:!1}),t.markAsDirty()}),t.registerOnChange(function(t){return e.valueAccessor.writeValue(t)}),e.valueAccessor.registerOnTouched(function(){return t.markAsTouched()})}function o(t,e){h.isBlank(t)&&s(e,"Cannot find control"),t.validator=d.Validators.compose([t.validator,e.validator]),t.asyncValidator=d.Validators.composeAsync([t.asyncValidator,e.asyncValidator])}function s(t,e){var n=t.path.join(" -> ");throw new f.BaseException(e+" '"+n+"'")}function a(t){return h.isPresent(t)?d.Validators.compose(t.map(b.normalizeValidator)):null}function u(t){return h.isPresent(t)?d.Validators.composeAsync(t.map(b.normalizeAsyncValidator)):null}function c(t,e){if(!l.StringMapWrapper.contains(t,"model"))return!1;var n=t.model;return n.isFirstChange()?!0:!h.looseIdentical(e,n.currentValue)}function p(t,e){if(h.isBlank(e))return null;var n,r,i;return e.forEach(function(e){h.hasConstructor(e,v.DefaultValueAccessor)?n=e:h.hasConstructor(e,m.CheckboxControlValueAccessor)||h.hasConstructor(e,y.NumberValueAccessor)||h.hasConstructor(e,g.SelectControlValueAccessor)||h.hasConstructor(e,_.RadioControlValueAccessor)?(h.isPresent(r)&&s(t,"More than one built-in value accessor matches"),r=e):(h.isPresent(i)&&s(t,"More than one custom value accessor matches"),i=e)}),h.isPresent(i)?i:h.isPresent(r)?r:h.isPresent(n)?n:(s(t,"No valid value accessor for"),null)}var l=n(15),h=n(5),f=n(12),d=n(120),v=n(121),y=n(122),m=n(123),g=n(124),_=n(125),b=n(126);e.controlPath=r,e.setUpControl=i,e.setUpControlGroup=o,e.composeValidators=a,e.composeAsyncValidators=u,e.isPropertyUpdated=c,e.selectValueAccessor=p},function(t,e,n){"use strict";function r(t){return u.PromiseWrapper.isPromise(t)?t:c.ObservableWrapper.toPromise(t)}function i(t,e){return e.map(function(e){return e(t)})}function o(t,e){return e.map(function(e){return e(t)})}function s(t){var e=t.reduce(function(t,e){return a.isPresent(e)?p.StringMapWrapper.merge(t,e):t},{});return p.StringMapWrapper.isEmpty(e)?null:e}var a=n(5),u=n(41),c=n(40),p=n(15),l=n(2);e.NG_VALIDATORS=a.CONST_EXPR(new l.OpaqueToken("NgValidators")),e.NG_ASYNC_VALIDATORS=a.CONST_EXPR(new l.OpaqueToken("NgAsyncValidators"));var h=function(){function t(){}return t.required=function(t){return a.isBlank(t.value)||a.isString(t.value)&&""==t.value?{required:!0}:null},t.minLength=function(e){return function(n){if(a.isPresent(t.required(n)))return null;var r=n.value;return r.lengthe?{maxlength:{requiredLength:e,actualLength:r.length}}:null}},t.pattern=function(e){return function(n){if(a.isPresent(t.required(n)))return null;var r=new RegExp("^"+e+"$"),i=n.value;return r.test(i)?null:{pattern:{requiredPattern:"^"+e+"$",actualValue:i}}}},t.nullValidator=function(t){return null},t.compose=function(t){if(a.isBlank(t))return null;var e=t.filter(a.isPresent);return 0==e.length?null:function(t){return s(i(t,e))}},t.composeAsync=function(t){if(a.isBlank(t))return null;var e=t.filter(a.isPresent);return 0==e.length?null:function(t){var n=o(t,e).map(r);return u.PromiseWrapper.all(n).then(s)}},t}();e.Validators=h},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(118),a=n(5),u=a.CONST_EXPR(new o.Provider(s.NG_VALUE_ACCESSOR,{useExisting:o.forwardRef(function(){return c}),multi:!0})),c=function(){function t(t,e){this._renderer=t,this._elementRef=e,this.onChange=function(t){},this.onTouched=function(){}}return t.prototype.writeValue=function(t){var e=a.isBlank(t)?"":t;this._renderer.setElementProperty(this._elementRef.nativeElement,"value",e)},t.prototype.registerOnChange=function(t){this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t=r([o.Directive({selector:"input:not([type=checkbox])[ngControl],textarea[ngControl],input:not([type=checkbox])[ngFormControl],textarea[ngFormControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]", -host:{"(input)":"onChange($event.target.value)","(blur)":"onTouched()"},bindings:[u]}),i("design:paramtypes",[o.Renderer,o.ElementRef])],t)}();e.DefaultValueAccessor=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(118),a=n(5),u=a.CONST_EXPR(new o.Provider(s.NG_VALUE_ACCESSOR,{useExisting:o.forwardRef(function(){return c}),multi:!0})),c=function(){function t(t,e){this._renderer=t,this._elementRef=e,this.onChange=function(t){},this.onTouched=function(){}}return t.prototype.writeValue=function(t){this._renderer.setElementProperty(this._elementRef.nativeElement,"value",t)},t.prototype.registerOnChange=function(t){this.onChange=function(e){t(""==e?null:a.NumberWrapper.parseFloat(e))}},t.prototype.registerOnTouched=function(t){this.onTouched=t},t=r([o.Directive({selector:"input[type=number][ngControl],input[type=number][ngFormControl],input[type=number][ngModel]",host:{"(change)":"onChange($event.target.value)","(input)":"onChange($event.target.value)","(blur)":"onTouched()"},bindings:[u]}),i("design:paramtypes",[o.Renderer,o.ElementRef])],t)}();e.NumberValueAccessor=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(118),a=n(5),u=a.CONST_EXPR(new o.Provider(s.NG_VALUE_ACCESSOR,{useExisting:o.forwardRef(function(){return c}),multi:!0})),c=function(){function t(t,e){this._renderer=t,this._elementRef=e,this.onChange=function(t){},this.onTouched=function(){}}return t.prototype.writeValue=function(t){this._renderer.setElementProperty(this._elementRef.nativeElement,"checked",t)},t.prototype.registerOnChange=function(t){this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t=r([o.Directive({selector:"input[type=checkbox][ngControl],input[type=checkbox][ngFormControl],input[type=checkbox][ngModel]",host:{"(change)":"onChange($event.target.checked)","(blur)":"onTouched()"},providers:[u]}),i("design:paramtypes",[o.Renderer,o.ElementRef])],t)}();e.CheckboxControlValueAccessor=c},function(t,e,n){"use strict";function r(t,e){return p.isBlank(t)?""+e:(p.isPrimitive(e)||(e="Object"),p.StringWrapper.slice(t+": "+e,0,50))}function i(t){return t.split(":")[0]}var o=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},s=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},a=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},u=n(2),c=n(118),p=n(5),l=n(15),h=p.CONST_EXPR(new u.Provider(c.NG_VALUE_ACCESSOR,{useExisting:u.forwardRef(function(){return f}),multi:!0})),f=function(){function t(t,e){this._renderer=t,this._elementRef=e,this._optionMap=new Map,this._idCounter=0,this.onChange=function(t){},this.onTouched=function(){}}return t.prototype.writeValue=function(t){this.value=t;var e=r(this._getOptionId(t),t);this._renderer.setElementProperty(this._elementRef.nativeElement,"value",e)},t.prototype.registerOnChange=function(t){var e=this;this.onChange=function(n){t(e._getOptionValue(n))}},t.prototype.registerOnTouched=function(t){this.onTouched=t},t.prototype._registerOption=function(){return(this._idCounter++).toString()},t.prototype._getOptionId=function(t){for(var e=0,n=l.MapWrapper.keys(this._optionMap);eo?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(118),a=n(117),u=n(5),c=n(15),p=u.CONST_EXPR(new o.Provider(s.NG_VALUE_ACCESSOR,{useExisting:o.forwardRef(function(){return f}),multi:!0})),l=function(){function t(){this._accessors=[]}return t.prototype.add=function(t,e){this._accessors.push([t,e])},t.prototype.remove=function(t){for(var e=-1,n=0;no?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(5),u=n(15),c=n(40),p=n(2),l=n(117),h=n(120),f=n(118),d=n(119),v=a.CONST_EXPR(new p.Provider(l.NgControl,{useExisting:p.forwardRef(function(){return y})})),y=function(t){function e(e,n,r){t.call(this),this._validators=e,this._asyncValidators=n,this.update=new c.EventEmitter,this.valueAccessor=d.selectValueAccessor(this,r)}return r(e,t),e.prototype.ngOnChanges=function(t){this._isControlChanged(t)&&(d.setUpControl(this.form,this),this.form.updateValueAndValidity({emitEvent:!1})),d.isPropertyUpdated(t,this.viewModel)&&(this.form.updateValue(this.model),this.viewModel=this.model)},Object.defineProperty(e.prototype,"path",{get:function(){return[]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validator",{get:function(){return d.composeValidators(this._validators)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"asyncValidator",{get:function(){return d.composeAsyncValidators(this._asyncValidators)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"control",{get:function(){return this.form},enumerable:!0,configurable:!0}),e.prototype.viewToModelUpdate=function(t){this.viewModel=t,c.ObservableWrapper.callEmit(this.update,t)},e.prototype._isControlChanged=function(t){return u.StringMapWrapper.contains(t,"form")},e=i([p.Directive({selector:"[ngFormControl]",bindings:[v],inputs:["form: ngFormControl","model: ngModel"],outputs:["update: ngModelChange"],exportAs:"ngForm"}),s(0,p.Optional()),s(0,p.Self()),s(0,p.Inject(h.NG_VALIDATORS)),s(1,p.Optional()),s(1,p.Self()),s(1,p.Inject(h.NG_ASYNC_VALIDATORS)),s(2,p.Optional()),s(2,p.Self()),s(2,p.Inject(f.NG_VALUE_ACCESSOR)),o("design:paramtypes",[Array,Array,Array])],e)}(l.NgControl);e.NgFormControl=y},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(5),u=n(40),c=n(2),p=n(118),l=n(117),h=n(113),f=n(120),d=n(119),v=a.CONST_EXPR(new c.Provider(l.NgControl,{useExisting:c.forwardRef(function(){return y})})),y=function(t){function e(e,n,r){t.call(this),this._validators=e,this._asyncValidators=n,this._control=new h.Control,this._added=!1,this.update=new u.EventEmitter,this.valueAccessor=d.selectValueAccessor(this,r)}return r(e,t),e.prototype.ngOnChanges=function(t){this._added||(d.setUpControl(this._control,this),this._control.updateValueAndValidity({emitEvent:!1}),this._added=!0),d.isPropertyUpdated(t,this.viewModel)&&(this._control.updateValue(this.model),this.viewModel=this.model)},Object.defineProperty(e.prototype,"control",{get:function(){return this._control},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return[]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validator",{get:function(){return d.composeValidators(this._validators)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"asyncValidator",{get:function(){return d.composeAsyncValidators(this._asyncValidators)},enumerable:!0,configurable:!0}),e.prototype.viewToModelUpdate=function(t){this.viewModel=t,u.ObservableWrapper.callEmit(this.update,t)},e=i([c.Directive({selector:"[ngModel]:not([ngControl]):not([ngFormControl])",bindings:[v],inputs:["model: ngModel"],outputs:["update: ngModelChange"],exportAs:"ngForm"}),s(0,c.Optional()),s(0,c.Self()),s(0,c.Inject(f.NG_VALIDATORS)),s(1,c.Optional()),s(1,c.Self()),s(1,c.Inject(f.NG_ASYNC_VALIDATORS)),s(2,c.Optional()),s(2,c.Self()),s(2,c.Inject(p.NG_VALUE_ACCESSOR)),o("design:paramtypes",[Array,Array,Array])],e)}(l.NgControl);e.NgModel=y},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(2),u=n(5),c=n(115),p=n(119),l=n(120),h=u.CONST_EXPR(new a.Provider(c.ControlContainer,{useExisting:a.forwardRef(function(){return f})})),f=function(t){function e(e,n,r){t.call(this),this._validators=n,this._asyncValidators=r,this._parent=e}return r(e,t),e.prototype.ngOnInit=function(){this.formDirective.addControlGroup(this)},e.prototype.ngOnDestroy=function(){this.formDirective.removeControlGroup(this)},Object.defineProperty(e.prototype,"control",{get:function(){return this.formDirective.getControlGroup(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return p.controlPath(this.name,this._parent)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formDirective",{get:function(){return this._parent.formDirective},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"validator",{get:function(){return p.composeValidators(this._validators)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"asyncValidator",{get:function(){return p.composeAsyncValidators(this._asyncValidators)},enumerable:!0,configurable:!0}),e=i([a.Directive({selector:"[ngControlGroup]",providers:[h],inputs:["name: ngControlGroup"],exportAs:"ngForm"}),s(0,a.Host()),s(0,a.SkipSelf()),s(1,a.Optional()),s(1,a.Self()),s(1,a.Inject(l.NG_VALIDATORS)),s(2,a.Optional()),s(2,a.Self()),s(2,a.Inject(l.NG_ASYNC_VALIDATORS)),o("design:paramtypes",[c.ControlContainer,Array,Array])],e)}(c.ControlContainer);e.NgControlGroup=f},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(5),u=n(15),c=n(12),p=n(40),l=n(2),h=n(115),f=n(119),d=n(120),v=a.CONST_EXPR(new l.Provider(h.ControlContainer,{useExisting:l.forwardRef(function(){return y})})),y=function(t){function e(e,n){t.call(this),this._validators=e,this._asyncValidators=n,this.form=null,this.directives=[],this.ngSubmit=new p.EventEmitter}return r(e,t),e.prototype.ngOnChanges=function(t){if(this._checkFormPresent(),u.StringMapWrapper.contains(t,"form")){var e=f.composeValidators(this._validators);this.form.validator=d.Validators.compose([this.form.validator,e]);var n=f.composeAsyncValidators(this._asyncValidators);this.form.asyncValidator=d.Validators.composeAsync([this.form.asyncValidator,n]),this.form.updateValueAndValidity({onlySelf:!0,emitEvent:!1})}this._updateDomValue()},Object.defineProperty(e.prototype,"formDirective",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"control",{get:function(){return this.form},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return[]},enumerable:!0,configurable:!0}),e.prototype.addControl=function(t){var e=this.form.find(t.path);f.setUpControl(e,t),e.updateValueAndValidity({emitEvent:!1}),this.directives.push(t)},e.prototype.getControl=function(t){return this.form.find(t.path)},e.prototype.removeControl=function(t){u.ListWrapper.remove(this.directives,t)},e.prototype.addControlGroup=function(t){var e=this.form.find(t.path);f.setUpControlGroup(e,t),e.updateValueAndValidity({emitEvent:!1})},e.prototype.removeControlGroup=function(t){},e.prototype.getControlGroup=function(t){return this.form.find(t.path)},e.prototype.updateModel=function(t,e){var n=this.form.find(t.path);n.updateValue(e)},e.prototype.onSubmit=function(){return p.ObservableWrapper.callEmit(this.ngSubmit,null),!1},e.prototype._updateDomValue=function(){var t=this;this.directives.forEach(function(e){var n=t.form.find(e.path);e.valueAccessor.writeValue(n.value)})},e.prototype._checkFormPresent=function(){if(a.isBlank(this.form))throw new c.BaseException('ngFormModel expects a form. Please pass one in. Example:
')},e=i([l.Directive({selector:"[ngFormModel]",bindings:[v],inputs:["form: ngFormModel"],host:{"(submit)":"onSubmit()"},outputs:["ngSubmit"],exportAs:"ngForm"}),s(0,l.Optional()),s(0,l.Self()),s(0,l.Inject(d.NG_VALIDATORS)),s(1,l.Optional()),s(1,l.Self()),s(1,l.Inject(d.NG_ASYNC_VALIDATORS)),o("design:paramtypes",[Array,Array])],e)}(h.ControlContainer);e.NgFormModel=y},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(40),u=n(15),c=n(5),p=n(2),l=n(115),h=n(113),f=n(119),d=n(120),v=c.CONST_EXPR(new p.Provider(l.ControlContainer,{useExisting:p.forwardRef(function(){return y})})),y=function(t){function e(e,n){t.call(this),this.ngSubmit=new a.EventEmitter,this.form=new h.ControlGroup({},null,f.composeValidators(e),f.composeAsyncValidators(n))}return r(e,t),Object.defineProperty(e.prototype,"formDirective",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"control",{get:function(){return this.form},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return[]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controls",{get:function(){return this.form.controls},enumerable:!0,configurable:!0}),e.prototype.addControl=function(t){var e=this;a.PromiseWrapper.scheduleMicrotask(function(){var n=e._findContainer(t.path),r=new h.Control;f.setUpControl(r,t),n.addControl(t.name,r),r.updateValueAndValidity({emitEvent:!1})})},e.prototype.getControl=function(t){return this.form.find(t.path)},e.prototype.removeControl=function(t){var e=this;a.PromiseWrapper.scheduleMicrotask(function(){var n=e._findContainer(t.path);c.isPresent(n)&&(n.removeControl(t.name),n.updateValueAndValidity({emitEvent:!1}))})},e.prototype.addControlGroup=function(t){var e=this;a.PromiseWrapper.scheduleMicrotask(function(){var n=e._findContainer(t.path),r=new h.ControlGroup({});f.setUpControlGroup(r,t),n.addControl(t.name,r),r.updateValueAndValidity({emitEvent:!1})})},e.prototype.removeControlGroup=function(t){var e=this;a.PromiseWrapper.scheduleMicrotask(function(){var n=e._findContainer(t.path);c.isPresent(n)&&(n.removeControl(t.name),n.updateValueAndValidity({emitEvent:!1}))})},e.prototype.getControlGroup=function(t){return this.form.find(t.path)},e.prototype.updateModel=function(t,e){var n=this;a.PromiseWrapper.scheduleMicrotask(function(){var r=n.form.find(t.path);r.updateValue(e)})},e.prototype.onSubmit=function(){return a.ObservableWrapper.callEmit(this.ngSubmit,null),!1},e.prototype._findContainer=function(t){return t.pop(),u.ListWrapper.isEmpty(t)?this.form:this.form.find(t)},e=i([p.Directive({selector:"form:not([ngNoForm]):not([ngFormModel]),ngForm,[ngForm]",bindings:[v],host:{"(submit)":"onSubmit()"},outputs:["ngSubmit"],exportAs:"ngForm"}),s(0,p.Optional()),s(0,p.Self()),s(0,p.Inject(d.NG_VALIDATORS)),s(1,p.Optional()),s(1,p.Self()),s(1,p.Inject(d.NG_ASYNC_VALIDATORS)),o("design:paramtypes",[Array,Array])],e)}(l.ControlContainer);e.NgForm=y},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},s=n(2),a=n(117),u=n(5),c=function(){function t(t){this._cd=t}return Object.defineProperty(t.prototype,"ngClassUntouched",{get:function(){return u.isPresent(this._cd.control)?this._cd.control.untouched:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngClassTouched",{get:function(){return u.isPresent(this._cd.control)?this._cd.control.touched:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngClassPristine",{get:function(){return u.isPresent(this._cd.control)?this._cd.control.pristine:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngClassDirty",{get:function(){return u.isPresent(this._cd.control)?this._cd.control.dirty:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngClassValid",{get:function(){return u.isPresent(this._cd.control)?this._cd.control.valid:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngClassInvalid",{get:function(){return u.isPresent(this._cd.control)?!this._cd.control.valid:!1},enumerable:!0,configurable:!0}),t=r([s.Directive({selector:"[ngControl],[ngModel],[ngFormControl]",host:{"[class.ng-untouched]":"ngClassUntouched","[class.ng-touched]":"ngClassTouched","[class.ng-pristine]":"ngClassPristine","[class.ng-dirty]":"ngClassDirty","[class.ng-valid]":"ngClassValid","[class.ng-invalid]":"ngClassInvalid"}}),o(0,s.Self()),i("design:paramtypes",[a.NgControl])],t)}();e.NgControlStatus=c},function(t,e,n){"use strict";var r=n(5),i=n(116),o=n(127),s=n(128),a=n(129),u=n(130),c=n(131),p=n(121),l=n(123),h=n(122),f=n(125),d=n(132),v=n(124),y=n(134),m=n(116);e.NgControlName=m.NgControlName;var g=n(127);e.NgFormControl=g.NgFormControl;var _=n(128);e.NgModel=_.NgModel;var b=n(129);e.NgControlGroup=b.NgControlGroup;var P=n(130);e.NgFormModel=P.NgFormModel;var E=n(131);e.NgForm=E.NgForm;var w=n(121);e.DefaultValueAccessor=w.DefaultValueAccessor;var C=n(123);e.CheckboxControlValueAccessor=C.CheckboxControlValueAccessor;var R=n(125);e.RadioControlValueAccessor=R.RadioControlValueAccessor,e.RadioButtonState=R.RadioButtonState;var S=n(122);e.NumberValueAccessor=S.NumberValueAccessor;var O=n(132);e.NgControlStatus=O.NgControlStatus;var T=n(124);e.SelectControlValueAccessor=T.SelectControlValueAccessor,e.NgSelectOption=T.NgSelectOption;var x=n(134);e.RequiredValidator=x.RequiredValidator,e.MinLengthValidator=x.MinLengthValidator,e.MaxLengthValidator=x.MaxLengthValidator,e.PatternValidator=x.PatternValidator;var A=n(117);e.NgControl=A.NgControl,e.FORM_DIRECTIVES=r.CONST_EXPR([i.NgControlName,a.NgControlGroup,o.NgFormControl,s.NgModel,u.NgFormModel,c.NgForm,v.NgSelectOption,p.DefaultValueAccessor,h.NumberValueAccessor,l.CheckboxControlValueAccessor,v.SelectControlValueAccessor,f.RadioControlValueAccessor,d.NgControlStatus,y.RequiredValidator,y.MinLengthValidator,y.MaxLengthValidator,y.PatternValidator])},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},s=n(2),a=n(5),u=n(120),c=n(5),p=u.Validators.required,l=a.CONST_EXPR(new s.Provider(u.NG_VALIDATORS,{useValue:p,multi:!0})),h=function(){function t(){}return t=r([s.Directive({selector:"[required][ngControl],[required][ngFormControl],[required][ngModel]",providers:[l]}),i("design:paramtypes",[])],t)}();e.RequiredValidator=h;var f=a.CONST_EXPR(new s.Provider(u.NG_VALIDATORS,{useExisting:s.forwardRef(function(){return d}),multi:!0})),d=function(){function t(t){this._validator=u.Validators.minLength(c.NumberWrapper.parseInt(t,10))}return t.prototype.validate=function(t){return this._validator(t)},t=r([s.Directive({selector:"[minlength][ngControl],[minlength][ngFormControl],[minlength][ngModel]",providers:[f]}),o(0,s.Attribute("minlength")),i("design:paramtypes",[String])],t)}();e.MinLengthValidator=d;var v=a.CONST_EXPR(new s.Provider(u.NG_VALIDATORS,{useExisting:s.forwardRef(function(){return y}),multi:!0})),y=function(){function t(t){this._validator=u.Validators.maxLength(c.NumberWrapper.parseInt(t,10))}return t.prototype.validate=function(t){return this._validator(t)},t=r([s.Directive({selector:"[maxlength][ngControl],[maxlength][ngFormControl],[maxlength][ngModel]",providers:[v]}),o(0,s.Attribute("maxlength")),i("design:paramtypes",[String])],t)}();e.MaxLengthValidator=y;var m=a.CONST_EXPR(new s.Provider(u.NG_VALIDATORS,{useExisting:s.forwardRef(function(){return g}),multi:!0})),g=function(){function t(t){this._validator=u.Validators.pattern(t)}return t.prototype.validate=function(t){return this._validator(t)},t=r([s.Directive({selector:"[pattern][ngControl],[pattern][ngFormControl],[pattern][ngModel]",providers:[m]}),o(0,s.Attribute("pattern")),i("design:paramtypes",[String])],t)}();e.PatternValidator=g},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(15),a=n(5),u=n(113),c=function(){function t(){}return t.prototype.group=function(t,e){void 0===e&&(e=null);var n=this._reduceControls(t),r=a.isPresent(e)?s.StringMapWrapper.get(e,"optionals"):null,i=a.isPresent(e)?s.StringMapWrapper.get(e,"validator"):null,o=a.isPresent(e)?s.StringMapWrapper.get(e,"asyncValidator"):null;return new u.ControlGroup(n,r,i,o)},t.prototype.control=function(t,e,n){return void 0===e&&(e=null),void 0===n&&(n=null),new u.Control(t,e,n)},t.prototype.array=function(t,e,n){var r=this;void 0===e&&(e=null),void 0===n&&(n=null);var i=t.map(function(t){return r._createControl(t)});return new u.ControlArray(i,e,n)},t.prototype._reduceControls=function(t){var e=this,n={};return s.StringMapWrapper.forEach(t,function(t,r){n[r]=e._createControl(t)}),n},t.prototype._createControl=function(t){if(t instanceof u.Control||t instanceof u.ControlGroup||t instanceof u.ControlArray)return t;if(a.isArray(t)){var e=t[0],n=t.length>1?t[1]:null,r=t.length>2?t[2]:null;return this.control(e,n,r)}return this.control(t)},t=r([o.Injectable(),i("design:paramtypes",[])],t)}();e.FormBuilder=c},function(t,e,n){"use strict";var r=n(5),i=n(112),o=n(102);e.COMMON_DIRECTIVES=r.CONST_EXPR([o.CORE_DIRECTIVES,i.FORM_DIRECTIVES])},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var i=n(138);e.PLATFORM_DIRECTIVES=i.PLATFORM_DIRECTIVES,e.PLATFORM_PIPES=i.PLATFORM_PIPES,e.COMPILER_PROVIDERS=i.COMPILER_PROVIDERS,e.TEMPLATE_TRANSFORMS=i.TEMPLATE_TRANSFORMS,e.CompilerConfig=i.CompilerConfig,e.RenderTypes=i.RenderTypes,e.UrlResolver=i.UrlResolver,e.DEFAULT_PACKAGE_URL_PROVIDER=i.DEFAULT_PACKAGE_URL_PROVIDER,e.createOfflineCompileUrlResolver=i.createOfflineCompileUrlResolver,e.XHR=i.XHR,e.ViewResolver=i.ViewResolver,e.DirectiveResolver=i.DirectiveResolver,e.PipeResolver=i.PipeResolver,e.SourceModule=i.SourceModule,e.NormalizedComponentWithViewDirectives=i.NormalizedComponentWithViewDirectives,e.OfflineCompiler=i.OfflineCompiler,e.CompileMetadataWithIdentifier=i.CompileMetadataWithIdentifier,e.CompileMetadataWithType=i.CompileMetadataWithType,e.CompileIdentifierMetadata=i.CompileIdentifierMetadata,e.CompileDiDependencyMetadata=i.CompileDiDependencyMetadata,e.CompileProviderMetadata=i.CompileProviderMetadata,e.CompileFactoryMetadata=i.CompileFactoryMetadata,e.CompileTokenMetadata=i.CompileTokenMetadata,e.CompileTypeMetadata=i.CompileTypeMetadata,e.CompileQueryMetadata=i.CompileQueryMetadata,e.CompileTemplateMetadata=i.CompileTemplateMetadata,e.CompileDirectiveMetadata=i.CompileDirectiveMetadata,e.CompilePipeMetadata=i.CompilePipeMetadata,r(n(139))},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}function i(){return new b.CompilerConfig(h.assertionsEnabled(),!1,!0)}var o=n(84);e.PLATFORM_DIRECTIVES=o.PLATFORM_DIRECTIVES,e.PLATFORM_PIPES=o.PLATFORM_PIPES,r(n(139));var s=n(140);e.TEMPLATE_TRANSFORMS=s.TEMPLATE_TRANSFORMS;var a=n(162);e.CompilerConfig=a.CompilerConfig,e.RenderTypes=a.RenderTypes,r(n(155)),r(n(163));var u=n(165);e.RuntimeCompiler=u.RuntimeCompiler,r(n(157)),r(n(184));var c=n(188);e.ViewResolver=c.ViewResolver;var p=n(186); -e.DirectiveResolver=p.DirectiveResolver;var l=n(187);e.PipeResolver=l.PipeResolver;var h=n(5),f=n(6),d=n(140),v=n(144),y=n(183),m=n(185),g=n(166),_=n(168),b=n(162),P=n(64),E=n(165),w=n(150),C=n(199),R=n(157),S=n(142),O=n(143),T=n(188),x=n(186),A=n(187);e.COMPILER_PROVIDERS=h.CONST_EXPR([O.Lexer,S.Parser,v.HtmlParser,d.TemplateParser,y.DirectiveNormalizer,m.RuntimeMetadataResolver,R.DEFAULT_PACKAGE_URL_PROVIDER,g.StyleCompiler,_.ViewCompiler,new f.Provider(b.CompilerConfig,{useFactory:i,deps:[]}),E.RuntimeCompiler,new f.Provider(P.ComponentResolver,{useExisting:E.RuntimeCompiler}),C.DomElementSchemaRegistry,new f.Provider(w.ElementSchemaRegistry,{useExisting:C.DomElementSchemaRegistry}),R.UrlResolver,T.ViewResolver,x.DirectiveResolver,A.PipeResolver])},function(t,e,n){"use strict";function r(t,e,n){void 0===n&&(n=null);var r=[];return e.forEach(function(e){var o=e.visit(t,n);i.isPresent(o)&&r.push(o)}),r}var i=n(5),o=function(){function t(t,e,n){this.value=t,this.ngContentIndex=e,this.sourceSpan=n}return t.prototype.visit=function(t,e){return t.visitText(this,e)},t}();e.TextAst=o;var s=function(){function t(t,e,n){this.value=t,this.ngContentIndex=e,this.sourceSpan=n}return t.prototype.visit=function(t,e){return t.visitBoundText(this,e)},t}();e.BoundTextAst=s;var a=function(){function t(t,e,n){this.name=t,this.value=e,this.sourceSpan=n}return t.prototype.visit=function(t,e){return t.visitAttr(this,e)},t}();e.AttrAst=a;var u=function(){function t(t,e,n,r,i){this.name=t,this.type=e,this.value=n,this.unit=r,this.sourceSpan=i}return t.prototype.visit=function(t,e){return t.visitElementProperty(this,e)},t}();e.BoundElementPropertyAst=u;var c=function(){function t(t,e,n,r){this.name=t,this.target=e,this.handler=n,this.sourceSpan=r}return t.prototype.visit=function(t,e){return t.visitEvent(this,e)},Object.defineProperty(t.prototype,"fullName",{get:function(){return i.isPresent(this.target)?this.target+":"+this.name:this.name},enumerable:!0,configurable:!0}),t}();e.BoundEventAst=c;var p=function(){function t(t,e,n){this.name=t,this.value=e,this.sourceSpan=n}return t.prototype.visit=function(t,e){return t.visitVariable(this,e)},t}();e.VariableAst=p;var l=function(){function t(t,e,n,r,i,o,s,a,u,c,p){this.name=t,this.attrs=e,this.inputs=n,this.outputs=r,this.exportAsVars=i,this.directives=o,this.providers=s,this.hasViewContainer=a,this.children=u,this.ngContentIndex=c,this.sourceSpan=p}return t.prototype.visit=function(t,e){return t.visitElement(this,e)},t.prototype.isBound=function(){return this.inputs.length>0||this.outputs.length>0||this.exportAsVars.length>0||this.directives.length>0},t.prototype.getComponent=function(){for(var t=0;t0;n||e.push(t)}),e}var s=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},a=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},u=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},c=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},p=n(15),l=n(5),h=n(2),f=n(5),d=n(12),v=n(141),y=n(142),m=n(144),g=n(148),_=n(147),b=n(66),P=n(139),E=n(149),w=n(150),C=n(151),R=n(152),S=n(145),O=n(153),T=n(154),x=/^(?:(?:(?:(bind-)|(var-|#)|(on-)|(bindon-))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/g,A="template",I="template",M="*",k="class",N=".",D="attr",V="class",j="style",L=E.CssSelector.parse("*")[0];e.TEMPLATE_TRANSFORMS=f.CONST_EXPR(new h.OpaqueToken("TemplateTransforms"));var B=function(t){function e(e,n){t.call(this,n,e)}return s(e,t),e}(_.ParseError);e.TemplateParseError=B;var F=function(){function t(t,e){this.templateAst=t,this.errors=e}return t}();e.TemplateParseResult=F;var U=function(){function t(t,e,n,r){this._exprParser=t,this._schemaRegistry=e,this._htmlParser=n,this.transforms=r}return t.prototype.parse=function(t,e,n,r,i){var o=this.tryParse(t,e,n,r,i);if(l.isPresent(o.errors)){var s=o.errors.join("\n");throw new d.BaseException("Template parse errors:\n"+s)}return o.templateAst},t.prototype.tryParse=function(t,e,n,r,i){var s,a=this._htmlParser.parse(e,i),u=a.errors;if(a.rootNodes.length>0){var c=o(n),p=o(r),h=new T.ProviderViewContext(t,a.rootNodes[0].sourceSpan),f=new W(h,c,p,this._exprParser,this._schemaRegistry);s=S.htmlVisitAll(f,a.rootNodes,G),u=u.concat(f.errors).concat(h.errors)}else s=[];return u.length>0?new F(s,u):(l.isPresent(this.transforms)&&this.transforms.forEach(function(t){s=P.templateVisitAll(t,s)}),new F(s))},t=a([h.Injectable(),c(3,h.Optional()),c(3,h.Inject(e.TEMPLATE_TRANSFORMS)),u("design:paramtypes",[y.Parser,w.ElementSchemaRegistry,m.HtmlParser,Array])],t)}();e.TemplateParser=U;var W=function(){function t(t,e,n,r,i){var o=this;this.providerViewContext=t,this._exprParser=r,this._schemaRegistry=i,this.errors=[],this.directivesIndex=new Map,this.ngContentCount=0,this.selectorMatcher=new E.SelectorMatcher,p.ListWrapper.forEachWithIndex(e,function(t,e){var n=E.CssSelector.parse(t.selector);o.selectorMatcher.addSelectables(n,t),o.directivesIndex.set(t,e)}),this.pipesByName=new Map,n.forEach(function(t){return o.pipesByName.set(t.name,t)})}return t.prototype._reportError=function(t,e){this.errors.push(new B(t,e))},t.prototype._parseInterpolation=function(t,e){var n=e.start.toString();try{var r=this._exprParser.parseInterpolation(t,n);if(this._checkPipes(r,e),l.isPresent(r)&&r.ast.expressions.length>b.MAX_INTERPOLATION_VALUES)throw new d.BaseException("Only support at most "+b.MAX_INTERPOLATION_VALUES+" interpolation values!");return r}catch(i){return this._reportError(""+i,e),this._exprParser.wrapLiteralPrimitive("ERROR",n)}},t.prototype._parseAction=function(t,e){var n=e.start.toString();try{var r=this._exprParser.parseAction(t,n);return this._checkPipes(r,e),r}catch(i){return this._reportError(""+i,e),this._exprParser.wrapLiteralPrimitive("ERROR",n)}},t.prototype._parseBinding=function(t,e){var n=e.start.toString();try{var r=this._exprParser.parseBinding(t,n);return this._checkPipes(r,e),r}catch(i){return this._reportError(""+i,e),this._exprParser.wrapLiteralPrimitive("ERROR",n)}},t.prototype._parseTemplateBindings=function(t,e){var n=this,r=e.start.toString();try{var i=this._exprParser.parseTemplateBindings(t,r);return i.forEach(function(t){l.isPresent(t.expression)&&n._checkPipes(t.expression,e)}),i}catch(o){return this._reportError(""+o,e),[]}},t.prototype._checkPipes=function(t,e){var n=this;if(l.isPresent(t)){var r=new K;t.visit(r),r.pipes.forEach(function(t){n.pipesByName.has(t)||n._reportError("The pipe '"+t+"' could not be found",e)})}},t.prototype.visitExpansion=function(t,e){return null},t.prototype.visitExpansionCase=function(t,e){return null},t.prototype.visitText=function(t,e){var n=e.findNgContentIndex(L),r=this._parseInterpolation(t.value,t.sourceSpan);return l.isPresent(r)?new P.BoundTextAst(r,n,t.sourceSpan):new P.TextAst(t.value,n,t.sourceSpan)},t.prototype.visitAttr=function(t,e){return new P.AttrAst(t.name,t.value,t.sourceSpan)},t.prototype.visitComment=function(t,e){return null},t.prototype.visitElement=function(t,e){var n=this,r=t.name,o=C.preparseElement(t);if(o.type===C.PreparsedElementType.SCRIPT||o.type===C.PreparsedElementType.STYLE)return null;if(o.type===C.PreparsedElementType.STYLESHEET&&R.isStyleUrlResolvable(o.hrefAttr))return null;var s=[],a=[],u=[],c=[],p=[],h=[],f=[],d=!1,v=[];t.attrs.forEach(function(t){var e=n._parseAttr(t,s,a,c,u),r=n._parseInlineTemplateBinding(t,f,p,h);e||r||(v.push(n.visitAttr(t,null)),s.push([t.name,t.value])),r&&(d=!0)});var y=g.splitNsName(r.toLowerCase())[1],m=y==A,_=i(r,s),b=this._parseDirectives(this.selectorMatcher,_),w=this._createDirectiveAsts(t.name,b,a,m?[]:u,t.sourceSpan),O=this._createElementPropertyAsts(t.name,a,w),x=e.isTemplateElement||d,I=new T.ProviderElementContext(this.providerViewContext,e.providerContext,x,w,v,u,t.sourceSpan),M=S.htmlVisitAll(o.nonBindable?z:this,t.children,q.create(m,w,m?e.providerContext:I));I.afterElement();var k,N=l.isPresent(o.projectAs)?E.CssSelector.parse(o.projectAs)[0]:_,D=e.findNgContentIndex(N);if(o.type===C.PreparsedElementType.NG_CONTENT)l.isPresent(t.children)&&t.children.length>0&&this._reportError(" element cannot have content. must be immediately followed by ",t.sourceSpan),k=new P.NgContentAst(this.ngContentCount++,d?null:D,t.sourceSpan);else if(m)this._assertAllEventsPublishedByDirectives(w,c),this._assertNoComponentsNorElementBindingsOnTemplate(w,O,t.sourceSpan),k=new P.EmbeddedTemplateAst(v,c,u,I.transformedDirectiveAsts,I.transformProviders,I.transformedHasViewContainer,M,d?null:D,t.sourceSpan);else{this._assertOnlyOneComponent(w,t.sourceSpan);var V=u.filter(function(t){return 0===t.value.length}),j=d?null:e.findNgContentIndex(N);k=new P.ElementAst(r,v,O,c,V,I.transformedDirectiveAsts,I.transformProviders,I.transformedHasViewContainer,M,d?null:j,t.sourceSpan)}if(d){var L=i(A,f),B=this._parseDirectives(this.selectorMatcher,L),F=this._createDirectiveAsts(t.name,B,p,[],t.sourceSpan),U=this._createElementPropertyAsts(t.name,p,F);this._assertNoComponentsNorElementBindingsOnTemplate(F,U,t.sourceSpan);var W=new T.ProviderElementContext(this.providerViewContext,e.providerContext,e.isTemplateElement,F,[],h,t.sourceSpan);W.afterElement(),k=new P.EmbeddedTemplateAst([],[],h,W.transformedDirectiveAsts,W.transformProviders,W.transformedHasViewContainer,[k],D,t.sourceSpan)}return k},t.prototype._parseInlineTemplateBinding=function(t,e,n,r){var i=null;if(t.name==I)i=t.value;else if(t.name.startsWith(M)){var o=t.name.substring(M.length);i=0==t.value.length?o:o+" "+t.value}if(l.isPresent(i)){for(var s=this._parseTemplateBindings(i,t.sourceSpan),a=0;a-1&&this._reportError('"-" is not allowed in variable names',n),r.push(new P.VariableAst(t,e,n))},t.prototype._parseProperty=function(t,e,n,r,i){this._parsePropertyAst(t,this._parseBinding(e,n),n,r,i)},t.prototype._parsePropertyInterpolation=function(t,e,n,r,i){var o=this._parseInterpolation(e,n);return l.isPresent(o)?(this._parsePropertyAst(t,o,n,r,i),!0):!1},t.prototype._parsePropertyAst=function(t,e,n,r,i){r.push([t,e.source]),i.push(new X(t,e,!1,n))},t.prototype._parseAssignmentEvent=function(t,e,n,r,i){this._parseEvent(t+"Change",e+"=$event",n,r,i)},t.prototype._parseEvent=function(t,e,n,r,i){var o=O.splitAtColon(t,[null,t]),s=o[0],a=o[1],u=this._parseAction(e,n);r.push([t,u.source]),i.push(new P.BoundEventAst(a,s,u,n))},t.prototype._parseLiteralAttr=function(t,e,n,r){r.push(new X(t,this._exprParser.wrapLiteralPrimitive(e,""),!0,n))},t.prototype._parseDirectives=function(t,e){var n=this,r=[];return t.match(e,function(t,e){r.push(e)}),p.ListWrapper.sort(r,function(t,e){var r=t.isComponent,i=e.isComponent;return r&&!i?-1:!r&&i?1:n.directivesIndex.get(t)-n.directivesIndex.get(e)}),r},t.prototype._createDirectiveAsts=function(t,e,n,r,i){var o=this,s=new Set,a=e.map(function(e){var a=[],u=[],c=[];o._createDirectiveHostPropertyAsts(t,e.hostProperties,i,a),o._createDirectiveHostEventAsts(e.hostListeners,i,u),o._createDirectivePropertyAsts(e.inputs,n,c);var p=[];return r.forEach(function(t){(0===t.value.length&&e.isComponent||e.exportAs==t.value)&&(p.push(t),s.add(t.name))}),new P.DirectiveAst(e,c,a,u,p,i)});return r.forEach(function(t){t.value.length>0&&!p.SetWrapper.has(s,t.name)&&o._reportError('There is no directive with "exportAs" set to "'+t.value+'"',t.sourceSpan)}),a},t.prototype._createDirectiveHostPropertyAsts=function(t,e,n,r){var i=this;l.isPresent(e)&&p.StringMapWrapper.forEach(e,function(e,o){var s=i._parseBinding(e,n);r.push(i._createElementPropertyAst(t,o,s,n))})},t.prototype._createDirectiveHostEventAsts=function(t,e,n){var r=this;l.isPresent(t)&&p.StringMapWrapper.forEach(t,function(t,i){r._parseEvent(i,t,e,[],n)})},t.prototype._createDirectivePropertyAsts=function(t,e,n){if(l.isPresent(t)){var r=new Map;e.forEach(function(t){var e=r.get(t.name);(l.isBlank(e)||e.isLiteral)&&r.set(t.name,t)}),p.StringMapWrapper.forEach(t,function(t,e){var i=r.get(t);l.isPresent(i)&&n.push(new P.BoundDirectivePropertyAst(e,i.name,i.expression,i.sourceSpan))})}},t.prototype._createElementPropertyAsts=function(t,e,n){var r=this,i=[],o=new Map;return n.forEach(function(t){t.inputs.forEach(function(t){o.set(t.templateName,t)})}),e.forEach(function(e){!e.isLiteral&&l.isBlank(o.get(e.name))&&i.push(r._createElementPropertyAst(t,e.name,e.expression,e.sourceSpan))}),i},t.prototype._createElementPropertyAst=function(t,e,n,r){var i,o,s=null,a=e.split(N);if(1===a.length)o=this._schemaRegistry.getMappedPropName(a[0]),i=P.PropertyBindingType.Property,this._schemaRegistry.hasProperty(t,o)||this._reportError("Can't bind to '"+o+"' since it isn't a known native property",r);else if(a[0]==D){o=a[1];var u=o.indexOf(":");if(u>-1){var c=o.substring(0,u),p=o.substring(u+1);o=g.mergeNsAndName(c,p)}i=P.PropertyBindingType.Attribute}else a[0]==V?(o=a[1],i=P.PropertyBindingType.Class):a[0]==j?(s=a.length>2?a[2]:null,o=a[1],i=P.PropertyBindingType.Style):(this._reportError("Invalid property name '"+e+"'",r),i=null);return new P.BoundElementPropertyAst(o,i,n,s,r)},t.prototype._findComponentDirectiveNames=function(t){var e=[];return t.forEach(function(t){var n=t.directive.type.name;t.directive.isComponent&&e.push(n)}),e},t.prototype._assertOnlyOneComponent=function(t,e){var n=this._findComponentDirectiveNames(t);n.length>1&&this._reportError("More than one component: "+n.join(","),e)},t.prototype._assertNoComponentsNorElementBindingsOnTemplate=function(t,e,n){var r=this,i=this._findComponentDirectiveNames(t);i.length>0&&this._reportError("Components on an embedded template: "+i.join(","),n),e.forEach(function(t){r._reportError("Property binding "+t.name+" not used by any directive on an embedded template",n)})},t.prototype._assertAllEventsPublishedByDirectives=function(t,e){var n=this,r=new Set;t.forEach(function(t){p.StringMapWrapper.forEach(t.directive.outputs,function(t,e){r.add(t)})}),e.forEach(function(t){(l.isPresent(t.target)||!p.SetWrapper.has(r,t.name))&&n._reportError("Event binding "+t.fullName+" not emitted by any directive on an embedded template",t.sourceSpan)})},t}(),H=function(){function t(){}return t.prototype.visitElement=function(t,e){var n=C.preparseElement(t);if(n.type===C.PreparsedElementType.SCRIPT||n.type===C.PreparsedElementType.STYLE||n.type===C.PreparsedElementType.STYLESHEET)return null;var r=t.attrs.map(function(t){return[t.name,t.value]}),o=i(t.name,r),s=e.findNgContentIndex(o),a=S.htmlVisitAll(this,t.children,G);return new P.ElementAst(t.name,S.htmlVisitAll(this,t.attrs),[],[],[],[],[],!1,a,s,t.sourceSpan)},t.prototype.visitComment=function(t,e){return null},t.prototype.visitAttr=function(t,e){return new P.AttrAst(t.name,t.value,t.sourceSpan)},t.prototype.visitText=function(t,e){var n=e.findNgContentIndex(L);return new P.TextAst(t.value,n,t.sourceSpan)},t.prototype.visitExpansion=function(t,e){return t},t.prototype.visitExpansionCase=function(t,e){return t},t}(),X=function(){function t(t,e,n,r){this.name=t,this.expression=e,this.isLiteral=n,this.sourceSpan=r}return t}();e.splitClasses=r;var q=function(){function t(t,e,n,r){this.isTemplateElement=t,this._ngContentIndexMatcher=e,this._wildcardNgContentIndex=n,this.providerContext=r}return t.create=function(e,n,r){var i=new E.SelectorMatcher,o=null;if(n.length>0&&n[0].directive.isComponent)for(var s=n[0].directive.template.ngContentSelectors,a=0;a0?e[0]:null},t}(),G=new q(!0,new E.SelectorMatcher,null,null),z=new H,K=function(t){function e(){t.apply(this,arguments),this.pipes=new Set}return s(e,t),e.prototype.visitPipe=function(t,e){return this.pipes.add(t.name),t.exp.visit(this),this.visitAll(t.args,e),null},e}(v.RecursiveAstVisitor);e.PipeCollector=K},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(15),o=function(){function t(){}return t.prototype.visit=function(t,e){return void 0===e&&(e=null),null},t.prototype.toString=function(){return"AST"},t}();e.AST=o;var s=function(t){function e(e,n,r){t.call(this),this.prefix=e,this.uninterpretedExpression=n,this.location=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitQuote(this,e)},e.prototype.toString=function(){return"Quote"},e}(o);e.Quote=s;var a=function(t){function e(){t.apply(this,arguments)}return r(e,t),e.prototype.visit=function(t,e){void 0===e&&(e=null)},e}(o);e.EmptyExpr=a;var u=function(t){function e(){t.apply(this,arguments)}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitImplicitReceiver(this,e)},e}(o);e.ImplicitReceiver=u;var c=function(t){function e(e){t.call(this),this.expressions=e}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitChain(this,e)},e}(o);e.Chain=c;var p=function(t){function e(e,n,r){t.call(this),this.condition=e,this.trueExp=n,this.falseExp=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitConditional(this,e)},e}(o);e.Conditional=p;var l=function(t){function e(e,n){t.call(this),this.receiver=e,this.name=n}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitPropertyRead(this,e)},e}(o);e.PropertyRead=l;var h=function(t){function e(e,n,r){t.call(this),this.receiver=e,this.name=n,this.value=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitPropertyWrite(this,e)},e}(o);e.PropertyWrite=h;var f=function(t){function e(e,n){t.call(this),this.receiver=e,this.name=n}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitSafePropertyRead(this,e)},e}(o);e.SafePropertyRead=f;var d=function(t){function e(e,n){t.call(this),this.obj=e,this.key=n}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitKeyedRead(this,e)},e}(o);e.KeyedRead=d;var v=function(t){function e(e,n,r){t.call(this),this.obj=e,this.key=n,this.value=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitKeyedWrite(this,e)},e}(o);e.KeyedWrite=v;var y=function(t){function e(e,n,r){t.call(this),this.exp=e,this.name=n,this.args=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitPipe(this,e)},e}(o);e.BindingPipe=y;var m=function(t){function e(e){t.call(this),this.value=e}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitLiteralPrimitive(this,e)},e}(o);e.LiteralPrimitive=m;var g=function(t){function e(e){t.call(this),this.expressions=e}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitLiteralArray(this,e)},e}(o);e.LiteralArray=g;var _=function(t){function e(e,n){t.call(this),this.keys=e,this.values=n}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitLiteralMap(this,e)},e}(o);e.LiteralMap=_;var b=function(t){function e(e,n){t.call(this),this.strings=e,this.expressions=n}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitInterpolation(this,e)},e}(o);e.Interpolation=b;var P=function(t){function e(e,n,r){t.call(this),this.operation=e,this.left=n,this.right=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitBinary(this,e)},e}(o);e.Binary=P;var E=function(t){function e(e){t.call(this),this.expression=e}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitPrefixNot(this,e)},e}(o);e.PrefixNot=E;var w=function(t){function e(e,n,r){t.call(this),this.receiver=e,this.name=n,this.args=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitMethodCall(this,e)},e}(o);e.MethodCall=w;var C=function(t){function e(e,n,r){t.call(this),this.receiver=e,this.name=n,this.args=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitSafeMethodCall(this,e)},e}(o);e.SafeMethodCall=C;var R=function(t){function e(e,n){t.call(this),this.target=e,this.args=n}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),t.visitFunctionCall(this,e)},e}(o);e.FunctionCall=R;var S=function(t){function e(e,n,r){t.call(this),this.ast=e,this.source=n,this.location=r}return r(e,t),e.prototype.visit=function(t,e){return void 0===e&&(e=null),this.ast.visit(t,e)},e.prototype.toString=function(){return this.source+" in "+this.location},e}(o);e.ASTWithSource=S;var O=function(){function t(t,e,n,r){this.key=t,this.keyIsVar=e,this.name=n,this.expression=r}return t}();e.TemplateBinding=O;var T=function(){function t(){}return t.prototype.visitBinary=function(t,e){return t.left.visit(this),t.right.visit(this),null},t.prototype.visitChain=function(t,e){return this.visitAll(t.expressions,e)},t.prototype.visitConditional=function(t,e){return t.condition.visit(this),t.trueExp.visit(this),t.falseExp.visit(this),null},t.prototype.visitPipe=function(t,e){return t.exp.visit(this),this.visitAll(t.args,e),null},t.prototype.visitFunctionCall=function(t,e){return t.target.visit(this),this.visitAll(t.args,e),null},t.prototype.visitImplicitReceiver=function(t,e){return null},t.prototype.visitInterpolation=function(t,e){return this.visitAll(t.expressions,e)},t.prototype.visitKeyedRead=function(t,e){return t.obj.visit(this),t.key.visit(this),null},t.prototype.visitKeyedWrite=function(t,e){return t.obj.visit(this),t.key.visit(this),t.value.visit(this),null},t.prototype.visitLiteralArray=function(t,e){return this.visitAll(t.expressions,e)},t.prototype.visitLiteralMap=function(t,e){return this.visitAll(t.values,e)},t.prototype.visitLiteralPrimitive=function(t,e){return null},t.prototype.visitMethodCall=function(t,e){return t.receiver.visit(this),this.visitAll(t.args,e)},t.prototype.visitPrefixNot=function(t,e){return t.expression.visit(this),null},t.prototype.visitPropertyRead=function(t,e){return t.receiver.visit(this),null},t.prototype.visitPropertyWrite=function(t,e){return t.receiver.visit(this),t.value.visit(this),null},t.prototype.visitSafePropertyRead=function(t,e){return t.receiver.visit(this),null},t.prototype.visitSafeMethodCall=function(t,e){return t.receiver.visit(this),this.visitAll(t.args,e)},t.prototype.visitAll=function(t,e){var n=this;return t.forEach(function(t){return t.visit(n,e)}),null},t.prototype.visitQuote=function(t,e){return null},t}();e.RecursiveAstVisitor=T;var x=function(){function t(){}return t.prototype.visitImplicitReceiver=function(t,e){return t},t.prototype.visitInterpolation=function(t,e){return new b(t.strings,this.visitAll(t.expressions))},t.prototype.visitLiteralPrimitive=function(t,e){return new m(t.value)},t.prototype.visitPropertyRead=function(t,e){return new l(t.receiver.visit(this),t.name)},t.prototype.visitPropertyWrite=function(t,e){return new h(t.receiver.visit(this),t.name,t.value)},t.prototype.visitSafePropertyRead=function(t,e){return new f(t.receiver.visit(this),t.name)},t.prototype.visitMethodCall=function(t,e){return new w(t.receiver.visit(this),t.name,this.visitAll(t.args))},t.prototype.visitSafeMethodCall=function(t,e){return new C(t.receiver.visit(this),t.name,this.visitAll(t.args))},t.prototype.visitFunctionCall=function(t,e){return new R(t.target.visit(this),this.visitAll(t.args))},t.prototype.visitLiteralArray=function(t,e){return new g(this.visitAll(t.expressions))},t.prototype.visitLiteralMap=function(t,e){return new _(t.keys,this.visitAll(t.values))},t.prototype.visitBinary=function(t,e){return new P(t.operation,t.left.visit(this),t.right.visit(this))},t.prototype.visitPrefixNot=function(t,e){return new E(t.expression.visit(this))},t.prototype.visitConditional=function(t,e){return new p(t.condition.visit(this),t.trueExp.visit(this),t.falseExp.visit(this))},t.prototype.visitPipe=function(t,e){return new y(t.exp.visit(this),t.name,this.visitAll(t.args))},t.prototype.visitKeyedRead=function(t,e){return new d(t.obj.visit(this),t.key.visit(this))},t.prototype.visitKeyedWrite=function(t,e){return new v(t.obj.visit(this),t.key.visit(this),t.value.visit(this))},t.prototype.visitAll=function(t){for(var e=i.ListWrapper.createFixedSize(t.length),n=0;no?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(8),a=n(5),u=n(12),c=n(15),p=n(143),l=n(141),h=new l.ImplicitReceiver,f=/\{\{([\s\S]*?)\}\}/g,d=function(t){function e(e,n,r,i){t.call(this,"Parser Error: "+e+" "+r+" ["+n+"] in "+i)}return r(e,t),e}(u.BaseException),v=function(){function t(t,e){this.strings=t,this.expressions=e}return t}();e.SplitInterpolation=v;var y=function(){function t(t){this._lexer=t}return t.prototype.parseAction=function(t,e){this._checkNoInterpolation(t,e);var n=this._lexer.tokenize(this._stripComments(t)),r=new m(t,e,n,!0).parseChain();return new l.ASTWithSource(r,t,e)},t.prototype.parseBinding=function(t,e){var n=this._parseBindingAst(t,e);return new l.ASTWithSource(n,t,e)},t.prototype.parseSimpleBinding=function(t,e){var n=this._parseBindingAst(t,e);if(!g.check(n))throw new d("Host binding expression can only contain field access and constants",t,e);return new l.ASTWithSource(n,t,e)},t.prototype._parseBindingAst=function(t,e){var n=this._parseQuote(t,e);if(a.isPresent(n))return n;this._checkNoInterpolation(t,e);var r=this._lexer.tokenize(this._stripComments(t));return new m(t,e,r,!1).parseChain()},t.prototype._parseQuote=function(t,e){if(a.isBlank(t))return null;var n=t.indexOf(":");if(-1==n)return null;var r=t.substring(0,n).trim();if(!p.isIdentifier(r))return null;var i=t.substring(n+1);return new l.Quote(r,i,e)},t.prototype.parseTemplateBindings=function(t,e){var n=this._lexer.tokenize(t);return new m(t,e,n,!1).parseTemplateBindings()},t.prototype.parseInterpolation=function(t,e){var n=this.splitInterpolation(t,e);if(null==n)return null;for(var r=[],i=0;i0))throw new d("Blank expressions are not allowed in interpolated strings",t,"at column "+this._findInterpolationErrorColumn(n,o)+" in",e);i.push(s)}}return new v(r,i)},t.prototype.wrapLiteralPrimitive=function(t,e){return new l.ASTWithSource(new l.LiteralPrimitive(t),t,e)},t.prototype._stripComments=function(t){var e=this._commentStart(t);return a.isPresent(e)?t.substring(0,e).trim():t},t.prototype._commentStart=function(t){for(var e=null,n=0;n1)throw new d("Got interpolation ({{}}) where expression was expected",t,"at column "+this._findInterpolationErrorColumn(n,1)+" in",e)},t.prototype._findInterpolationErrorColumn=function(t,e){for(var n="",r=0;e>r;r++)n+=r%2===0?t[r]:"{{"+t[r]+"}}";return n.length},t=i([s.Injectable(),o("design:paramtypes",[p.Lexer])],t)}();e.Parser=y;var m=function(){function t(t,e,n,r){this.input=t,this.location=e,this.tokens=n,this.parseAction=r,this.index=0}return t.prototype.peek=function(t){var e=this.index+t;return e"))t=new l.Binary(">",t,this.parseAdditive());else if(this.optionalOperator("<="))t=new l.Binary("<=",t,this.parseAdditive());else{if(!this.optionalOperator(">="))return t;t=new l.Binary(">=",t,this.parseAdditive())}},t.prototype.parseAdditive=function(){for(var t=this.parseMultiplicative();;)if(this.optionalOperator("+"))t=new l.Binary("+",t,this.parseMultiplicative());else{if(!this.optionalOperator("-"))return t;t=new l.Binary("-",t,this.parseMultiplicative())}},t.prototype.parseMultiplicative=function(){for(var t=this.parsePrefix();;)if(this.optionalOperator("*"))t=new l.Binary("*",t,this.parsePrefix());else if(this.optionalOperator("%"))t=new l.Binary("%",t,this.parsePrefix());else{if(!this.optionalOperator("/"))return t;t=new l.Binary("/",t,this.parsePrefix())}},t.prototype.parsePrefix=function(){return this.optionalOperator("+")?this.parsePrefix():this.optionalOperator("-")?new l.Binary("-",new l.LiteralPrimitive(0),this.parsePrefix()):this.optionalOperator("!")?new l.PrefixNot(this.parsePrefix()):this.parseCallChain()},t.prototype.parseCallChain=function(){for(var t=this.parsePrimary();;)if(this.optionalCharacter(p.$PERIOD))t=this.parseAccessMemberOrMethodCall(t,!1);else if(this.optionalOperator("?."))t=this.parseAccessMemberOrMethodCall(t,!0);else if(this.optionalCharacter(p.$LBRACKET)){var e=this.parsePipe();if(this.expectCharacter(p.$RBRACKET),this.optionalOperator("=")){var n=this.parseConditional();t=new l.KeyedWrite(t,e,n)}else t=new l.KeyedRead(t,e)}else{if(!this.optionalCharacter(p.$LPAREN))return t;var r=this.parseCallArguments();this.expectCharacter(p.$RPAREN),t=new l.FunctionCall(t,r)}},t.prototype.parsePrimary=function(){if(this.optionalCharacter(p.$LPAREN)){var t=this.parsePipe();return this.expectCharacter(p.$RPAREN),t}if(this.next.isKeywordNull()||this.next.isKeywordUndefined())return this.advance(),new l.LiteralPrimitive(null);if(this.next.isKeywordTrue())return this.advance(),new l.LiteralPrimitive(!0);if(this.next.isKeywordFalse())return this.advance(),new l.LiteralPrimitive(!1);if(this.optionalCharacter(p.$LBRACKET)){var e=this.parseExpressionList(p.$RBRACKET);return this.expectCharacter(p.$RBRACKET),new l.LiteralArray(e)}if(this.next.isCharacter(p.$LBRACE))return this.parseLiteralMap();if(this.next.isIdentifier())return this.parseAccessMemberOrMethodCall(h,!1);if(this.next.isNumber()){var n=this.next.toNumber();return this.advance(),new l.LiteralPrimitive(n)}if(this.next.isString()){var r=this.next.toString();return this.advance(),new l.LiteralPrimitive(r)}throw this.index>=this.tokens.length?this.error("Unexpected end of expression: "+this.input):this.error("Unexpected token "+this.next),new u.BaseException("Fell through all cases in parsePrimary")},t.prototype.parseExpressionList=function(t){var e=[];if(!this.next.isCharacter(t))do e.push(this.parsePipe());while(this.optionalCharacter(p.$COMMA));return e},t.prototype.parseLiteralMap=function(){var t=[],e=[];if(this.expectCharacter(p.$LBRACE),!this.optionalCharacter(p.$RBRACE)){do{var n=this.expectIdentifierOrKeywordOrString();t.push(n),this.expectCharacter(p.$COLON),e.push(this.parsePipe())}while(this.optionalCharacter(p.$COMMA));this.expectCharacter(p.$RBRACE)}return new l.LiteralMap(t,e)},t.prototype.parseAccessMemberOrMethodCall=function(t,e){void 0===e&&(e=!1);var n=this.expectIdentifierOrKeyword();if(this.optionalCharacter(p.$LPAREN)){var r=this.parseCallArguments();return this.expectCharacter(p.$RPAREN),e?new l.SafeMethodCall(t,n,r):new l.MethodCall(t,n,r)}if(!e){if(this.optionalOperator("=")){this.parseAction||this.error("Bindings cannot contain assignments");var i=this.parseConditional();return new l.PropertyWrite(t,n,i)}return new l.PropertyRead(t,n)}return this.optionalOperator("=")?(this.error("The '?.' operator cannot be used in the assignment"),null):new l.SafePropertyRead(t,n)},t.prototype.parseCallArguments=function(){if(this.next.isCharacter(p.$RPAREN))return[];var t=[];do t.push(this.parsePipe());while(this.optionalCharacter(p.$COMMA));return t},t.prototype.parseBlockContent=function(){this.parseAction||this.error("Binding expression cannot contain chained expression");for(var t=[];this.index=e.$TAB&&t<=e.$SPACE||t==X}function p(t){return t>=D&&H>=t||t>=A&&M>=t||t==N||t==e.$$}function l(t){if(0==t.length)return!1;var n=new G(t);if(!p(n.peek))return!1;for(n.advance();n.peek!==e.$EOF;){if(!h(n.peek))return!1;n.advance()}return!0}function h(t){return t>=D&&H>=t||t>=A&&M>=t||t>=T&&x>=t||t==N||t==e.$$}function f(t){return t>=T&&x>=t}function d(t){return t==V||t==I}function v(t){return t==e.$MINUS||t==e.$PLUS}function y(t){return t===e.$SQ||t===e.$DQ||t===e.$BT}function m(t){switch(t){case L:return e.$LF;case j:return e.$FF;case B:return e.$CR;case F:return e.$TAB;case W:return e.$VTAB;default:return t}}var g=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},_=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},b=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},P=n(8),E=n(15),w=n(5),C=n(12);!function(t){t[t.Character=0]="Character",t[t.Identifier=1]="Identifier",t[t.Keyword=2]="Keyword",t[t.String=3]="String",t[t.Operator=4]="Operator",t[t.Number=5]="Number"}(e.TokenType||(e.TokenType={}));var R=e.TokenType,S=function(){function t(){}return t.prototype.tokenize=function(t){for(var e=new G(t),n=[],r=e.scanToken();null!=r;)n.push(r),r=e.scanToken();return n},t=_([P.Injectable(),b("design:paramtypes",[])],t)}();e.Lexer=S;var O=function(){function t(t,e,n,r){this.index=t,this.type=e,this.numValue=n,this.strValue=r}return t.prototype.isCharacter=function(t){return this.type==R.Character&&this.numValue==t},t.prototype.isNumber=function(){return this.type==R.Number},t.prototype.isString=function(){return this.type==R.String},t.prototype.isOperator=function(t){return this.type==R.Operator&&this.strValue==t},t.prototype.isIdentifier=function(){return this.type==R.Identifier},t.prototype.isKeyword=function(){return this.type==R.Keyword},t.prototype.isKeywordVar=function(){return this.type==R.Keyword&&"var"==this.strValue},t.prototype.isKeywordNull=function(){return this.type==R.Keyword&&"null"==this.strValue},t.prototype.isKeywordUndefined=function(){return this.type==R.Keyword&&"undefined"==this.strValue},t.prototype.isKeywordTrue=function(){return this.type==R.Keyword&&"true"==this.strValue},t.prototype.isKeywordFalse=function(){return this.type==R.Keyword&&"false"==this.strValue},t.prototype.toNumber=function(){return this.type==R.Number?this.numValue:-1},t.prototype.toString=function(){switch(this.type){case R.Character:case R.Identifier:case R.Keyword:case R.Operator:case R.String:return this.strValue;case R.Number:return this.numValue.toString();default:return null}},t}();e.Token=O,e.EOF=new O(-1,R.Character,0,""),e.$EOF=0,e.$TAB=9,e.$LF=10,e.$VTAB=11,e.$FF=12,e.$CR=13,e.$SPACE=32,e.$BANG=33,e.$DQ=34,e.$HASH=35,e.$$=36,e.$PERCENT=37,e.$AMPERSAND=38,e.$SQ=39,e.$LPAREN=40,e.$RPAREN=41,e.$STAR=42,e.$PLUS=43,e.$COMMA=44,e.$MINUS=45,e.$PERIOD=46,e.$SLASH=47,e.$COLON=58,e.$SEMICOLON=59,e.$LT=60,e.$EQ=61,e.$GT=62,e.$QUESTION=63;var T=48,x=57,A=65,I=69,M=90;e.$LBRACKET=91,e.$BACKSLASH=92,e.$RBRACKET=93;var k=94,N=95;e.$BT=96;var D=97,V=101,j=102,L=110,B=114,F=116,U=117,W=118,H=122;e.$LBRACE=123,e.$BAR=124,e.$RBRACE=125;var X=160,q=function(t){function e(e){t.call(this),this.message=e}return g(e,t),e.prototype.toString=function(){return this.message},e}(C.BaseException);e.ScannerError=q;var G=function(){function t(t){this.input=t,this.peek=0,this.index=-1,this.length=t.length,this.advance()}return t.prototype.advance=function(){this.peek=++this.index>=this.length?e.$EOF:w.StringWrapper.charCodeAt(this.input,this.index)},t.prototype.scanToken=function(){for(var t=this.input,n=this.length,i=this.peek,o=this.index;i<=e.$SPACE;){if(++o>=n){i=e.$EOF;break}i=w.StringWrapper.charCodeAt(t,o)}if(this.peek=i,this.index=o,o>=n)return null;if(p(i))return this.scanIdentifier();if(f(i))return this.scanNumber(o);var s=o;switch(i){case e.$PERIOD:return this.advance(),f(this.peek)?this.scanNumber(s):r(s,e.$PERIOD);case e.$LPAREN:case e.$RPAREN:case e.$LBRACE:case e.$RBRACE:case e.$LBRACKET:case e.$RBRACKET:case e.$COMMA:case e.$COLON:case e.$SEMICOLON:return this.scanCharacter(s,i);case e.$SQ:case e.$DQ:return this.scanString();case e.$HASH:case e.$PLUS:case e.$MINUS:case e.$STAR:case e.$SLASH:case e.$PERCENT:case k:return this.scanOperator(s,w.StringWrapper.fromCharCode(i));case e.$QUESTION:return this.scanComplexOperator(s,"?",e.$PERIOD,".");case e.$LT:case e.$GT:return this.scanComplexOperator(s,w.StringWrapper.fromCharCode(i),e.$EQ,"=");case e.$BANG:case e.$EQ:return this.scanComplexOperator(s,w.StringWrapper.fromCharCode(i),e.$EQ,"=",e.$EQ,"=");case e.$AMPERSAND:return this.scanComplexOperator(s,"&",e.$AMPERSAND,"&");case e.$BAR:return this.scanComplexOperator(s,"|",e.$BAR,"|");case X:for(;c(this.peek);)this.advance();return this.scanToken()}return this.error("Unexpected character ["+w.StringWrapper.fromCharCode(i)+"]",0),null},t.prototype.scanCharacter=function(t,e){return this.advance(),r(t,e)},t.prototype.scanOperator=function(t,e){return this.advance(),s(t,e)},t.prototype.scanComplexOperator=function(t,e,n,r,i,o){this.advance();var a=e;return this.peek==n&&(this.advance(),a+=r),w.isPresent(i)&&this.peek==i&&(this.advance(),a+=o),s(t,a)},t.prototype.scanIdentifier=function(){var t=this.index;for(this.advance();h(this.peek);)this.advance();var e=this.input.substring(t,this.index);return E.SetWrapper.has(z,e)?o(t,e):i(t,e)},t.prototype.scanNumber=function(t){var n=this.index===t;for(this.advance();;){if(f(this.peek));else if(this.peek==e.$PERIOD)n=!1;else{if(!d(this.peek))break;this.advance(),v(this.peek)&&this.advance(),f(this.peek)||this.error("Invalid exponent",-1),n=!1}this.advance()}var r=this.input.substring(t,this.index),i=n?w.NumberWrapper.parseIntAutoRadix(r):w.NumberWrapper.parseFloat(r);return u(t,i)},t.prototype.scanString=function(){var t=this.index,n=this.peek;this.advance();for(var r,i=this.index,o=this.input;this.peek!=n;)if(this.peek==e.$BACKSLASH){null==r&&(r=new w.StringJoiner),r.add(o.substring(i,this.index)),this.advance();var s;if(this.peek==U){var u=o.substring(this.index+1,this.index+5);try{s=w.NumberWrapper.parseInt(u,16)}catch(c){this.error("Invalid unicode escape [\\u"+u+"]",0)}for(var p=0;5>p;p++)this.advance()}else s=m(this.peek),this.advance();r.add(w.StringWrapper.fromCharCode(s)),i=this.index}else this.peek==e.$EOF?this.error("Unterminated quote",0):this.advance();var l=o.substring(i,this.index);this.advance();var h=l;return null!=r&&(r.add(l),h=r.toString()),a(t,h)},t.prototype.error=function(t,e){var n=this.index+e;throw new q("Lexer Error: "+t+" at column "+n+" in expression ["+this.input+"]")},t}();e.isIdentifier=l,e.isQuote=y;var z=(E.SetWrapper.createFromList(["+","-","*","/","%","^","=","==","!=","===","!==","<",">","<=",">=","&&","||","&","|","!","?","#","?."]),E.SetWrapper.createFromList(["var","null","undefined","true","false","if","else"]))},function(t,e,n){"use strict";function r(t,e,n){return u.isBlank(t)&&(t=d.getHtmlTagDefinition(e).implicitNamespacePrefix,u.isBlank(t)&&u.isPresent(n)&&(t=d.getNsPrefix(n.name))),d.mergeNsAndName(t,e)}function i(t,e){return t.length>0&&t[t.length-1]===e}var o=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},s=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},a=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},u=n(5),c=n(15),p=n(145),l=n(6),h=n(146),f=n(147),d=n(148),v=function(t){function e(e,n,r){t.call(this,n,r),this.elementName=e}return o(e,t),e.create=function(t,n,r){return new e(t,n,r)},e}(f.ParseError);e.HtmlTreeError=v;var y=function(){function t(t,e){this.rootNodes=t,this.errors=e}return t}();e.HtmlParseTreeResult=y;var m=function(){function t(){}return t.prototype.parse=function(t,e,n){void 0===n&&(n=!1);var r=h.tokenizeHtml(t,e,n),i=new g(r.tokens).build();return new y(i.rootNodes,r.errors.concat(i.errors))},t=s([l.Injectable(),a("design:paramtypes",[])],t)}();e.HtmlParser=m;var g=function(){function t(t){this.tokens=t,this.index=-1,this.rootNodes=[],this.errors=[],this.elementStack=[],this._advance()}return t.prototype.build=function(){for(;this.peek.type!==h.HtmlTokenType.EOF;)this.peek.type===h.HtmlTokenType.TAG_OPEN_START?this._consumeStartTag(this._advance()):this.peek.type===h.HtmlTokenType.TAG_CLOSE?this._consumeEndTag(this._advance()):this.peek.type===h.HtmlTokenType.CDATA_START?(this._closeVoidElement(),this._consumeCdata(this._advance())):this.peek.type===h.HtmlTokenType.COMMENT_START?(this._closeVoidElement(),this._consumeComment(this._advance())):this.peek.type===h.HtmlTokenType.TEXT||this.peek.type===h.HtmlTokenType.RAW_TEXT||this.peek.type===h.HtmlTokenType.ESCAPABLE_RAW_TEXT?(this._closeVoidElement(),this._consumeText(this._advance())):this.peek.type===h.HtmlTokenType.EXPANSION_FORM_START?this._consumeExpansion(this._advance()):this._advance();return new y(this.rootNodes,this.errors)},t.prototype._advance=function(){var t=this.peek;return this.index0)return this.errors=this.errors.concat(o.errors),null;var s=new f.ParseSourceSpan(e.sourceSpan.start,i.sourceSpan.end),a=new f.ParseSourceSpan(n.sourceSpan.start,i.sourceSpan.end);return new p.HtmlExpansionCaseAst(e.parts[0],o.rootNodes,s,e.sourceSpan,a)},t.prototype._collectExpansionExpTokens=function(t){for(var e=[],n=[h.HtmlTokenType.EXPANSION_CASE_EXP_START];;){if((this.peek.type===h.HtmlTokenType.EXPANSION_FORM_START||this.peek.type===h.HtmlTokenType.EXPANSION_CASE_EXP_START)&&n.push(this.peek.type),this.peek.type===h.HtmlTokenType.EXPANSION_CASE_EXP_END){if(!i(n,h.HtmlTokenType.EXPANSION_CASE_EXP_START))return this.errors.push(v.create(null,t.sourceSpan,"Invalid expansion form. Missing '}'.")),null;if(n.pop(),0==n.length)return e}if(this.peek.type===h.HtmlTokenType.EXPANSION_FORM_END){if(!i(n,h.HtmlTokenType.EXPANSION_FORM_START))return this.errors.push(v.create(null,t.sourceSpan,"Invalid expansion form. Missing '}'.")),null;n.pop()}if(this.peek.type===h.HtmlTokenType.EOF)return this.errors.push(v.create(null,t.sourceSpan,"Invalid expansion form. Missing '}'.")),null;e.push(this._advance())}},t.prototype._consumeText=function(t){var e=t.parts[0];if(e.length>0&&"\n"==e[0]){var n=this._getParentElement();u.isPresent(n)&&0==n.children.length&&d.getHtmlTagDefinition(n.name).ignoreFirstLf&&(e=e.substring(1))}e.length>0&&this._addToParent(new p.HtmlTextAst(e,t.sourceSpan))},t.prototype._closeVoidElement=function(){if(this.elementStack.length>0){var t=c.ListWrapper.last(this.elementStack);d.getHtmlTagDefinition(t.name).isVoid&&this.elementStack.pop()}},t.prototype._consumeStartTag=function(t){for(var e=t.parts[0],n=t.parts[1],i=[];this.peek.type===h.HtmlTokenType.ATTR_NAME;)i.push(this._consumeAttr(this._advance()));var o=r(e,n,this._getParentElement()),s=!1;this.peek.type===h.HtmlTokenType.TAG_OPEN_END_VOID?(this._advance(),s=!0,null!=d.getNsPrefix(o)||d.getHtmlTagDefinition(o).isVoid||this.errors.push(v.create(o,t.sourceSpan,'Only void and foreign elements can be self closed "'+t.parts[1]+'"'))):this.peek.type===h.HtmlTokenType.TAG_OPEN_END&&(this._advance(),s=!1);var a=this.peek.sourceSpan.start,u=new f.ParseSourceSpan(t.sourceSpan.start,a),c=new p.HtmlElementAst(o,i,[],u,u,null);this._pushElement(c),s&&(this._popElement(o),c.endSourceSpan=u)},t.prototype._pushElement=function(t){if(this.elementStack.length>0){var e=c.ListWrapper.last(this.elementStack);d.getHtmlTagDefinition(e.name).isClosedByChild(t.name)&&this.elementStack.pop()}var n=d.getHtmlTagDefinition(t.name),e=this._getParentElement();if(n.requireExtraParent(u.isPresent(e)?e.name:null)){var r=new p.HtmlElementAst(n.parentToAdd,[],[t],t.sourceSpan,t.startSourceSpan,t.endSourceSpan);this._addToParent(r),this.elementStack.push(r),this.elementStack.push(t)}else this._addToParent(t),this.elementStack.push(t)},t.prototype._consumeEndTag=function(t){var e=r(t.parts[0],t.parts[1],this._getParentElement());this._getParentElement().endSourceSpan=t.sourceSpan,d.getHtmlTagDefinition(e).isVoid?this.errors.push(v.create(e,t.sourceSpan,'Void elements do not have end tags "'+t.parts[1]+'"')):this._popElement(e)||this.errors.push(v.create(e,t.sourceSpan,'Unexpected closing tag "'+t.parts[1]+'"'))},t.prototype._popElement=function(t){for(var e=this.elementStack.length-1;e>=0;e--){var n=this.elementStack[e];if(n.name==t)return c.ListWrapper.splice(this.elementStack,e,this.elementStack.length-e),!0;if(!d.getHtmlTagDefinition(n.name).closedByParent)return!1}return!1},t.prototype._consumeAttr=function(t){var e=d.mergeNsAndName(t.parts[0],t.parts[1]),n=t.sourceSpan.end,r="";if(this.peek.type===h.HtmlTokenType.ATTR_VALUE){var i=this._advance();r=i.parts[0],n=i.sourceSpan.end}return new p.HtmlAttrAst(e,r,new f.ParseSourceSpan(t.sourceSpan.start,n))},t.prototype._getParentElement=function(){return this.elementStack.length>0?c.ListWrapper.last(this.elementStack):null},t.prototype._addToParent=function(t){var e=this._getParentElement();u.isPresent(e)?e.children.push(t):this.rootNodes.push(t)},t}()},function(t,e,n){"use strict";function r(t,e,n){void 0===n&&(n=null);var r=[];return e.forEach(function(e){var o=e.visit(t,n);i.isPresent(o)&&r.push(o)}),r}var i=n(5),o=function(){function t(t,e){this.value=t,this.sourceSpan=e}return t.prototype.visit=function(t,e){return t.visitText(this,e)},t}();e.HtmlTextAst=o;var s=function(){function t(t,e,n,r,i){this.switchValue=t,this.type=e,this.cases=n,this.sourceSpan=r,this.switchValueSourceSpan=i}return t.prototype.visit=function(t,e){return t.visitExpansion(this,e)},t}();e.HtmlExpansionAst=s;var a=function(){function t(t,e,n,r,i){this.value=t,this.expression=e,this.sourceSpan=n,this.valueSourceSpan=r,this.expSourceSpan=i}return t.prototype.visit=function(t,e){return t.visitExpansionCase(this,e)},t}();e.HtmlExpansionCaseAst=a;var u=function(){function t(t,e,n){this.name=t,this.value=e,this.sourceSpan=n}return t.prototype.visit=function(t,e){return t.visitAttr(this,e)},t}();e.HtmlAttrAst=u;var c=function(){function t(t,e,n,r,i,o){this.name=t,this.attrs=e,this.children=n,this.sourceSpan=r,this.startSourceSpan=i,this.endSourceSpan=o}return t.prototype.visit=function(t,e){return t.visitElement(this,e)},t}();e.HtmlElementAst=c;var p=function(){function t(t,e){this.value=t,this.sourceSpan=e}return t.prototype.visit=function(t,e){return t.visitComment(this,e)},t}();e.HtmlCommentAst=p,e.htmlVisitAll=r},function(t,e,n){"use strict";function r(t,e,n){return void 0===n&&(n=!1),new ut(new P.ParseSourceFile(t,e),n).tokenize()}function i(t){var e=t===O?"EOF":_.StringWrapper.fromCharCode(t);return'Unexpected character "'+e+'"'}function o(t){return'Unknown entity "'+t+'" - use the "&#;" or "&#x;" syntax'}function s(t){return!a(t)||t===O}function a(t){return t>=T&&I>=t||t===ot}function u(t){return a(t)||t===q||t===L||t===V||t===k||t===X}function c(t){return(et>t||t>rt)&&(J>t||t>tt)&&(B>t||t>U)}function p(t){return t==F||t==O||!d(t)}function l(t){return t==F||t==O||!f(t)}function h(t,e){return t===K&&e!=K}function f(t){return t>=et&&rt>=t||t>=J&&tt>=t}function d(t){return t>=et&&nt>=t||t>=J&&Z>=t||t>=B&&U>=t}function v(t,e){return y(t)==y(e)}function y(t){return t>=et&&rt>=t?t-et+J:t}function m(t){for(var e,n=[],r=0;r=this.length)throw this._createError(i(O),this._getSpan());this.peek===x?(this.line++,this.column=0):this.peek!==x&&this.peek!==A&&this.column++,this.index++,this.peek=this.index>=this.length?O:_.StringWrapper.charCodeAt(this.input,this.index),this.nextPeek=this.index+1>=this.length?O:_.StringWrapper.charCodeAt(this.input,this.index+1)},t.prototype._attemptCharCode=function(t){return this.peek===t?(this._advance(),!0):!1},t.prototype._attemptCharCodeCaseInsensitive=function(t){return v(this.peek,t)?(this._advance(),!0):!1},t.prototype._requireCharCode=function(t){var e=this._getLocation();if(!this._attemptCharCode(t))throw this._createError(i(this.peek),this._getSpan(e,e))},t.prototype._attemptStr=function(t){for(var e=0;er.offset&&o.push(this.input.substring(r.offset,this.index));this.peek!==e;)o.push(this._readChar(t))}return this._endToken([this._processCarriageReturns(o.join(""))],r)},t.prototype._consumeComment=function(t){var e=this;this._beginToken(w.COMMENT_START,t),this._requireCharCode(j),this._endToken([]);var n=this._consumeRawText(!1,j,function(){return e._attemptStr("->")});this._beginToken(w.COMMENT_END,n.sourceSpan.end),this._endToken([])},t.prototype._consumeCdata=function(t){var e=this;this._beginToken(w.CDATA_START,t),this._requireStr("CDATA["),this._endToken([]);var n=this._consumeRawText(!1,z,function(){return e._attemptStr("]>")});this._beginToken(w.CDATA_END,n.sourceSpan.end),this._endToken([])},t.prototype._consumeDocType=function(t){this._beginToken(w.DOC_TYPE,t),this._attemptUntilChar(q),this._advance(),this._endToken([this.input.substring(t.offset+2,this.index-1)])},t.prototype._consumePrefixAndName=function(){for(var t=this.index,e=null;this.peek!==W&&!c(this.peek);)this._advance();var n;this.peek===W?(this._advance(),e=this.input.substring(t,this.index-1),n=this.index):n=t,this._requireCharCodeUntilFn(u,this.index===n?1:0);var r=this.input.substring(n,this.index);return[e,r]},t.prototype._consumeTagOpen=function(t){var e,n=this._savePosition();try{if(!f(this.peek))throw this._createError(i(this.peek),this._getSpan());var r=this.index;for(this._consumeTagOpenStart(t),e=this.input.substring(r,this.index).toLowerCase(),this._attemptCharCodeUntilFn(s);this.peek!==L&&this.peek!==q;)this._consumeAttributeName(),this._attemptCharCodeUntilFn(s),this._attemptCharCode(X)&&(this._attemptCharCodeUntilFn(s),this._consumeAttributeValue()),this._attemptCharCodeUntilFn(s);this._consumeTagOpenEnd()}catch(o){if(o instanceof at)return this._restorePosition(n),this._beginToken(w.TEXT,t),void this._endToken(["<"]);throw o}var a=E.getHtmlTagDefinition(e).contentType;a===E.HtmlTagContentType.RAW_TEXT?this._consumeRawTextWithTagClose(e,!1):a===E.HtmlTagContentType.ESCAPABLE_RAW_TEXT&&this._consumeRawTextWithTagClose(e,!0)},t.prototype._consumeRawTextWithTagClose=function(t,e){var n=this,r=this._consumeRawText(e,H,function(){return n._attemptCharCode(L)?(n._attemptCharCodeUntilFn(s),n._attemptStrCaseInsensitive(t)?(n._attemptCharCodeUntilFn(s),n._attemptCharCode(q)?!0:!1):!1):!1});this._beginToken(w.TAG_CLOSE,r.sourceSpan.end),this._endToken([null,t])},t.prototype._consumeTagOpenStart=function(t){this._beginToken(w.TAG_OPEN_START,t);var e=this._consumePrefixAndName();this._endToken(e)},t.prototype._consumeAttributeName=function(){this._beginToken(w.ATTR_NAME);var t=this._consumePrefixAndName();this._endToken(t)},t.prototype._consumeAttributeValue=function(){this._beginToken(w.ATTR_VALUE);var t;if(this.peek===V||this.peek===k){var e=this.peek;this._advance();for(var n=[];this.peek!==e;)n.push(this._readChar(!0));t=n.join(""),this._advance()}else{var r=this.index;this._requireCharCodeUntilFn(u,1),t=this.input.substring(r,this.index)}this._endToken([this._processCarriageReturns(t)])},t.prototype._consumeTagOpenEnd=function(){var t=this._attemptCharCode(L)?w.TAG_OPEN_END_VOID:w.TAG_OPEN_END;this._beginToken(t),this._requireCharCode(q),this._endToken([])},t.prototype._consumeTagClose=function(t){this._beginToken(w.TAG_CLOSE,t),this._attemptCharCodeUntilFn(s);var e;e=this._consumePrefixAndName(),this._attemptCharCodeUntilFn(s),this._requireCharCode(q),this._endToken(e)},t.prototype._consumeExpansionFormStart=function(){this._beginToken(w.EXPANSION_FORM_START,this._getLocation()),this._requireCharCode(K),this._endToken([]),this._beginToken(w.RAW_TEXT,this._getLocation());var t=this._readUntil(Q);this._endToken([t],this._getLocation()),this._requireCharCode(Q),this._attemptCharCodeUntilFn(s),this._beginToken(w.RAW_TEXT,this._getLocation());var e=this._readUntil(Q);this._endToken([e],this._getLocation()),this._requireCharCode(Q),this._attemptCharCodeUntilFn(s),this.expansionCaseStack.push(w.EXPANSION_FORM_START)},t.prototype._consumeExpansionCaseStart=function(){this._requireCharCode(X),this._beginToken(w.EXPANSION_CASE_VALUE,this._getLocation());var t=this._readUntil(K).trim();this._endToken([t],this._getLocation()),this._attemptCharCodeUntilFn(s),this._beginToken(w.EXPANSION_CASE_EXP_START,this._getLocation()),this._requireCharCode(K),this._endToken([],this._getLocation()),this._attemptCharCodeUntilFn(s),this.expansionCaseStack.push(w.EXPANSION_CASE_EXP_START)},t.prototype._consumeExpansionCaseEnd=function(){this._beginToken(w.EXPANSION_CASE_EXP_END,this._getLocation()),this._requireCharCode($),this._endToken([],this._getLocation()),this._attemptCharCodeUntilFn(s),this.expansionCaseStack.pop()},t.prototype._consumeExpansionFormEnd=function(){this._beginToken(w.EXPANSION_FORM_END,this._getLocation()),this._requireCharCode($),this._endToken([]),this.expansionCaseStack.pop()},t.prototype._consumeText=function(){var t=this._getLocation();this._beginToken(w.TEXT,t);var e=[],n=!1;for(this.peek===K&&this.nextPeek===K?(e.push(this._readChar(!0)),e.push(this._readChar(!0)),n=!0):e.push(this._readChar(!0));!this.isTextEnd(n);)this.peek===K&&this.nextPeek===K?(e.push(this._readChar(!0)),e.push(this._readChar(!0)),n=!0):this.peek===$&&this.nextPeek===$&&n?(e.push(this._readChar(!0)),e.push(this._readChar(!0)),n=!1):e.push(this._readChar(!0));this._endToken([this._processCarriageReturns(e.join(""))])},t.prototype.isTextEnd=function(t){if(this.peek===H||this.peek===O)return!0;if(this.tokenizeExpansionForms){if(h(this.peek,this.nextPeek))return!0;if(this.peek===$&&!t&&(this.isInExpansionCase()||this.isInExpansionForm()))return!0}return!1},t.prototype._savePosition=function(){return[this.peek,this.index,this.column,this.line,this.tokens.length]},t.prototype._readUntil=function(t){var e=this.index;return this._attemptUntilChar(t),this.input.substring(e,this.index)},t.prototype._restorePosition=function(t){this.peek=t[0],this.index=t[1],this.column=t[2],this.line=t[3];var e=t[4];e0&&this.expansionCaseStack[this.expansionCaseStack.length-1]===w.EXPANSION_CASE_EXP_START},t.prototype.isInExpansionForm=function(){return this.expansionCaseStack.length>0&&this.expansionCaseStack[this.expansionCaseStack.length-1]===w.EXPANSION_FORM_START},t}()},function(t,e){"use strict";var n=function(){function t(t,e,n,r){this.file=t,this.offset=e,this.line=n,this.col=r}return t.prototype.toString=function(){return this.file.url+"@"+this.line+":"+this.col},t}();e.ParseLocation=n;var r=function(){function t(t,e){this.content=t,this.url=e}return t}();e.ParseSourceFile=r;var i=function(){function t(t,e){this.start=t,this.end=e}return t.prototype.toString=function(){return this.start.file.content.substring(this.start.offset,this.end.offset)},t}();e.ParseSourceSpan=i;var o=function(){function t(t,e){this.span=t,this.msg=e}return t.prototype.toString=function(){var t=this.span.start.file.content,e=this.span.start.offset;e>t.length-1&&(e=t.length-1);for(var n=e,r=0,i=0;100>r&&e>0&&(e--,r++,"\n"!=t[e]||3!=++i););for(r=0,i=0;100>r&&n]"+t.substring(this.span.start.offset,n+1);return this.msg+' ("'+o+'"): '+this.span.start},t}();e.ParseError=o},function(t,e,n){"use strict";function r(t){var e=p[t.toLowerCase()];return a.isPresent(e)?e:l}function i(t){if("@"!=t[0])return[null,t];var e=a.RegExpWrapper.firstMatch(h,t);return[e[1],e[2]]}function o(t){return i(t)[0]}function s(t,e){return a.isPresent(t)?"@"+t+":"+e:e}var a=n(5);e.NAMED_ENTITIES=a.CONST_EXPR({Aacute:"Á",aacute:"á",Acirc:"Â",acirc:"â",acute:"´",AElig:"Æ",aelig:"æ",Agrave:"À",agrave:"à",alefsym:"ℵ",Alpha:"Α",alpha:"α",amp:"&",and:"∧",ang:"∠",apos:"'",Aring:"Å",aring:"å",asymp:"≈",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",bdquo:"„",Beta:"Β",beta:"β",brvbar:"¦",bull:"•",cap:"∩",Ccedil:"Ç",ccedil:"ç",cedil:"¸",cent:"¢",Chi:"Χ",chi:"χ",circ:"ˆ",clubs:"♣",cong:"≅",copy:"©",crarr:"↵",cup:"∪",curren:"¤",dagger:"†",Dagger:"‡",darr:"↓",dArr:"⇓",deg:"°",Delta:"Δ",delta:"δ",diams:"♦",divide:"÷",Eacute:"É",eacute:"é",Ecirc:"Ê",ecirc:"ê",Egrave:"È",egrave:"è",empty:"∅",emsp:" ",ensp:" ",Epsilon:"Ε",epsilon:"ε",equiv:"≡",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",exist:"∃",fnof:"ƒ",forall:"∀",frac12:"½",frac14:"¼",frac34:"¾",frasl:"⁄",Gamma:"Γ",gamma:"γ",ge:"≥",gt:">",harr:"↔",hArr:"⇔",hearts:"♥",hellip:"…",Iacute:"Í",iacute:"í",Icirc:"Î",icirc:"î",iexcl:"¡",Igrave:"Ì",igrave:"ì",image:"ℑ",infin:"∞","int":"∫",Iota:"Ι",iota:"ι",iquest:"¿",isin:"∈",Iuml:"Ï",iuml:"ï",Kappa:"Κ",kappa:"κ",Lambda:"Λ",lambda:"λ",lang:"⟨",laquo:"«",larr:"←",lArr:"⇐",lceil:"⌈",ldquo:"“",le:"≤",lfloor:"⌊",lowast:"∗",loz:"◊",lrm:"‎",lsaquo:"‹",lsquo:"‘",lt:"<",macr:"¯",mdash:"—",micro:"µ",middot:"·",minus:"−",Mu:"Μ",mu:"μ",nabla:"∇",nbsp:" ",ndash:"–",ne:"≠",ni:"∋",not:"¬",notin:"∉",nsub:"⊄",Ntilde:"Ñ",ntilde:"ñ",Nu:"Ν",nu:"ν",Oacute:"Ó",oacute:"ó",Ocirc:"Ô",ocirc:"ô",OElig:"Œ",oelig:"œ",Ograve:"Ò",ograve:"ò",oline:"‾",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",oplus:"⊕",or:"∨",ordf:"ª",ordm:"º",Oslash:"Ø",oslash:"ø",Otilde:"Õ",otilde:"õ",otimes:"⊗",Ouml:"Ö",ouml:"ö",para:"¶",permil:"‰",perp:"⊥",Phi:"Φ",phi:"φ",Pi:"Π",pi:"π",piv:"ϖ",plusmn:"±",pound:"£",prime:"′",Prime:"″",prod:"∏",prop:"∝",Psi:"Ψ",psi:"ψ",quot:'"',radic:"√",rang:"⟩",raquo:"»",rarr:"→",rArr:"⇒",rceil:"⌉",rdquo:"”",real:"ℜ",reg:"®",rfloor:"⌋",Rho:"Ρ",rho:"ρ",rlm:"‏",rsaquo:"›",rsquo:"’",sbquo:"‚",Scaron:"Š",scaron:"š",sdot:"⋅",sect:"§",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sim:"∼",spades:"♠",sub:"⊂",sube:"⊆",sum:"∑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supe:"⊇",szlig:"ß",Tau:"Τ",tau:"τ",there4:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thinsp:" ",THORN:"Þ",thorn:"þ",tilde:"˜",times:"×",trade:"™",Uacute:"Ú",uacute:"ú",uarr:"↑",uArr:"⇑",Ucirc:"Û",ucirc:"û",Ugrave:"Ù",ugrave:"ù",uml:"¨",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",Uuml:"Ü",uuml:"ü",weierp:"℘",Xi:"Ξ",xi:"ξ",Yacute:"Ý",yacute:"ý",yen:"¥",yuml:"ÿ",Yuml:"Ÿ",Zeta:"Ζ",zeta:"ζ",zwj:"‍",zwnj:"‌"}),function(t){t[t.RAW_TEXT=0]="RAW_TEXT",t[t.ESCAPABLE_RAW_TEXT=1]="ESCAPABLE_RAW_TEXT",t[t.PARSABLE_DATA=2]="PARSABLE_DATA"}(e.HtmlTagContentType||(e.HtmlTagContentType={}));var u=e.HtmlTagContentType,c=function(){function t(t){var e=this,n=void 0===t?{}:t,r=n.closedByChildren,i=n.requiredParents,o=n.implicitNamespacePrefix,s=n.contentType,c=n.closedByParent,p=n.isVoid,l=n.ignoreFirstLf;this.closedByChildren={},this.closedByParent=!1,a.isPresent(r)&&r.length>0&&r.forEach(function(t){return e.closedByChildren[t]=!0}),this.isVoid=a.normalizeBool(p),this.closedByParent=a.normalizeBool(c)||this.isVoid,a.isPresent(i)&&i.length>0&&(this.requiredParents={},this.parentToAdd=i[0],i.forEach(function(t){return e.requiredParents[t]=!0})),this.implicitNamespacePrefix=o,this.contentType=a.isPresent(s)?s:u.PARSABLE_DATA,this.ignoreFirstLf=a.normalizeBool(l)}return t.prototype.requireExtraParent=function(t){if(a.isBlank(this.requiredParents))return!1;if(a.isBlank(t))return!0;var e=t.toLowerCase();return 1!=this.requiredParents[e]&&"template"!=e},t.prototype.isClosedByChild=function(t){return this.isVoid||a.normalizeBool(this.closedByChildren[t.toLowerCase()])},t}();e.HtmlTagDefinition=c;var p={base:new c({isVoid:!0}),meta:new c({isVoid:!0}),area:new c({isVoid:!0}),embed:new c({isVoid:!0}),link:new c({isVoid:!0}),img:new c({isVoid:!0}),input:new c({isVoid:!0}),param:new c({isVoid:!0}),hr:new c({isVoid:!0}),br:new c({isVoid:!0}),source:new c({isVoid:!0}),track:new c({isVoid:!0}),wbr:new c({isVoid:!0}),p:new c({closedByChildren:["address","article","aside","blockquote","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","nav","ol","p","pre","section","table","ul"],closedByParent:!0}),thead:new c({closedByChildren:["tbody","tfoot"]}),tbody:new c({closedByChildren:["tbody","tfoot"],closedByParent:!0}),tfoot:new c({closedByChildren:["tbody"],closedByParent:!0}),tr:new c({closedByChildren:["tr"],requiredParents:["tbody","tfoot","thead"],closedByParent:!0}),td:new c({closedByChildren:["td","th"],closedByParent:!0}),th:new c({closedByChildren:["td","th"],closedByParent:!0}),col:new c({requiredParents:["colgroup"],isVoid:!0}),svg:new c({implicitNamespacePrefix:"svg"}),math:new c({implicitNamespacePrefix:"math"}),li:new c({closedByChildren:["li"],closedByParent:!0}),dt:new c({closedByChildren:["dt","dd"]}),dd:new c({closedByChildren:["dt","dd"],closedByParent:!0}),rb:new c({closedByChildren:["rb","rt","rtc","rp"],closedByParent:!0}),rt:new c({closedByChildren:["rb","rt","rtc","rp"],closedByParent:!0}),rtc:new c({closedByChildren:["rb","rtc","rp"],closedByParent:!0}),rp:new c({closedByChildren:["rb","rt","rtc","rp"],closedByParent:!0}),optgroup:new c({closedByChildren:["optgroup"],closedByParent:!0}),option:new c({closedByChildren:["option","optgroup"],closedByParent:!0}),pre:new c({ignoreFirstLf:!0}),listing:new c({ignoreFirstLf:!0}),style:new c({contentType:u.RAW_TEXT}),script:new c({contentType:u.RAW_TEXT}),title:new c({contentType:u.ESCAPABLE_RAW_TEXT}),textarea:new c({contentType:u.ESCAPABLE_RAW_TEXT,ignoreFirstLf:!0})},l=new c;e.getHtmlTagDefinition=r;var h=/^@([^:]+):(.+)/g;e.splitNsName=i,e.getNsPrefix=o,e.mergeNsAndName=s},function(t,e,n){"use strict";var r=n(15),i=n(5),o=n(12),s="",a=i.RegExpWrapper.create("(\\:not\\()|([-\\w]+)|(?:\\.([-\\w]+))|(?:\\[([-\\w*]+)(?:=([^\\]]*))?\\])|(\\))|(\\s*,\\s*)"),u=function(){function t(){this.element=null,this.classNames=[],this.attrs=[],this.notSelectors=[]}return t.parse=function(e){for(var n,s=[],u=function(t,e){e.notSelectors.length>0&&i.isBlank(e.element)&&r.ListWrapper.isEmpty(e.classNames)&&r.ListWrapper.isEmpty(e.attrs)&&(e.element="*"),t.push(e)},c=new t,p=i.RegExpWrapper.matcher(a,e),l=c,h=!1;i.isPresent(n=i.RegExpMatcherWrapper.next(p));){if(i.isPresent(n[1])){if(h)throw new o.BaseException("Nesting :not is not allowed in a selector");h=!0,l=new t,c.notSelectors.push(l)}if(i.isPresent(n[2])&&l.setElement(n[2]),i.isPresent(n[3])&&l.addClassName(n[3]),i.isPresent(n[4])&&l.addAttribute(n[4],n[5]),i.isPresent(n[6])&&(h=!1,l=c),i.isPresent(n[7])){if(h)throw new o.BaseException("Multiple selectors in :not are not supported");u(s,c),c=l=new t}}return u(s,c),s},t.prototype.isElementSelector=function(){return i.isPresent(this.element)&&r.ListWrapper.isEmpty(this.classNames)&&r.ListWrapper.isEmpty(this.attrs)&&0===this.notSelectors.length},t.prototype.setElement=function(t){void 0===t&&(t=null),this.element=t},t.prototype.getMatchingElementTemplate=function(){for(var t=i.isPresent(this.element)?this.element:"div",e=this.classNames.length>0?' class="'+this.classNames.join(" ")+'"':"",n="",r=0;r"},t.prototype.addAttribute=function(t,e){void 0===e&&(e=s),this.attrs.push(t),e=i.isPresent(e)?e.toLowerCase():s,this.attrs.push(e)},t.prototype.addClassName=function(t){this.classNames.push(t.toLowerCase())},t.prototype.toString=function(){var t="";if(i.isPresent(this.element)&&(t+=this.element),i.isPresent(this.classNames))for(var e=0;e0&&(t+="="+r),t+="]"}return this.notSelectors.forEach(function(e){return t+=":not("+e+")"}),t},t}();e.CssSelector=u;var c=function(){function t(){this._elementMap=new r.Map,this._elementPartialMap=new r.Map,this._classMap=new r.Map,this._classPartialMap=new r.Map,this._attrValueMap=new r.Map,this._attrValuePartialMap=new r.Map,this._listContexts=[]}return t.createNotMatcher=function(e){var n=new t;return n.addSelectables(e,null),n},t.prototype.addSelectables=function(t,e){var n=null;t.length>1&&(n=new p(t),this._listContexts.push(n));for(var r=0;r0&&(i.isBlank(this.listContext)||!this.listContext.alreadyMatched)){var r=c.createNotMatcher(this.notSelectors);n=!r.match(t,null)}return n&&i.isPresent(e)&&(i.isBlank(this.listContext)||!this.listContext.alreadyMatched)&&(i.isPresent(this.listContext)&&(this.listContext.alreadyMatched=!0),e(this.selector,this.cbContext)),n},t}();e.SelectorContext=l},function(t,e){"use strict";var n=function(){function t(){}return t.prototype.hasProperty=function(t,e){return!0},t.prototype.getMappedPropName=function(t){return t},t}();e.ElementSchemaRegistry=n},function(t,e,n){"use strict";function r(t){var e=null,n=null,r=null,o=!1,_=null;t.attrs.forEach(function(t){var i=t.name.toLowerCase();i==a?e=t.value:i==l?n=t.value:i==p?r=t.value:t.name==v?o=!0:t.name==y&&t.value.length>0&&(_=t.value)}),e=i(e);var b=t.name.toLowerCase(),P=m.OTHER;return s.splitNsName(b)[1]==u?P=m.NG_CONTENT:b==f?P=m.STYLE:b==d?P=m.SCRIPT:b==c&&r==h&&(P=m.STYLESHEET),new g(P,e,n,o,_)}function i(t){return o.isBlank(t)||0===t.length?"*":t}var o=n(5),s=n(148),a="select",u="ng-content",c="link",p="rel",l="href",h="stylesheet",f="style",d="script",v="ngNonBindable",y="ngProjectAs";e.preparseElement=r,function(t){t[t.NG_CONTENT=0]="NG_CONTENT",t[t.STYLE=1]="STYLE",t[t.STYLESHEET=2]="STYLESHEET",t[t.SCRIPT=3]="SCRIPT",t[t.OTHER=4]="OTHER"}(e.PreparsedElementType||(e.PreparsedElementType={}));var m=e.PreparsedElementType,g=function(){function t(t,e,n,r,i){this.type=t,this.selectAttr=e,this.hrefAttr=n,this.nonBindable=r,this.projectAs=i}return t}();e.PreparsedElement=g},function(t,e,n){"use strict";function r(t){if(o.isBlank(t)||0===t.length||"/"==t[0])return!1;var e=o.RegExpWrapper.firstMatch(u,t);return o.isBlank(e)||"package"==e[1]||"asset"==e[1]}function i(t,e,n){var i=[],u=o.StringWrapper.replaceAllMapped(n,a,function(n){var s=o.isPresent(n[1])?n[1]:n[2];return r(s)?(i.push(t.resolve(e,s)),""):n[0]});return new s(u,i)}var o=n(5),s=function(){function t(t,e){this.style=t,this.styleUrls=e}return t}();e.StyleWithImports=s,e.isStyleUrlResolvable=r,e.extractStyleUrls=i;var a=/@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g,u=/^([a-zA-Z\-\+\.]+):/g},function(t,e,n){"use strict";function r(t){return a.StringWrapper.replaceAllMapped(t,u,function(t){return"-"+t[1].toLowerCase()})}function i(t){return a.StringWrapper.replaceAllMapped(t,c,function(t){return t[1].toUpperCase()})}function o(t,e){var n=a.StringWrapper.split(t.trim(),/\s*:\s*/g);return n.length>1?n:e}function s(t){return a.StringWrapper.replaceAll(t,/\W/g,"_")}var a=n(5);e.MODULE_SUFFIX=a.IS_DART?".dart":"";var u=/([A-Z])/g,c=/-([a-z])/g;e.camelCaseToDashCase=r,e.dashCaseToCamelCase=i,e.splitAtColon=o,e.sanitizeIdentifier=s},function(t,e,n){"use strict";function r(t,e){var n=e.useExisting,r=e.useValue,i=e.deps;return new v.CompileProviderMetadata({token:t.token,useClass:t.useClass,useExisting:n,useFactory:t.useFactory,useValue:r,deps:i,multi:t.multi})}function i(t,e){var n=e.eager,r=e.providers;return new d.ProviderAst(t.token,t.multiProvider,t.eager||n,r,t.providerType,t.sourceSpan)}function o(t,e,n,r){return void 0===r&&(r=null),h.isBlank(r)&&(r=[]),h.isPresent(t)&&t.forEach(function(t){if(h.isArray(t))o(t,e,n,r);else{var i;t instanceof v.CompileProviderMetadata?i=t:t instanceof v.CompileTypeMetadata?i=new v.CompileProviderMetadata({token:new v.CompileTokenMetadata({identifier:t}),useClass:t}):n.push(new g("Unknown provider type "+t,e)),h.isPresent(i)&&r.push(i)}}),r}function s(t,e,n){var r=new v.CompileTokenMap;t.forEach(function(t){var i=new v.CompileProviderMetadata({token:new v.CompileTokenMetadata({identifier:t.type}),useClass:t.type});a([i],t.isComponent?d.ProviderAstType.Component:d.ProviderAstType.Directive,!0,e,n,r)});var i=t.filter(function(t){return t.isComponent}).concat(t.filter(function(t){return!t.isComponent}));return i.forEach(function(t){a(o(t.providers,e,n),d.ProviderAstType.PublicService,!1,e,n,r),a(o(t.viewProviders,e,n),d.ProviderAstType.PrivateService,!1,e,n,r)}),r}function a(t,e,n,r,i,o){t.forEach(function(t){var s=o.get(t.token);h.isPresent(s)&&s.multiProvider!==t.multi&&i.push(new g("Mixing multi and non multi provider is not possible for token "+s.token.name,r)),h.isBlank(s)?(s=new d.ProviderAst(t.token,t.multi,n,[t],e,r),o.add(t.token,s)):(t.multi||f.ListWrapper.clear(s.providers),s.providers.push(t))})}function u(t){var e=new v.CompileTokenMap;return h.isPresent(t.viewQueries)&&t.viewQueries.forEach(function(t){return p(e,t)}),t.type.diDeps.forEach(function(t){h.isPresent(t.viewQuery)&&p(e,t.viewQuery)}),e}function c(t){var e=new v.CompileTokenMap;return t.forEach(function(t){h.isPresent(t.queries)&&t.queries.forEach(function(t){return p(e,t)}),t.type.diDeps.forEach(function(t){h.isPresent(t.query)&&p(e,t.query)})}),e}function p(t,e){e.selectors.forEach(function(n){var r=t.get(n);h.isBlank(r)&&(r=[],t.add(n,r)),r.push(e)})}var l=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},h=n(5),f=n(15),d=n(139),v=n(155),y=n(158),m=n(147),g=function(t){function e(e,n){t.call(this,n,e)}return l(e,t),e}(m.ParseError);e.ProviderError=g;var _=function(){function t(t,e){var n=this;this.component=t,this.sourceSpan=e,this.errors=[],this.viewQueries=u(t),this.viewProviders=new v.CompileTokenMap,o(t.viewProviders,e,this.errors).forEach(function(t){h.isBlank(n.viewProviders.get(t.token))&&n.viewProviders.add(t.token,!0)})}return t}();e.ProviderViewContext=_;var b=function(){function t(t,e,n,r,i,o,a){var u=this;this._viewContext=t,this._parent=e,this._isViewRoot=n,this._directiveAsts=r,this._sourceSpan=a,this._transformedProviders=new v.CompileTokenMap,this._seenProviders=new v.CompileTokenMap,this._hasViewContainer=!1,this._attrs={},i.forEach(function(t){return u._attrs[t.name]=t.value});var p=r.map(function(t){return t.directive});this._allProviders=s(p,a,t.errors),this._contentQueries=c(p);var l=new v.CompileTokenMap;this._allProviders.values().forEach(function(t){u._addQueryReadsTo(t.token,l)}),o.forEach(function(t){var e=new v.CompileTokenMetadata({value:t.name});u._addQueryReadsTo(e,l)}),h.isPresent(l.get(y.identifierToken(y.Identifiers.ViewContainerRef)))&&(this._hasViewContainer=!0),this._allProviders.values().forEach(function(t){var e=t.eager||h.isPresent(l.get(t.token));e&&u._getOrCreateLocalProvider(t.providerType,t.token,!0)})}return t.prototype.afterElement=function(){var t=this;this._allProviders.values().forEach(function(e){t._getOrCreateLocalProvider(e.providerType,e.token,!1)})},Object.defineProperty(t.prototype,"transformProviders",{get:function(){return this._transformedProviders.values()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transformedDirectiveAsts",{get:function(){var t=this._transformedProviders.values().map(function(t){return t.token.identifier}),e=f.ListWrapper.clone(this._directiveAsts);return f.ListWrapper.sort(e,function(e,n){return t.indexOf(e.directive.type)-t.indexOf(n.directive.type)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transformedHasViewContainer",{get:function(){return this._hasViewContainer},enumerable:!0,configurable:!0}),t.prototype._addQueryReadsTo=function(t,e){this._getQueriesFor(t).forEach(function(n){var r=h.isPresent(n.read)?n.read:t;h.isBlank(e.get(r))&&e.add(r,!0)})},t.prototype._getQueriesFor=function(t){for(var e,n=[],r=this,i=0;null!==r;)e=r._contentQueries.get(t),h.isPresent(e)&&f.ListWrapper.addAll(n,e.filter(function(t){return t.descendants||1>=i})),r._directiveAsts.length>0&&i++,r=r._parent;return e=this._viewContext.viewQueries.get(t),h.isPresent(e)&&f.ListWrapper.addAll(n,e),n},t.prototype._getOrCreateLocalProvider=function(t,e,n){var o=this,s=this._allProviders.get(e);if(h.isBlank(s)||(t===d.ProviderAstType.Directive||t===d.ProviderAstType.PublicService)&&s.providerType===d.ProviderAstType.PrivateService||(t===d.ProviderAstType.PrivateService||t===d.ProviderAstType.PublicService)&&s.providerType===d.ProviderAstType.Builtin)return null;var a=this._transformedProviders.get(e);if(h.isPresent(a))return a;if(h.isPresent(this._seenProviders.get(e)))return this._viewContext.errors.push(new g("Cannot instantiate cyclic dependency! "+e.name,this._sourceSpan)),null;this._seenProviders.add(e,!0);var u=s.providers.map(function(t){var e,i=t.useValue,a=t.useExisting;if(h.isPresent(t.useExisting)){var u=o._getDependency(s.providerType,new v.CompileDiDependencyMetadata({token:t.useExisting}),n);h.isPresent(u.token)?a=u.token:(a=null,i=u.value)}else if(h.isPresent(t.useFactory)){var c=h.isPresent(t.deps)?t.deps:t.useFactory.diDeps;e=c.map(function(t){return o._getDependency(s.providerType,t,n)})}else if(h.isPresent(t.useClass)){var c=h.isPresent(t.deps)?t.deps:t.useClass.diDeps;e=c.map(function(t){return o._getDependency(s.providerType,t,n)})}return r(t,{useExisting:a,useValue:i,deps:e})});return a=i(s,{eager:n,providers:u}),this._transformedProviders.add(e,a),a},t.prototype._getLocalDependency=function(t,e,n){if(void 0===n&&(n=null),e.isAttribute){var r=this._attrs[e.token.value];return new v.CompileDiDependencyMetadata({isValue:!0,value:h.normalizeBlank(r)})}if(h.isPresent(e.query)||h.isPresent(e.viewQuery))return e;if(h.isPresent(e.token)){if(t===d.ProviderAstType.Directive||t===d.ProviderAstType.Component){if(e.token.equalsTo(y.identifierToken(y.Identifiers.Renderer))||e.token.equalsTo(y.identifierToken(y.Identifiers.ElementRef))||e.token.equalsTo(y.identifierToken(y.Identifiers.ChangeDetectorRef))||e.token.equalsTo(y.identifierToken(y.Identifiers.TemplateRef)))return e;e.token.equalsTo(y.identifierToken(y.Identifiers.ViewContainerRef))&&(this._hasViewContainer=!0)}if(e.token.equalsTo(y.identifierToken(y.Identifiers.Injector)))return e;if(h.isPresent(this._getOrCreateLocalProvider(t,e.token,n)))return e}return null},t.prototype._getDependency=function(t,e,n){void 0===n&&(n=null);var r=this,i=n,o=null;if(e.isSkipSelf||(o=this._getLocalDependency(t,e,n)),e.isSelf)h.isBlank(o)&&e.isOptional&&(o=new v.CompileDiDependencyMetadata({isValue:!0,value:null}));else{for(;h.isBlank(o)&&h.isPresent(r._parent);){var s=r;r=r._parent,s._isViewRoot&&(i=!1),o=r._getLocalDependency(d.ProviderAstType.PublicService,e,i)}h.isBlank(o)&&(o=!e.isHost||this._viewContext.component.type.isHost||y.identifierToken(this._viewContext.component.type).equalsTo(e.token)||h.isPresent(this._viewContext.viewProviders.get(e.token))?e:e.isOptional?o=new v.CompileDiDependencyMetadata({ -isValue:!0,value:null}):null)}return h.isBlank(o)&&this._viewContext.errors.push(new g("No provider for "+e.token.name,this._sourceSpan)),o},t}();e.ProviderElementContext=b},function(t,e,n){"use strict";function r(t){return N[t["class"]](t)}function i(t,e){var n=y.CssSelector.parse(e)[0].getMatchingElementTemplate();return M.create({type:new x({runtime:Object,name:t.name+"_Host",moduleUrl:t.moduleUrl,isHost:!0}),template:new I({template:n,templateUrl:"",styles:[],styleUrls:[],ngContentSelectors:[]}),changeDetection:d.ChangeDetectionStrategy.Default,inputs:[],outputs:[],host:{},lifecycleHooks:[],isComponent:!0,selector:"*",providers:[],viewProviders:[],queries:[],viewQueries:[]})}function o(t,e){return l.isBlank(t)?null:t.map(function(t){return a(t,e)})}function s(t){return l.isBlank(t)?null:t.map(u)}function a(t,e){return l.isArray(t)?o(t,e):l.isString(t)||l.isBlank(t)||l.isBoolean(t)||l.isNumber(t)?t:e(t)}function u(t){return l.isArray(t)?s(t):l.isString(t)||l.isBlank(t)||l.isBoolean(t)||l.isNumber(t)?t:t.toJson()}function c(t){return l.isPresent(t)?t:[]}var p=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},l=n(5),h=n(12),f=n(15),d=n(28),v=n(36),y=n(149),m=n(153),g=n(156),_=n(157),b=/^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))$/g,P=function(){function t(){}return Object.defineProperty(t.prototype,"identifier",{get:function(){return h.unimplemented()},enumerable:!0,configurable:!0}),t}();e.CompileMetadataWithIdentifier=P;var E=function(t){function e(){t.apply(this,arguments)}return p(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return h.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return h.unimplemented()},enumerable:!0,configurable:!0}),e}(P);e.CompileMetadataWithType=E,e.metadataFromJson=r;var w=function(){function t(t){var e=void 0===t?{}:t,n=e.runtime,r=e.name,i=e.moduleUrl,o=e.prefix,s=e.value;this.runtime=n,this.name=r,this.prefix=o,this.moduleUrl=i,this.value=s}return t.fromJson=function(e){var n=l.isArray(e.value)?o(e.value,r):a(e.value,r);return new t({name:e.name,prefix:e.prefix,moduleUrl:e.moduleUrl,value:n})},t.prototype.toJson=function(){var t=l.isArray(this.value)?s(this.value):u(this.value);return{"class":"Identifier",name:this.name,moduleUrl:this.moduleUrl,prefix:this.prefix,value:t}},Object.defineProperty(t.prototype,"identifier",{get:function(){return this},enumerable:!0,configurable:!0}),t}();e.CompileIdentifierMetadata=w;var C=function(){function t(t){var e=void 0===t?{}:t,n=e.isAttribute,r=e.isSelf,i=e.isHost,o=e.isSkipSelf,s=e.isOptional,a=e.isValue,u=e.query,c=e.viewQuery,p=e.token,h=e.value;this.isAttribute=l.normalizeBool(n),this.isSelf=l.normalizeBool(r),this.isHost=l.normalizeBool(i),this.isSkipSelf=l.normalizeBool(o),this.isOptional=l.normalizeBool(s),this.isValue=l.normalizeBool(a),this.query=u,this.viewQuery=c,this.token=p,this.value=h}return t.fromJson=function(e){return new t({token:a(e.token,O.fromJson),query:a(e.query,A.fromJson),viewQuery:a(e.viewQuery,A.fromJson),value:e.value,isAttribute:e.isAttribute,isSelf:e.isSelf,isHost:e.isHost,isSkipSelf:e.isSkipSelf,isOptional:e.isOptional,isValue:e.isValue})},t.prototype.toJson=function(){return{token:u(this.token),query:u(this.query),viewQuery:u(this.viewQuery),value:this.value,isAttribute:this.isAttribute,isSelf:this.isSelf,isHost:this.isHost,isSkipSelf:this.isSkipSelf,isOptional:this.isOptional,isValue:this.isValue}},t}();e.CompileDiDependencyMetadata=C;var R=function(){function t(t){var e=t.token,n=t.useClass,r=t.useValue,i=t.useExisting,o=t.useFactory,s=t.deps,a=t.multi;this.token=e,this.useClass=n,this.useValue=r,this.useExisting=i,this.useFactory=o,this.deps=l.normalizeBlank(s),this.multi=l.normalizeBool(a)}return t.fromJson=function(e){return new t({token:a(e.token,O.fromJson),useClass:a(e.useClass,x.fromJson),useExisting:a(e.useExisting,O.fromJson),useValue:a(e.useValue,w.fromJson),useFactory:a(e.useFactory,S.fromJson),multi:e.multi,deps:o(e.deps,C.fromJson)})},t.prototype.toJson=function(){return{"class":"Provider",token:u(this.token),useClass:u(this.useClass),useExisting:u(this.useExisting),useValue:u(this.useValue),useFactory:u(this.useFactory),multi:this.multi,deps:s(this.deps)}},t}();e.CompileProviderMetadata=R;var S=function(){function t(t){var e=t.runtime,n=t.name,r=t.moduleUrl,i=t.prefix,o=t.diDeps,s=t.value;this.runtime=e,this.name=n,this.prefix=i,this.moduleUrl=r,this.diDeps=c(o),this.value=s}return Object.defineProperty(t.prototype,"identifier",{get:function(){return this},enumerable:!0,configurable:!0}),t.fromJson=function(e){return new t({name:e.name,prefix:e.prefix,moduleUrl:e.moduleUrl,value:e.value,diDeps:o(e.diDeps,C.fromJson)})},t.prototype.toJson=function(){return{"class":"Factory",name:this.name,prefix:this.prefix,moduleUrl:this.moduleUrl,value:this.value,diDeps:s(this.diDeps)}},t}();e.CompileFactoryMetadata=S;var O=function(){function t(t){var e=t.value,n=t.identifier,r=t.identifierIsInstance;this.value=e,this.identifier=n,this.identifierIsInstance=l.normalizeBool(r)}return t.fromJson=function(e){return new t({value:e.value,identifier:a(e.identifier,w.fromJson),identifierIsInstance:e.identifierIsInstance})},t.prototype.toJson=function(){return{value:this.value,identifier:u(this.identifier),identifierIsInstance:this.identifierIsInstance}},Object.defineProperty(t.prototype,"runtimeCacheKey",{get:function(){return l.isPresent(this.identifier)?this.identifier.runtime:this.value},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"assetCacheKey",{get:function(){return l.isPresent(this.identifier)?l.isPresent(this.identifier.moduleUrl)&&l.isPresent(_.getUrlScheme(this.identifier.moduleUrl))?this.identifier.name+"|"+this.identifier.moduleUrl+"|"+this.identifierIsInstance:null:this.value},enumerable:!0,configurable:!0}),t.prototype.equalsTo=function(t){var e=this.runtimeCacheKey,n=this.assetCacheKey;return l.isPresent(e)&&e==t.runtimeCacheKey||l.isPresent(n)&&n==t.assetCacheKey},Object.defineProperty(t.prototype,"name",{get:function(){return l.isPresent(this.value)?m.sanitizeIdentifier(this.value):this.identifier.name},enumerable:!0,configurable:!0}),t}();e.CompileTokenMetadata=O;var T=function(){function t(){this._valueMap=new Map,this._values=[]}return t.prototype.add=function(t,e){var n=this.get(t);if(l.isPresent(n))throw new h.BaseException("Can only add to a TokenMap! Token: "+t.name);this._values.push(e);var r=t.runtimeCacheKey;l.isPresent(r)&&this._valueMap.set(r,e);var i=t.assetCacheKey;l.isPresent(i)&&this._valueMap.set(i,e)},t.prototype.get=function(t){var e,n=t.runtimeCacheKey,r=t.assetCacheKey;return l.isPresent(n)&&(e=this._valueMap.get(n)),l.isBlank(e)&&l.isPresent(r)&&(e=this._valueMap.get(r)),e},t.prototype.values=function(){return this._values},Object.defineProperty(t.prototype,"size",{get:function(){return this._values.length},enumerable:!0,configurable:!0}),t}();e.CompileTokenMap=T;var x=function(){function t(t){var e=void 0===t?{}:t,n=e.runtime,r=e.name,i=e.moduleUrl,o=e.prefix,s=e.isHost,a=e.value,u=e.diDeps;this.runtime=n,this.name=r,this.moduleUrl=i,this.prefix=o,this.isHost=l.normalizeBool(s),this.value=a,this.diDeps=c(u)}return t.fromJson=function(e){return new t({name:e.name,moduleUrl:e.moduleUrl,prefix:e.prefix,isHost:e.isHost,value:e.value,diDeps:o(e.diDeps,C.fromJson)})},Object.defineProperty(t.prototype,"identifier",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this},enumerable:!0,configurable:!0}),t.prototype.toJson=function(){return{"class":"Type",name:this.name,moduleUrl:this.moduleUrl,prefix:this.prefix,isHost:this.isHost,value:this.value,diDeps:s(this.diDeps)}},t}();e.CompileTypeMetadata=x;var A=function(){function t(t){var e=void 0===t?{}:t,n=e.selectors,r=e.descendants,i=e.first,o=e.propertyName,s=e.read;this.selectors=n,this.descendants=l.normalizeBool(r),this.first=l.normalizeBool(i),this.propertyName=o,this.read=s}return t.fromJson=function(e){return new t({selectors:o(e.selectors,O.fromJson),descendants:e.descendants,first:e.first,propertyName:e.propertyName,read:a(e.read,O.fromJson)})},t.prototype.toJson=function(){return{selectors:s(this.selectors),descendants:this.descendants,first:this.first,propertyName:this.propertyName,read:u(this.read)}},t}();e.CompileQueryMetadata=A;var I=function(){function t(t){var e=void 0===t?{}:t,n=e.encapsulation,r=e.template,i=e.templateUrl,o=e.styles,s=e.styleUrls,a=e.ngContentSelectors;this.encapsulation=l.isPresent(n)?n:v.ViewEncapsulation.Emulated,this.template=r,this.templateUrl=i,this.styles=l.isPresent(o)?o:[],this.styleUrls=l.isPresent(s)?s:[],this.ngContentSelectors=l.isPresent(a)?a:[]}return t.fromJson=function(e){return new t({encapsulation:l.isPresent(e.encapsulation)?v.VIEW_ENCAPSULATION_VALUES[e.encapsulation]:e.encapsulation,template:e.template,templateUrl:e.templateUrl,styles:e.styles,styleUrls:e.styleUrls,ngContentSelectors:e.ngContentSelectors})},t.prototype.toJson=function(){return{encapsulation:l.isPresent(this.encapsulation)?l.serializeEnum(this.encapsulation):this.encapsulation,template:this.template,templateUrl:this.templateUrl,styles:this.styles,styleUrls:this.styleUrls,ngContentSelectors:this.ngContentSelectors}},t}();e.CompileTemplateMetadata=I;var M=function(){function t(t){var e=void 0===t?{}:t,n=e.type,r=e.isComponent,i=e.selector,o=e.exportAs,s=e.changeDetection,a=e.inputs,u=e.outputs,p=e.hostListeners,l=e.hostProperties,h=e.hostAttributes,f=e.lifecycleHooks,d=e.providers,v=e.viewProviders,y=e.queries,m=e.viewQueries,g=e.template;this.type=n,this.isComponent=r,this.selector=i,this.exportAs=o,this.changeDetection=s,this.inputs=a,this.outputs=u,this.hostListeners=p,this.hostProperties=l,this.hostAttributes=h,this.lifecycleHooks=c(f),this.providers=c(d),this.viewProviders=c(v),this.queries=c(y),this.viewQueries=c(m),this.template=g}return t.create=function(e){var n=void 0===e?{}:e,r=n.type,i=n.isComponent,o=n.selector,s=n.exportAs,a=n.changeDetection,u=n.inputs,c=n.outputs,p=n.host,h=n.lifecycleHooks,d=n.providers,v=n.viewProviders,y=n.queries,g=n.viewQueries,_=n.template,P={},E={},w={};l.isPresent(p)&&f.StringMapWrapper.forEach(p,function(t,e){var n=l.RegExpWrapper.firstMatch(b,e);l.isBlank(n)?w[e]=t:l.isPresent(n[1])?E[n[1]]=t:l.isPresent(n[2])&&(P[n[2]]=t)});var C={};l.isPresent(u)&&u.forEach(function(t){var e=m.splitAtColon(t,[t,t]);C[e[0]]=e[1]});var R={};return l.isPresent(c)&&c.forEach(function(t){var e=m.splitAtColon(t,[t,t]);R[e[0]]=e[1]}),new t({type:r,isComponent:l.normalizeBool(i),selector:o,exportAs:s,changeDetection:a,inputs:C,outputs:R,hostListeners:P,hostProperties:E,hostAttributes:w,lifecycleHooks:l.isPresent(h)?h:[],providers:d,viewProviders:v,queries:y,viewQueries:g,template:_})},Object.defineProperty(t.prototype,"identifier",{get:function(){return this.type},enumerable:!0,configurable:!0}),t.fromJson=function(e){return new t({isComponent:e.isComponent,selector:e.selector,exportAs:e.exportAs,type:l.isPresent(e.type)?x.fromJson(e.type):e.type,changeDetection:l.isPresent(e.changeDetection)?d.CHANGE_DETECTION_STRATEGY_VALUES[e.changeDetection]:e.changeDetection,inputs:e.inputs,outputs:e.outputs,hostListeners:e.hostListeners,hostProperties:e.hostProperties,hostAttributes:e.hostAttributes,lifecycleHooks:e.lifecycleHooks.map(function(t){return g.LIFECYCLE_HOOKS_VALUES[t]}),template:l.isPresent(e.template)?I.fromJson(e.template):e.template,providers:o(e.providers,r),viewProviders:o(e.viewProviders,r),queries:o(e.queries,A.fromJson),viewQueries:o(e.viewQueries,A.fromJson)})},t.prototype.toJson=function(){return{"class":"Directive",isComponent:this.isComponent,selector:this.selector,exportAs:this.exportAs,type:l.isPresent(this.type)?this.type.toJson():this.type,changeDetection:l.isPresent(this.changeDetection)?l.serializeEnum(this.changeDetection):this.changeDetection,inputs:this.inputs,outputs:this.outputs,hostListeners:this.hostListeners,hostProperties:this.hostProperties,hostAttributes:this.hostAttributes,lifecycleHooks:this.lifecycleHooks.map(function(t){return l.serializeEnum(t)}),template:l.isPresent(this.template)?this.template.toJson():this.template,providers:s(this.providers),viewProviders:s(this.viewProviders),queries:s(this.queries),viewQueries:s(this.viewQueries)}},t}();e.CompileDirectiveMetadata=M,e.createHostComponentMeta=i;var k=function(){function t(t){var e=void 0===t?{}:t,n=e.type,r=e.name,i=e.pure,o=e.lifecycleHooks;this.type=n,this.name=r,this.pure=l.normalizeBool(i),this.lifecycleHooks=c(o)}return Object.defineProperty(t.prototype,"identifier",{get:function(){return this.type},enumerable:!0,configurable:!0}),t.fromJson=function(e){return new t({type:l.isPresent(e.type)?x.fromJson(e.type):e.type,name:e.name,pure:e.pure})},t.prototype.toJson=function(){return{"class":"Pipe",type:l.isPresent(this.type)?this.type.toJson():null,name:this.name,pure:this.pure}},t}();e.CompilePipeMetadata=k;var N={Directive:M.fromJson,Pipe:k.fromJson,Type:x.fromJson,Provider:R.fromJson,Identifier:w.fromJson,Factory:S.fromJson}},function(t,e){"use strict";!function(t){t[t.OnInit=0]="OnInit",t[t.OnDestroy=1]="OnDestroy",t[t.DoCheck=2]="DoCheck",t[t.OnChanges=3]="OnChanges",t[t.AfterContentInit=4]="AfterContentInit",t[t.AfterContentChecked=5]="AfterContentChecked",t[t.AfterViewInit=6]="AfterViewInit",t[t.AfterViewChecked=7]="AfterViewChecked"}(e.LifecycleHooks||(e.LifecycleHooks={}));var n=e.LifecycleHooks;e.LIFECYCLE_HOOKS_VALUES=[n.OnInit,n.OnDestroy,n.DoCheck,n.OnChanges,n.AfterContentInit,n.AfterContentChecked,n.AfterViewInit,n.AfterViewChecked]},function(t,e,n){"use strict";function r(){return new _}function i(){return new _(g)}function o(t){var e=a(t);return e&&e[b.Scheme]||""}function s(t,e,n,r,i,o,s){var a=[];return v.isPresent(t)&&a.push(t+":"),v.isPresent(n)&&(a.push("//"),v.isPresent(e)&&a.push(e+"@"),a.push(n),v.isPresent(r)&&a.push(":"+r)),v.isPresent(i)&&a.push(i),v.isPresent(o)&&a.push("?"+o),v.isPresent(s)&&a.push("#"+s),a.join("")}function a(t){return v.RegExpWrapper.firstMatch(P,t)}function u(t){if("/"==t)return"/";for(var e="/"==t[0]?"/":"",n="/"===t[t.length-1]?"/":"",r=t.split("/"),i=[],o=0,s=0;s0?i.pop():o++;break;default:i.push(a)}}if(""==e){for(;o-- >0;)i.unshift("..");0===i.length&&i.push(".")}return e+i.join("/")+n}function c(t){var e=t[b.Path];return e=v.isBlank(e)?"":u(e),t[b.Path]=e,s(t[b.Scheme],t[b.UserInfo],t[b.Domain],t[b.Port],e,t[b.QueryData],t[b.Fragment])}function p(t,e){var n=a(encodeURI(e)),r=a(t);if(v.isPresent(n[b.Scheme]))return c(n);n[b.Scheme]=r[b.Scheme];for(var i=b.Scheme;i<=b.Port;i++)v.isBlank(n[i])&&(n[i]=r[i]);if("/"==n[b.Path][0])return c(n);var o=r[b.Path];v.isBlank(o)&&(o="/");var s=o.lastIndexOf("/");return o=o.substring(0,s+1)+n[b.Path],n[b.Path]=o,c(n)}var l=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},h=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},f=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},d=n(6),v=n(5),y=n(62),m=n(6),g="asset:";e.createUrlResolverWithoutPackagePrefix=r,e.createOfflineCompileUrlResolver=i,e.DEFAULT_PACKAGE_URL_PROVIDER=new m.Provider(y.PACKAGE_ROOT_URL,{useValue:"/"});var _=function(){function t(t){void 0===t&&(t=null),this._packagePrefix=t}return t.prototype.resolve=function(t,e){var n=e;v.isPresent(t)&&t.length>0&&(n=p(t,n));var r=a(n),i=this._packagePrefix;if(v.isPresent(i)&&v.isPresent(r)&&"package"==r[b.Scheme]){var o=r[b.Path];if(this._packagePrefix!==g)return i=v.StringWrapper.stripRight(i,"/"),o=v.StringWrapper.stripLeft(o,"/"),i+"/"+o;var s=o.split(/\//);n="asset:"+s[0]+"/lib/"+s.slice(1).join("/")}return n},t=l([d.Injectable(),f(0,d.Inject(y.PACKAGE_ROOT_URL)),h("design:paramtypes",[String])],t)}();e.UrlResolver=_,e.getUrlScheme=o;var b,P=v.RegExpWrapper.create("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([\\w\\d\\-\\u0100-\\uffff.%]*)(?::([0-9]+))?)?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$");!function(t){t[t.Scheme=1]="Scheme",t[t.UserInfo=2]="UserInfo",t[t.Domain=3]="Domain",t[t.Port=4]="Port",t[t.Path=5]="Path",t[t.QueryData=6]="QueryData",t[t.Fragment=7]="Fragment"}(b||(b={}))},function(t,e,n){"use strict";function r(t){return new i.CompileTokenMetadata({identifier:t})}var i=n(155),o=n(159),s=n(160),a=n(66),u=n(28),c=n(67),p=n(69),l=n(70),h=n(74),f=n(36),d=n(68),v=n(78),y=n(11),m=n(81),g=n(153),_="asset:angular2/lib/src/core/linker/view"+g.MODULE_SUFFIX,b="asset:angular2/lib/src/core/linker/view_utils"+g.MODULE_SUFFIX,P="asset:angular2/lib/src/core/change_detection/change_detection"+g.MODULE_SUFFIX,E=a.ViewUtils,w=o.AppView,C=s.DebugContext,R=c.AppElement,S=p.ElementRef,O=l.ViewContainerRef,T=u.ChangeDetectorRef,x=h.RenderComponentType,A=v.QueryList,I=m.TemplateRef,M=m.TemplateRef_,k=u.ValueUnwrapper,N=y.Injector,D=f.ViewEncapsulation,V=d.ViewType,j=u.ChangeDetectionStrategy,L=s.StaticNodeDebugInfo,B=h.Renderer,F=u.SimpleChange,U=u.uninitialized,W=u.ChangeDetectorState,H=a.flattenNestedViewRenderNodes,X=u.devModeEqual,q=a.interpolate,G=a.checkBinding,z=a.castByValue,K=function(){function t(){}return t.ViewUtils=new i.CompileIdentifierMetadata({name:"ViewUtils",moduleUrl:"asset:angular2/lib/src/core/linker/view_utils"+g.MODULE_SUFFIX,runtime:E}),t.AppView=new i.CompileIdentifierMetadata({name:"AppView",moduleUrl:_,runtime:w}),t.AppElement=new i.CompileIdentifierMetadata({name:"AppElement",moduleUrl:"asset:angular2/lib/src/core/linker/element"+g.MODULE_SUFFIX,runtime:R}),t.ElementRef=new i.CompileIdentifierMetadata({name:"ElementRef",moduleUrl:"asset:angular2/lib/src/core/linker/element_ref"+g.MODULE_SUFFIX,runtime:S}),t.ViewContainerRef=new i.CompileIdentifierMetadata({name:"ViewContainerRef",moduleUrl:"asset:angular2/lib/src/core/linker/view_container_ref"+g.MODULE_SUFFIX,runtime:O}),t.ChangeDetectorRef=new i.CompileIdentifierMetadata({name:"ChangeDetectorRef",moduleUrl:"asset:angular2/lib/src/core/change_detection/change_detector_ref"+g.MODULE_SUFFIX,runtime:T}),t.RenderComponentType=new i.CompileIdentifierMetadata({name:"RenderComponentType",moduleUrl:"asset:angular2/lib/src/core/render/api"+g.MODULE_SUFFIX,runtime:x}),t.QueryList=new i.CompileIdentifierMetadata({name:"QueryList",moduleUrl:"asset:angular2/lib/src/core/linker/query_list"+g.MODULE_SUFFIX,runtime:A}),t.TemplateRef=new i.CompileIdentifierMetadata({name:"TemplateRef",moduleUrl:"asset:angular2/lib/src/core/linker/template_ref"+g.MODULE_SUFFIX,runtime:I}),t.TemplateRef_=new i.CompileIdentifierMetadata({name:"TemplateRef_",moduleUrl:"asset:angular2/lib/src/core/linker/template_ref"+g.MODULE_SUFFIX,runtime:M}),t.ValueUnwrapper=new i.CompileIdentifierMetadata({name:"ValueUnwrapper",moduleUrl:P,runtime:k}),t.Injector=new i.CompileIdentifierMetadata({name:"Injector",moduleUrl:"asset:angular2/lib/src/core/di/injector"+g.MODULE_SUFFIX,runtime:N}),t.ViewEncapsulation=new i.CompileIdentifierMetadata({name:"ViewEncapsulation",moduleUrl:"asset:angular2/lib/src/core/metadata/view"+g.MODULE_SUFFIX,runtime:D}),t.ViewType=new i.CompileIdentifierMetadata({name:"ViewType",moduleUrl:"asset:angular2/lib/src/core/linker/view_type"+g.MODULE_SUFFIX,runtime:V}),t.ChangeDetectionStrategy=new i.CompileIdentifierMetadata({name:"ChangeDetectionStrategy",moduleUrl:P,runtime:j}),t.StaticNodeDebugInfo=new i.CompileIdentifierMetadata({name:"StaticNodeDebugInfo",moduleUrl:"asset:angular2/lib/src/core/linker/debug_context"+g.MODULE_SUFFIX,runtime:L}),t.DebugContext=new i.CompileIdentifierMetadata({name:"DebugContext",moduleUrl:"asset:angular2/lib/src/core/linker/debug_context"+g.MODULE_SUFFIX,runtime:C}),t.Renderer=new i.CompileIdentifierMetadata({name:"Renderer",moduleUrl:"asset:angular2/lib/src/core/render/api"+g.MODULE_SUFFIX,runtime:B}),t.SimpleChange=new i.CompileIdentifierMetadata({name:"SimpleChange",moduleUrl:P,runtime:F}),t.uninitialized=new i.CompileIdentifierMetadata({name:"uninitialized",moduleUrl:P,runtime:U}),t.ChangeDetectorState=new i.CompileIdentifierMetadata({name:"ChangeDetectorState",moduleUrl:P,runtime:W}),t.checkBinding=new i.CompileIdentifierMetadata({name:"checkBinding",moduleUrl:b,runtime:G}),t.flattenNestedViewRenderNodes=new i.CompileIdentifierMetadata({name:"flattenNestedViewRenderNodes",moduleUrl:b,runtime:H}),t.devModeEqual=new i.CompileIdentifierMetadata({name:"devModeEqual",moduleUrl:P,runtime:X}),t.interpolate=new i.CompileIdentifierMetadata({name:"interpolate",moduleUrl:b,runtime:q}),t.castByValue=new i.CompileIdentifierMetadata({name:"castByValue",moduleUrl:b,runtime:z}),t.pureProxies=[null,new i.CompileIdentifierMetadata({name:"pureProxy1",moduleUrl:b,runtime:a.pureProxy1}),new i.CompileIdentifierMetadata({name:"pureProxy2",moduleUrl:b,runtime:a.pureProxy2}),new i.CompileIdentifierMetadata({name:"pureProxy3",moduleUrl:b,runtime:a.pureProxy3}),new i.CompileIdentifierMetadata({name:"pureProxy4",moduleUrl:b,runtime:a.pureProxy4}),new i.CompileIdentifierMetadata({name:"pureProxy5",moduleUrl:b,runtime:a.pureProxy5}),new i.CompileIdentifierMetadata({name:"pureProxy6",moduleUrl:b,runtime:a.pureProxy6}),new i.CompileIdentifierMetadata({name:"pureProxy7",moduleUrl:b,runtime:a.pureProxy7}),new i.CompileIdentifierMetadata({name:"pureProxy8",moduleUrl:b,runtime:a.pureProxy8}),new i.CompileIdentifierMetadata({name:"pureProxy9",moduleUrl:b,runtime:a.pureProxy9}),new i.CompileIdentifierMetadata({name:"pureProxy10",moduleUrl:b,runtime:a.pureProxy10})],t}();e.Identifiers=K,e.identifierToken=r},function(t,e,n){"use strict";function r(t){var e;if(t instanceof o.AppElement){var n=t;if(e=n.nativeElement,s.isPresent(n.nestedViews))for(var i=n.nestedViews.length-1;i>=0;i--){var a=n.nestedViews[i];a.rootNodesOrAppElements.length>0&&(e=r(a.rootNodesOrAppElements[a.rootNodesOrAppElements.length-1]))}}else e=t;return e}var i=n(15),o=n(67),s=n(5),a=n(40),u=n(82),c=n(68),p=n(66),l=n(28),h=n(71),f=n(73),d=n(160),v=n(161),y=s.CONST_EXPR(new Object),m=h.wtfCreateScope("AppView#check(ascii id)"),g=function(){function t(t,e,n,r,i,o,s,a,p){this.clazz=t,this.componentType=e,this.type=n,this.locals=r,this.viewUtils=i,this.parentInjector=o,this.declarationAppElement=s,this.cdMode=a,this.staticNodeDebugInfos=p,this.contentChildren=[],this.viewChildren=[],this.viewContainerElement=null,this.cdState=l.ChangeDetectorState.NeverChecked,this.context=null,this.destroyed=!1,this._currentDebugContext=null,this.ref=new u.ViewRef_(this),n===c.ViewType.COMPONENT||n===c.ViewType.HOST?this.renderer=i.renderComponent(e):this.renderer=s.parentView.renderer}return t.prototype.create=function(t,e){var n,r;switch(this.type){case c.ViewType.COMPONENT:n=this.declarationAppElement.component,r=p.ensureSlotCount(t,this.componentType.slotCount);break;case c.ViewType.EMBEDDED:n=this.declarationAppElement.parentView.context,r=this.declarationAppElement.parentView.projectableNodes;break;case c.ViewType.HOST:n=y,r=t}if(this._hasExternalHostElement=s.isPresent(e),this.context=n,this.projectableNodes=r,!this.debugMode)return this.createInternal(e);this._resetDebug();try{return this.createInternal(e)}catch(i){throw this._rethrowWithContext(i,i.stack),i}},t.prototype.createInternal=function(t){return null},t.prototype.init=function(t,e,n,r){this.rootNodesOrAppElements=t,this.allNodes=e,this.disposables=n,this.subscriptions=r,this.type===c.ViewType.COMPONENT&&(this.declarationAppElement.parentView.viewChildren.push(this),this.renderParent=this.declarationAppElement.parentView,this.dirtyParentQueriesInternal())},t.prototype.selectOrCreateHostElement=function(t,e,n){var r;return r=s.isPresent(e)?this.renderer.selectRootElement(e,n):this.renderer.createElement(null,t,n)},t.prototype.injectorGet=function(t,e,n){if(!this.debugMode)return this.injectorGetInternal(t,e,n);this._resetDebug();try{return this.injectorGetInternal(t,e,n)}catch(r){throw this._rethrowWithContext(r,r.stack),r}},t.prototype.injectorGetInternal=function(t,e,n){return n},t.prototype.injector=function(t){return s.isPresent(t)?new v.ElementInjector(this,t):this.parentInjector},t.prototype.destroy=function(){this._hasExternalHostElement?this.renderer.detachView(this.flatRootNodes):s.isPresent(this.viewContainerElement)&&this.viewContainerElement.detachView(this.viewContainerElement.nestedViews.indexOf(this)),this._destroyRecurse()},t.prototype._destroyRecurse=function(){if(!this.destroyed){for(var t=this.contentChildren,e=0;e0?this.rootNodesOrAppElements[this.rootNodesOrAppElements.length-1]:null;return r(t)},enumerable:!0,configurable:!0}),t.prototype.hasLocal=function(t){return i.StringMapWrapper.contains(this.locals,t)},t.prototype.setLocal=function(t,e){this.locals[t]=e},t.prototype.dirtyParentQueriesInternal=function(){},t.prototype.addRenderContentChild=function(t){this.contentChildren.push(t),t.renderParent=this,t.dirtyParentQueriesInternal()},t.prototype.removeContentChild=function(t){i.ListWrapper.remove(this.contentChildren,t),t.dirtyParentQueriesInternal(),t.renderParent=null},t.prototype.detectChanges=function(t){var e=m(this.clazz);if(this.cdMode!==l.ChangeDetectionStrategy.Detached&&this.cdMode!==l.ChangeDetectionStrategy.Checked&&this.cdState!==l.ChangeDetectorState.Errored){if(this.destroyed&&this.throwDestroyedError("detectChanges"),this.debugMode){this._resetDebug();try{this.detectChangesInternal(t)}catch(n){throw this._rethrowWithContext(n,n.stack),n}}else this.detectChangesInternal(t);this.cdMode===l.ChangeDetectionStrategy.CheckOnce&&(this.cdMode=l.ChangeDetectionStrategy.Checked),this.cdState=l.ChangeDetectorState.CheckedBefore,h.wtfLeave(e)}},t.prototype.detectChangesInternal=function(t){this.detectContentChildrenChanges(t),this.detectViewChildrenChanges(t)},t.prototype.detectContentChildrenChanges=function(t){for(var e=0;eo?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=n(15),a=n(68),u=function(){function t(t,e,n){this.providerTokens=t,this.componentToken=e,this.varTokens=n}return t=r([o.CONST(),i("design:paramtypes",[Array,Object,Object])],t)}();e.StaticNodeDebugInfo=u;var c=function(){function t(t,e,n,r){this._view=t,this._nodeIndex=e,this._tplRow=n,this._tplCol=r}return Object.defineProperty(t.prototype,"_staticNodeInfo",{get:function(){return o.isPresent(this._nodeIndex)?this._view.staticNodeDebugInfos[this._nodeIndex]:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"context",{get:function(){return this._view.context},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"component",{get:function(){var t=this._staticNodeInfo;return o.isPresent(t)&&o.isPresent(t.componentToken)?this.injector.get(t.componentToken):null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"componentRenderElement",{get:function(){for(var t=this._view;o.isPresent(t.declarationAppElement)&&t.type!==a.ViewType.COMPONENT;)t=t.declarationAppElement.parentView;return o.isPresent(t.declarationAppElement)?t.declarationAppElement.nativeElement:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"injector",{get:function(){return this._view.injector(this._nodeIndex)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderNode",{get:function(){return o.isPresent(this._nodeIndex)&&o.isPresent(this._view.allNodes)?this._view.allNodes[this._nodeIndex]:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"providerTokens",{get:function(){var t=this._staticNodeInfo;return o.isPresent(t)?t.providerTokens:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._view.componentType.templateUrl+":"+this._tplRow+":"+this._tplCol},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"locals",{get:function(){var t=this,e={};return s.ListWrapper.forEachWithIndex(this._view.staticNodeDebugInfos,function(n,r){var i=n.varTokens;s.StringMapWrapper.forEach(i,function(n,i){var s;s=o.isBlank(n)?o.isPresent(t._view.allNodes)?t._view.allNodes[r]:null:t._view.injectorGet(n,r,null), -e[i]=s})}),s.StringMapWrapper.forEach(this._view.locals,function(t,n){e[n]=t}),e},enumerable:!0,configurable:!0}),t}();e.DebugContext=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(11),s=i.CONST_EXPR(new Object),a=function(t){function e(e,n){t.call(this),this._view=e,this._nodeIndex=n}return r(e,t),e.prototype.get=function(t,e){void 0===e&&(e=o.THROW_IF_NOT_FOUND);var n=s;return n===s&&(n=this._view.injectorGet(t,this._nodeIndex,s)),n===s&&(n=this._view.parentInjector.get(t,e)),n},e}(o.Injector);e.ElementInjector=a},function(t,e,n){"use strict";var r=n(5),i=n(12),o=n(158),s=function(){function t(t,e,n,i){void 0===i&&(i=null),this.genDebugInfo=t,this.logBindingUpdate=e,this.useJit=n,r.isBlank(i)&&(i=new u),this.renderTypes=i}return t}();e.CompilerConfig=s;var a=function(){function t(){}return Object.defineProperty(t.prototype,"renderer",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderText",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderElement",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderComment",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderNode",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderEvent",{get:function(){return i.unimplemented()},enumerable:!0,configurable:!0}),t}();e.RenderTypes=a;var u=function(){function t(){this.renderer=o.Identifiers.Renderer,this.renderText=null,this.renderElement=null,this.renderComment=null,this.renderNode=null,this.renderEvent=null}return t}();e.DefaultRenderTypes=u},function(t,e,n){"use strict";function r(t){return t.dependencies.forEach(function(t){t.factoryPlaceholder.moduleUrl=o(t.comp)}),t.statements}function i(t){return t.dependencies.forEach(function(t){t.valuePlaceholder.moduleUrl=s(t.sourceUrl,t.isShimmed)}),t.statements}function o(t){var e=t.type.moduleUrl,n=e.substring(0,e.length-f.MODULE_SUFFIX.length);return n+".ngfactory"+f.MODULE_SUFFIX}function s(t,e){return e?t+".shim"+f.MODULE_SUFFIX:""+t+f.MODULE_SUFFIX}function a(t){if(!t.isComponent)throw new c.BaseException("Could not compile '"+t.type.name+"' because it is not a component.")}var u=n(155),c=n(12),p=n(15),l=n(164),h=n(65),f=n(153),d=new u.CompileIdentifierMetadata({name:"ComponentFactory",runtime:h.ComponentFactory,moduleUrl:"asset:angular2/lib/src/core/linker/component_factory"+f.MODULE_SUFFIX}),v=function(){function t(t,e){this.moduleUrl=t,this.source=e}return t}();e.SourceModule=v;var y=function(){function t(t,e,n){this.component=t,this.directives=e,this.pipes=n}return t}();e.NormalizedComponentWithViewDirectives=y;var m=function(){function t(t,e,n,r,i){this._directiveNormalizer=t,this._templateParser=e,this._styleCompiler=n,this._viewCompiler=r,this._outputEmitter=i}return t.prototype.normalizeDirectiveMetadata=function(t){return this._directiveNormalizer.normalizeDirective(t)},t.prototype.compileTemplates=function(t){var e=this;if(0===t.length)throw new c.BaseException("No components given");var n=[],r=[],i=o(t[0].component);return t.forEach(function(t){var i=t.component;a(i);var o=e._compileComponent(i,t.directives,t.pipes,n);r.push(o);var s=u.createHostComponentMeta(i.type,i.selector),c=e._compileComponent(s,[i],[],n),p=i.type.name+"NgFactory";n.push(l.variable(p).set(l.importExpr(d).instantiate([l.literal(i.selector),l.variable(c),l.importExpr(i.type)],l.importType(d,null,[l.TypeModifier.Const]))).toDeclStmt(null,[l.StmtModifier.Final])),r.push(p)}),this._codegenSourceModule(i,n,r)},t.prototype.compileStylesheet=function(t,e){var n=this._styleCompiler.compileStylesheet(t,e,!1),r=this._styleCompiler.compileStylesheet(t,e,!0);return[this._codegenSourceModule(s(t,!1),i(n),[n.stylesVar]),this._codegenSourceModule(s(t,!0),i(r),[r.stylesVar])]},t.prototype._compileComponent=function(t,e,n,o){var s=this._styleCompiler.compileComponent(t),a=this._templateParser.parse(t,t.template.template,e,n,t.type.name),u=this._viewCompiler.compileComponent(t,a,l.variable(s.stylesVar),n);return p.ListWrapper.addAll(o,i(s)),p.ListWrapper.addAll(o,r(u)),u.viewFactoryVar},t.prototype._codegenSourceModule=function(t,e,n){return new v(t,this._outputEmitter.emitStatements(t,e,n))},t}();e.OfflineCompiler=m},function(t,e,n){"use strict";function r(t,e,n){var r=new ot(t,e);return n.visitExpression(r,null)}function i(t){var e=new st;return e.visitAllStatements(t,null),e.varNames}function o(t,e){return void 0===e&&(e=null),new C(t,e)}function s(t,e){return void 0===e&&(e=null),new M(t,null,e)}function a(t,e,n){return void 0===e&&(e=null),void 0===n&&(n=null),d.isPresent(t)?new g(t,e,n):null}function u(t,e){return void 0===e&&(e=null),new I(t,e)}function c(t,e){return void 0===e&&(e=null),new U(t,e)}function p(t,e){return void 0===e&&(e=null),new W(t,e)}function l(t){return new N(t)}function h(t,e,n){return void 0===n&&(n=null),new j(t,e,n)}var f=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},d=n(5);!function(t){t[t.Const=0]="Const"}(e.TypeModifier||(e.TypeModifier={}));var v=(e.TypeModifier,function(){function t(t){void 0===t&&(t=null),this.modifiers=t,d.isBlank(t)&&(this.modifiers=[])}return t.prototype.hasModifier=function(t){return-1!==this.modifiers.indexOf(t)},t}());e.Type=v,function(t){t[t.Dynamic=0]="Dynamic",t[t.Bool=1]="Bool",t[t.String=2]="String",t[t.Int=3]="Int",t[t.Number=4]="Number",t[t.Function=5]="Function"}(e.BuiltinTypeName||(e.BuiltinTypeName={}));var y=e.BuiltinTypeName,m=function(t){function e(e,n){void 0===n&&(n=null),t.call(this,n),this.name=e}return f(e,t),e.prototype.visitType=function(t,e){return t.visitBuiltintType(this,e)},e}(v);e.BuiltinType=m;var g=function(t){function e(e,n,r){void 0===n&&(n=null),void 0===r&&(r=null),t.call(this,r),this.value=e,this.typeParams=n}return f(e,t),e.prototype.visitType=function(t,e){return t.visitExternalType(this,e)},e}(v);e.ExternalType=g;var _=function(t){function e(e,n){void 0===n&&(n=null),t.call(this,n),this.of=e}return f(e,t),e.prototype.visitType=function(t,e){return t.visitArrayType(this,e)},e}(v);e.ArrayType=_;var b=function(t){function e(e,n){void 0===n&&(n=null),t.call(this,n),this.valueType=e}return f(e,t),e.prototype.visitType=function(t,e){return t.visitMapType(this,e)},e}(v);e.MapType=b,e.DYNAMIC_TYPE=new m(y.Dynamic),e.BOOL_TYPE=new m(y.Bool),e.INT_TYPE=new m(y.Int),e.NUMBER_TYPE=new m(y.Number),e.STRING_TYPE=new m(y.String),e.FUNCTION_TYPE=new m(y.Function),function(t){t[t.Equals=0]="Equals",t[t.NotEquals=1]="NotEquals",t[t.Identical=2]="Identical",t[t.NotIdentical=3]="NotIdentical",t[t.Minus=4]="Minus",t[t.Plus=5]="Plus",t[t.Divide=6]="Divide",t[t.Multiply=7]="Multiply",t[t.Modulo=8]="Modulo",t[t.And=9]="And",t[t.Or=10]="Or",t[t.Lower=11]="Lower",t[t.LowerEquals=12]="LowerEquals",t[t.Bigger=13]="Bigger",t[t.BiggerEquals=14]="BiggerEquals"}(e.BinaryOperator||(e.BinaryOperator={}));var P=e.BinaryOperator,E=function(){function t(t){this.type=t}return t.prototype.prop=function(t){return new B(this,t)},t.prototype.key=function(t,e){return void 0===e&&(e=null),new F(this,t,e)},t.prototype.callMethod=function(t,e){return new T(this,t,e)},t.prototype.callFn=function(t){return new x(this,t)},t.prototype.instantiate=function(t,e){return void 0===e&&(e=null),new A(this,t,e)},t.prototype.conditional=function(t,e){return void 0===e&&(e=null),new k(this,t,e)},t.prototype.equals=function(t){return new L(P.Equals,this,t)},t.prototype.notEquals=function(t){return new L(P.NotEquals,this,t)},t.prototype.identical=function(t){return new L(P.Identical,this,t)},t.prototype.notIdentical=function(t){return new L(P.NotIdentical,this,t)},t.prototype.minus=function(t){return new L(P.Minus,this,t)},t.prototype.plus=function(t){return new L(P.Plus,this,t)},t.prototype.divide=function(t){return new L(P.Divide,this,t)},t.prototype.multiply=function(t){return new L(P.Multiply,this,t)},t.prototype.modulo=function(t){return new L(P.Modulo,this,t)},t.prototype.and=function(t){return new L(P.And,this,t)},t.prototype.or=function(t){return new L(P.Or,this,t)},t.prototype.lower=function(t){return new L(P.Lower,this,t)},t.prototype.lowerEquals=function(t){return new L(P.LowerEquals,this,t)},t.prototype.bigger=function(t){return new L(P.Bigger,this,t)},t.prototype.biggerEquals=function(t){return new L(P.BiggerEquals,this,t)},t.prototype.isBlank=function(){return this.equals(e.NULL_EXPR)},t.prototype.cast=function(t){return new D(this,t)},t.prototype.toStmt=function(){return new G(this)},t}();e.Expression=E,function(t){t[t.This=0]="This",t[t.Super=1]="Super",t[t.CatchError=2]="CatchError",t[t.CatchStack=3]="CatchStack"}(e.BuiltinVar||(e.BuiltinVar={}));var w=e.BuiltinVar,C=function(t){function e(e,n){void 0===n&&(n=null),t.call(this,n),d.isString(e)?(this.name=e,this.builtin=null):(this.name=null,this.builtin=e)}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitReadVarExpr(this,e)},e.prototype.set=function(t){return new R(this.name,t)},e}(E);e.ReadVarExpr=C;var R=function(t){function e(e,n,r){void 0===r&&(r=null),t.call(this,d.isPresent(r)?r:n.type),this.name=e,this.value=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitWriteVarExpr(this,e)},e.prototype.toDeclStmt=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=null),new X(this.name,this.value,t,e)},e}(E);e.WriteVarExpr=R;var S=function(t){function e(e,n,r,i){void 0===i&&(i=null),t.call(this,d.isPresent(i)?i:r.type),this.receiver=e,this.index=n,this.value=r}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitWriteKeyExpr(this,e)},e}(E);e.WriteKeyExpr=S;var O=function(t){function e(e,n,r,i){void 0===i&&(i=null),t.call(this,d.isPresent(i)?i:r.type),this.receiver=e,this.name=n,this.value=r}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitWritePropExpr(this,e)},e}(E);e.WritePropExpr=O,function(t){t[t.ConcatArray=0]="ConcatArray",t[t.SubscribeObservable=1]="SubscribeObservable",t[t.bind=2]="bind"}(e.BuiltinMethod||(e.BuiltinMethod={}));var T=(e.BuiltinMethod,function(t){function e(e,n,r,i){void 0===i&&(i=null),t.call(this,i),this.receiver=e,this.args=r,d.isString(n)?(this.name=n,this.builtin=null):(this.name=null,this.builtin=n)}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitInvokeMethodExpr(this,e)},e}(E));e.InvokeMethodExpr=T;var x=function(t){function e(e,n,r){void 0===r&&(r=null),t.call(this,r),this.fn=e,this.args=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitInvokeFunctionExpr(this,e)},e}(E);e.InvokeFunctionExpr=x;var A=function(t){function e(e,n,r){t.call(this,r),this.classExpr=e,this.args=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitInstantiateExpr(this,e)},e}(E);e.InstantiateExpr=A;var I=function(t){function e(e,n){void 0===n&&(n=null),t.call(this,n),this.value=e}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitLiteralExpr(this,e)},e}(E);e.LiteralExpr=I;var M=function(t){function e(e,n,r){void 0===n&&(n=null),void 0===r&&(r=null),t.call(this,n),this.value=e,this.typeParams=r}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitExternalExpr(this,e)},e}(E);e.ExternalExpr=M;var k=function(t){function e(e,n,r,i){void 0===r&&(r=null),void 0===i&&(i=null),t.call(this,d.isPresent(i)?i:n.type),this.condition=e,this.falseCase=r,this.trueCase=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitConditionalExpr(this,e)},e}(E);e.ConditionalExpr=k;var N=function(t){function n(n){t.call(this,e.BOOL_TYPE),this.condition=n}return f(n,t),n.prototype.visitExpression=function(t,e){return t.visitNotExpr(this,e)},n}(E);e.NotExpr=N;var D=function(t){function e(e,n){t.call(this,n),this.value=e}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitCastExpr(this,e)},e}(E);e.CastExpr=D;var V=function(){function t(t,e){void 0===e&&(e=null),this.name=t,this.type=e}return t}();e.FnParam=V;var j=function(t){function e(e,n,r){void 0===r&&(r=null),t.call(this,r),this.params=e,this.statements=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitFunctionExpr(this,e)},e.prototype.toDeclStmt=function(t,e){return void 0===e&&(e=null),new q(t,this.params,this.statements,this.type,e)},e}(E);e.FunctionExpr=j;var L=function(t){function e(e,n,r,i){void 0===i&&(i=null),t.call(this,d.isPresent(i)?i:n.type),this.operator=e,this.rhs=r,this.lhs=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitBinaryOperatorExpr(this,e)},e}(E);e.BinaryOperatorExpr=L;var B=function(t){function e(e,n,r){void 0===r&&(r=null),t.call(this,r),this.receiver=e,this.name=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitReadPropExpr(this,e)},e.prototype.set=function(t){return new O(this.receiver,this.name,t)},e}(E);e.ReadPropExpr=B;var F=function(t){function e(e,n,r){void 0===r&&(r=null),t.call(this,r),this.receiver=e,this.index=n}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitReadKeyExpr(this,e)},e.prototype.set=function(t){return new S(this.receiver,this.index,t)},e}(E);e.ReadKeyExpr=F;var U=function(t){function e(e,n){void 0===n&&(n=null),t.call(this,n),this.entries=e}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitLiteralArrayExpr(this,e)},e}(E);e.LiteralArrayExpr=U;var W=function(t){function e(e,n){void 0===n&&(n=null),t.call(this,n),this.entries=e,this.valueType=null,d.isPresent(n)&&(this.valueType=n.valueType)}return f(e,t),e.prototype.visitExpression=function(t,e){return t.visitLiteralMapExpr(this,e)},e}(E);e.LiteralMapExpr=W,e.THIS_EXPR=new C(w.This),e.SUPER_EXPR=new C(w.Super),e.CATCH_ERROR_VAR=new C(w.CatchError),e.CATCH_STACK_VAR=new C(w.CatchStack),e.NULL_EXPR=new I(null,null),function(t){t[t.Final=0]="Final",t[t.Private=1]="Private"}(e.StmtModifier||(e.StmtModifier={}));var H=(e.StmtModifier,function(){function t(t){void 0===t&&(t=null),this.modifiers=t,d.isBlank(t)&&(this.modifiers=[])}return t.prototype.hasModifier=function(t){return-1!==this.modifiers.indexOf(t)},t}());e.Statement=H;var X=function(t){function e(e,n,r,i){void 0===r&&(r=null),void 0===i&&(i=null),t.call(this,i),this.name=e,this.value=n,this.type=d.isPresent(r)?r:n.type}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitDeclareVarStmt(this,e)},e}(H);e.DeclareVarStmt=X;var q=function(t){function e(e,n,r,i,o){void 0===i&&(i=null),void 0===o&&(o=null),t.call(this,o),this.name=e,this.params=n,this.statements=r,this.type=i}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitDeclareFunctionStmt(this,e)},e}(H);e.DeclareFunctionStmt=q;var G=function(t){function e(e){t.call(this),this.expr=e}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitExpressionStmt(this,e)},e}(H);e.ExpressionStatement=G;var z=function(t){function e(e){t.call(this),this.value=e}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitReturnStmt(this,e)},e}(H);e.ReturnStatement=z;var K=function(){function t(t,e){void 0===t&&(t=null),this.type=t,this.modifiers=e,d.isBlank(e)&&(this.modifiers=[])}return t.prototype.hasModifier=function(t){return-1!==this.modifiers.indexOf(t)},t}();e.AbstractClassPart=K;var $=function(t){function e(e,n,r){void 0===n&&(n=null),void 0===r&&(r=null),t.call(this,n,r),this.name=e}return f(e,t),e}(K);e.ClassField=$;var Q=function(t){function e(e,n,r,i,o){void 0===i&&(i=null),void 0===o&&(o=null),t.call(this,i,o),this.name=e,this.params=n,this.body=r}return f(e,t),e}(K);e.ClassMethod=Q;var J=function(t){function e(e,n,r,i){void 0===r&&(r=null),void 0===i&&(i=null),t.call(this,r,i),this.name=e,this.body=n}return f(e,t),e}(K);e.ClassGetter=J;var Z=function(t){function e(e,n,r,i,o,s,a){void 0===a&&(a=null),t.call(this,a),this.name=e,this.parent=n,this.fields=r,this.getters=i,this.constructorMethod=o,this.methods=s}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitDeclareClassStmt(this,e)},e}(H);e.ClassStmt=Z;var Y=function(t){function e(e,n,r){void 0===r&&(r=d.CONST_EXPR([])),t.call(this),this.condition=e,this.trueCase=n,this.falseCase=r}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitIfStmt(this,e)},e}(H);e.IfStmt=Y;var tt=function(t){function e(e){t.call(this),this.comment=e}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitCommentStmt(this,e)},e}(H);e.CommentStmt=tt;var et=function(t){function e(e,n){t.call(this),this.bodyStmts=e,this.catchStmts=n}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitTryCatchStmt(this,e)},e}(H);e.TryCatchStmt=et;var nt=function(t){function e(e){t.call(this),this.error=e}return f(e,t),e.prototype.visitStatement=function(t,e){return t.visitThrowStmt(this,e)},e}(H);e.ThrowStmt=nt;var rt=function(){function t(){}return t.prototype.visitReadVarExpr=function(t,e){return t},t.prototype.visitWriteVarExpr=function(t,e){return new R(t.name,t.value.visitExpression(this,e))},t.prototype.visitWriteKeyExpr=function(t,e){return new S(t.receiver.visitExpression(this,e),t.index.visitExpression(this,e),t.value.visitExpression(this,e))},t.prototype.visitWritePropExpr=function(t,e){return new O(t.receiver.visitExpression(this,e),t.name,t.value.visitExpression(this,e))},t.prototype.visitInvokeMethodExpr=function(t,e){var n=d.isPresent(t.builtin)?t.builtin:t.name;return new T(t.receiver.visitExpression(this,e),n,this.visitAllExpressions(t.args,e),t.type)},t.prototype.visitInvokeFunctionExpr=function(t,e){return new x(t.fn.visitExpression(this,e),this.visitAllExpressions(t.args,e),t.type)},t.prototype.visitInstantiateExpr=function(t,e){return new A(t.classExpr.visitExpression(this,e),this.visitAllExpressions(t.args,e),t.type)},t.prototype.visitLiteralExpr=function(t,e){return t},t.prototype.visitExternalExpr=function(t,e){return t},t.prototype.visitConditionalExpr=function(t,e){return new k(t.condition.visitExpression(this,e),t.trueCase.visitExpression(this,e),t.falseCase.visitExpression(this,e))},t.prototype.visitNotExpr=function(t,e){return new N(t.condition.visitExpression(this,e))},t.prototype.visitCastExpr=function(t,e){return new D(t.value.visitExpression(this,e),e)},t.prototype.visitFunctionExpr=function(t,e){return t},t.prototype.visitBinaryOperatorExpr=function(t,e){return new L(t.operator,t.lhs.visitExpression(this,e),t.rhs.visitExpression(this,e),t.type)},t.prototype.visitReadPropExpr=function(t,e){return new B(t.receiver.visitExpression(this,e),t.name,t.type)},t.prototype.visitReadKeyExpr=function(t,e){return new F(t.receiver.visitExpression(this,e),t.index.visitExpression(this,e),t.type)},t.prototype.visitLiteralArrayExpr=function(t,e){return new U(this.visitAllExpressions(t.entries,e))},t.prototype.visitLiteralMapExpr=function(t,e){var n=this;return new W(t.entries.map(function(t){return[t[0],t[1].visitExpression(n,e)]}))},t.prototype.visitAllExpressions=function(t,e){var n=this;return t.map(function(t){return t.visitExpression(n,e)})},t.prototype.visitDeclareVarStmt=function(t,e){return new X(t.name,t.value.visitExpression(this,e),t.type,t.modifiers)},t.prototype.visitDeclareFunctionStmt=function(t,e){return t},t.prototype.visitExpressionStmt=function(t,e){return new G(t.expr.visitExpression(this,e))},t.prototype.visitReturnStmt=function(t,e){return new z(t.value.visitExpression(this,e))},t.prototype.visitDeclareClassStmt=function(t,e){return t},t.prototype.visitIfStmt=function(t,e){return new Y(t.condition.visitExpression(this,e),this.visitAllStatements(t.trueCase,e),this.visitAllStatements(t.falseCase,e))},t.prototype.visitTryCatchStmt=function(t,e){return new et(this.visitAllStatements(t.bodyStmts,e),this.visitAllStatements(t.catchStmts,e))},t.prototype.visitThrowStmt=function(t,e){return new nt(t.error.visitExpression(this,e))},t.prototype.visitCommentStmt=function(t,e){return t},t.prototype.visitAllStatements=function(t,e){var n=this;return t.map(function(t){return t.visitStatement(n,e)})},t}();e.ExpressionTransformer=rt;var it=function(){function t(){}return t.prototype.visitReadVarExpr=function(t,e){return t},t.prototype.visitWriteVarExpr=function(t,e){return t.value.visitExpression(this,e),t},t.prototype.visitWriteKeyExpr=function(t,e){return t.receiver.visitExpression(this,e),t.index.visitExpression(this,e),t.value.visitExpression(this,e),t},t.prototype.visitWritePropExpr=function(t,e){return t.receiver.visitExpression(this,e),t.value.visitExpression(this,e),t},t.prototype.visitInvokeMethodExpr=function(t,e){return t.receiver.visitExpression(this,e),this.visitAllExpressions(t.args,e),t},t.prototype.visitInvokeFunctionExpr=function(t,e){return t.fn.visitExpression(this,e),this.visitAllExpressions(t.args,e),t},t.prototype.visitInstantiateExpr=function(t,e){return t.classExpr.visitExpression(this,e),this.visitAllExpressions(t.args,e),t},t.prototype.visitLiteralExpr=function(t,e){return t},t.prototype.visitExternalExpr=function(t,e){return t},t.prototype.visitConditionalExpr=function(t,e){return t.condition.visitExpression(this,e),t.trueCase.visitExpression(this,e),t.falseCase.visitExpression(this,e),t},t.prototype.visitNotExpr=function(t,e){return t.condition.visitExpression(this,e),t},t.prototype.visitCastExpr=function(t,e){return t.value.visitExpression(this,e),t},t.prototype.visitFunctionExpr=function(t,e){return t},t.prototype.visitBinaryOperatorExpr=function(t,e){return t.lhs.visitExpression(this,e),t.rhs.visitExpression(this,e),t},t.prototype.visitReadPropExpr=function(t,e){return t.receiver.visitExpression(this,e),t},t.prototype.visitReadKeyExpr=function(t,e){return t.receiver.visitExpression(this,e),t.index.visitExpression(this,e),t},t.prototype.visitLiteralArrayExpr=function(t,e){return this.visitAllExpressions(t.entries,e),t},t.prototype.visitLiteralMapExpr=function(t,e){var n=this;return t.entries.forEach(function(t){return t[1].visitExpression(n,e)}),t},t.prototype.visitAllExpressions=function(t,e){var n=this;t.forEach(function(t){return t.visitExpression(n,e)})},t.prototype.visitDeclareVarStmt=function(t,e){return t.value.visitExpression(this,e),t},t.prototype.visitDeclareFunctionStmt=function(t,e){return t},t.prototype.visitExpressionStmt=function(t,e){return t.expr.visitExpression(this,e),t},t.prototype.visitReturnStmt=function(t,e){return t.value.visitExpression(this,e),t},t.prototype.visitDeclareClassStmt=function(t,e){return t},t.prototype.visitIfStmt=function(t,e){return t.condition.visitExpression(this,e),this.visitAllStatements(t.trueCase,e),this.visitAllStatements(t.falseCase,e),t},t.prototype.visitTryCatchStmt=function(t,e){return this.visitAllStatements(t.bodyStmts,e),this.visitAllStatements(t.catchStmts,e),t},t.prototype.visitThrowStmt=function(t,e){return t.error.visitExpression(this,e),t},t.prototype.visitCommentStmt=function(t,e){return t},t.prototype.visitAllStatements=function(t,e){var n=this;t.forEach(function(t){return t.visitStatement(n,e)})},t}();e.RecursiveExpressionVisitor=it,e.replaceVarInExpression=r;var ot=function(t){function e(e,n){t.call(this),this._varName=e,this._newValue=n}return f(e,t),e.prototype.visitReadVarExpr=function(t,e){return t.name==this._varName?this._newValue:t},e}(rt);e.findReadVarNames=i;var st=function(t){function e(){t.apply(this,arguments),this.varNames=new Set}return f(e,t),e.prototype.visitReadVarExpr=function(t,e){return this.varNames.add(t.name),null},e}(it);e.variable=o,e.importExpr=s,e.importType=a,e.literal=u,e.literalArr=c,e.literalMap=p,e.not=l,e.fn=h},function(t,e,n){"use strict";function r(t){if(!t.isComponent)throw new a.BaseException("Could not compile '"+t.type.name+"' because it is not a component.")}var i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(5),a=n(12),u=n(15),c=n(40),p=n(155),l=n(6),h=n(166),f=n(168),d=n(140),v=n(183),y=n(185),m=n(65),g=n(162),_=n(164),b=n(191),P=n(194),E=n(198),w=n(184),C=function(){function t(t,e,n,r,i,o,s){this._runtimeMetadataResolver=t,this._templateNormalizer=e,this._templateParser=n,this._styleCompiler=r,this._viewCompiler=i,this._xhr=o,this._genConfig=s,this._styleCache=new Map,this._hostCacheKeys=new Map,this._compiledTemplateCache=new Map,this._compiledTemplateDone=new Map}return t.prototype.resolveComponent=function(t){var e=this._runtimeMetadataResolver.getDirectiveMetadata(t),n=this._hostCacheKeys.get(t);if(s.isBlank(n)){n=new Object,this._hostCacheKeys.set(t,n),r(e);var i=p.createHostComponentMeta(e.type,e.selector);this._loadAndCompileComponent(n,i,[e],[],[])}return this._compiledTemplateDone.get(n).then(function(n){return new m.ComponentFactory(e.selector,n.viewFactory,t)})},t.prototype.clearCache=function(){this._styleCache.clear(),this._compiledTemplateCache.clear(),this._compiledTemplateDone.clear(),this._hostCacheKeys.clear()},t.prototype._loadAndCompileComponent=function(t,e,n,r,i){var o=this,a=this._compiledTemplateCache.get(t),u=this._compiledTemplateDone.get(t);return s.isBlank(a)&&(a=new R,this._compiledTemplateCache.set(t,a),u=c.PromiseWrapper.all([this._compileComponentStyles(e)].concat(n.map(function(t){return o._templateNormalizer.normalizeDirective(t)}))).then(function(t){var n=t.slice(1),s=t[0],u=o._templateParser.parse(e,e.template.template,n,r,e.type.name),p=[];return a.init(o._compileComponent(e,u,s,r,i,p)),c.PromiseWrapper.all(p).then(function(t){return a})}),this._compiledTemplateDone.set(t,u)),a},t.prototype._compileComponent=function(t,e,n,r,i,o){var a=this,c=this._viewCompiler.compileComponent(t,e,new _.ExternalExpr(new p.CompileIdentifierMetadata({runtime:n})),r);c.dependencies.forEach(function(t){var e=u.ListWrapper.clone(i),n=t.comp.type.runtime,r=a._runtimeMetadataResolver.getViewDirectivesMetadata(t.comp.type.runtime),s=a._runtimeMetadataResolver.getViewPipesMetadata(t.comp.type.runtime),c=u.ListWrapper.contains(e,n);e.push(n);var p=a._loadAndCompileComponent(t.comp.type.runtime,t.comp,r,s,e);t.factoryPlaceholder.runtime=p.proxyViewFactory,t.factoryPlaceholder.name="viewFactory_"+t.comp.type.name,c||o.push(a._compiledTemplateDone.get(n))});var l;return l=s.IS_DART||!this._genConfig.useJit?P.interpretStatements(c.statements,c.viewFactoryVar,new E.InterpretiveAppViewInstanceFactory):b.jitStatements(t.type.name+".template.js",c.statements,c.viewFactoryVar)},t.prototype._compileComponentStyles=function(t){var e=this._styleCompiler.compileComponent(t);return this._resolveStylesCompileResult(t.type.name,e)},t.prototype._resolveStylesCompileResult=function(t,e){var n=this,r=e.dependencies.map(function(t){return n._loadStylesheetDep(t)});return c.PromiseWrapper.all(r).then(function(t){for(var r=[],i=0;io?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(155),a=n(164),u=n(36),c=n(167),p=n(157),l=n(152),h=n(6),f=n(5),d="%COMP%",v="_nghost-"+d,y="_ngcontent-"+d,m=function(){function t(t,e,n){this.sourceUrl=t,this.isShimmed=e,this.valuePlaceholder=n}return t}();e.StylesCompileDependency=m;var g=function(){function t(t,e,n){this.statements=t,this.stylesVar=e,this.dependencies=n}return t}();e.StylesCompileResult=g;var _=function(){function t(t){this._urlResolver=t,this._shadowCss=new c.ShadowCss}return t.prototype.compileComponent=function(t){var e=t.template.encapsulation===u.ViewEncapsulation.Emulated;return this._compileStyles(r(t),t.template.styles,t.template.styleUrls,e)},t.prototype.compileStylesheet=function(t,e,n){var i=l.extractStyleUrls(this._urlResolver,t,e);return this._compileStyles(r(null),[i.style],i.styleUrls,n)},t.prototype._compileStyles=function(t,e,n,i){for(var o=this,u=e.map(function(t){return a.literal(o._shimIfNeeded(t,i))}),c=[],p=0;p0?o.push(u):(o.length>0&&(r.push(o.join("")),n.push(x),o=[]),n.push(u)),u==O&&i++}return o.length>0&&(r.push(o.join("")),n.push(x)),new I(n.join(""),r)}var s=n(15),a=n(5),u=function(){function t(){this.strictStyling=!0}return t.prototype.shimCssText=function(t,e,n){return void 0===n&&(n=""),t=r(t),t=this._insertDirectives(t),this._scopeCssText(t,e,n)},t.prototype._insertDirectives=function(t){return t=this._insertPolyfillDirectivesInCssText(t),this._insertPolyfillRulesInCssText(t)},t.prototype._insertPolyfillDirectivesInCssText=function(t){return a.StringWrapper.replaceAllMapped(t,c,function(t){return t[1]+"{"})},t.prototype._insertPolyfillRulesInCssText=function(t){return a.StringWrapper.replaceAllMapped(t,p,function(t){var e=t[0];return e=a.StringWrapper.replace(e,t[1],""),e=a.StringWrapper.replace(e,t[2],""),t[3]+e})},t.prototype._scopeCssText=function(t,e,n){var r=this._extractUnscopedRulesFromCssText(t);return t=this._insertPolyfillHostInCssText(t),t=this._convertColonHost(t),t=this._convertColonHostContext(t),t=this._convertShadowDOMSelectors(t), -a.isPresent(e)&&(t=this._scopeSelectors(t,e,n)),t=t+"\n"+r,t.trim()},t.prototype._extractUnscopedRulesFromCssText=function(t){for(var e,n="",r=a.RegExpWrapper.matcher(l,t);a.isPresent(e=a.RegExpMatcherWrapper.next(r));){var i=e[0];i=a.StringWrapper.replace(i,e[2],""),i=a.StringWrapper.replace(i,e[1],e[3]),n+=i+"\n\n"}return n},t.prototype._convertColonHost=function(t){return this._convertColonRule(t,v,this._colonHostPartReplacer)},t.prototype._convertColonHostContext=function(t){return this._convertColonRule(t,y,this._colonHostContextPartReplacer)},t.prototype._convertColonRule=function(t,e,n){return a.StringWrapper.replaceAllMapped(t,e,function(t){if(a.isPresent(t[2])){for(var e=t[2].split(","),r=[],i=0;i","+","~"],i=t,o="["+e+"]",u=0;u0&&!s.ListWrapper.contains(r,e)&&!a.StringWrapper.contains(e,o)){var n=/([^:]*)(:*)(.*)/g,i=a.RegExpWrapper.firstMatch(n,e);a.isPresent(i)&&(t=i[1]+o+i[2]+i[3])}return t}).join(c)}return i},t.prototype._insertPolyfillHostInCssText=function(t){return t=a.StringWrapper.replaceAll(t,w,f),t=a.StringWrapper.replaceAll(t,E,h)},t}();e.ShadowCss=u;var c=/polyfill-next-selector[^}]*content:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim,p=/(polyfill-rule)[^}]*(content:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,l=/(polyfill-unscoped-rule)[^}]*(content:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,h="-shadowcsshost",f="-shadowcsscontext",d=")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)",v=a.RegExpWrapper.create("("+h+d,"im"),y=a.RegExpWrapper.create("("+f+d,"im"),m=h+"-no-combinator",g=[/::shadow/g,/::content/g,/\/shadow-deep\//g,/\/shadow\//g],_=/(?:>>>)|(?:\/deep\/)/g,b="([>\\s~+[.,{:][\\s\\S]*)?$",P=a.RegExpWrapper.create(h,"im"),E=/:host/gim,w=/:host-context/gim,C=/\/\*[\s\S]*?\*\//g,R=/(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g,S=/([{}])/g,O="{",T="}",x="%BLOCK%",A=function(){function t(t,e){this.selector=t,this.content=e}return t}();e.CssRule=A,e.processRules=i;var I=function(){function t(t,e){this.escapedString=t,this.blocks=e}return t}()},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(6),s=n(169),a=n(174),u=n(176),c=n(162),p=function(){function t(t,e,n){this.statements=t,this.viewFactoryVar=e,this.dependencies=n}return t}();e.ViewCompileResult=p;var l=function(){function t(t){this._genConfig=t}return t.prototype.compileComponent=function(t,e,n,r){var i=[],o=[],c=new a.CompileView(t,this._genConfig,r,n,0,s.CompileElement.createNull(),[]);return u.buildView(c,e,o,i),new p(i,c.viewFactory.name,o)},t=r([o.Injectable(),i("design:paramtypes",[c.CompilerConfig])],t)}();e.ViewCompiler=l},function(t,e,n){"use strict";function r(t,e,n,r){var i;return i=e>0?s.literal(t).lowerEquals(u.InjectMethodVars.requestNodeIndex).and(u.InjectMethodVars.requestNodeIndex.lowerEquals(s.literal(t+e))):s.literal(t).identical(u.InjectMethodVars.requestNodeIndex),new s.IfStmt(u.InjectMethodVars.token.identical(f.createDiTokenExpression(n.token)).and(i),[new s.ReturnStatement(r)])}function i(t,e,n,r,i,o){var a,u,p=o.view;if(r?(a=s.literalArr(n),u=new s.ArrayType(s.DYNAMIC_TYPE)):(a=n[0],u=n[0].type),c.isBlank(u)&&(u=s.DYNAMIC_TYPE),i)p.fields.push(new s.ClassField(t,u,[s.StmtModifier.Private])),p.createMethod.addStmt(s.THIS_EXPR.prop(t).set(a).toStmt());else{var l="_"+t;p.fields.push(new s.ClassField(l,u,[s.StmtModifier.Private]));var h=new v.CompileMethod(p);h.resetDebugInfo(o.nodeIndex,o.sourceAst),h.addStmt(new s.IfStmt(s.THIS_EXPR.prop(l).isBlank(),[s.THIS_EXPR.prop(l).set(a).toStmt()])),h.addStmt(new s.ReturnStatement(s.THIS_EXPR.prop(l))),p.getters.push(new s.ClassGetter(t,h.finish(),u))}return s.THIS_EXPR.prop(t)}var o=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},s=n(164),a=n(158),u=n(170),c=n(5),p=n(15),l=n(139),h=n(155),f=n(171),d=n(172),v=n(173),y=function(){function t(t,e,n,r,i){this.parent=t,this.view=e,this.nodeIndex=n,this.renderNode=r,this.sourceAst=i}return t.prototype.isNull=function(){return c.isBlank(this.renderNode)},t.prototype.isRootElement=function(){return this.view!=this.parent.view},t}();e.CompileNode=y;var m=function(t){function e(e,n,r,i,o,u,p,l,f,d,v){t.call(this,e,n,r,i,o),this.component=u,this._directives=p,this._resolvedProvidersArray=l,this.hasViewContainer=f,this.hasEmbeddedView=d,this.variableTokens=v,this._compViewExpr=null,this._instances=new h.CompileTokenMap,this._queryCount=0,this._queries=new h.CompileTokenMap,this._componentConstructorViewQueryLists=[],this.contentNodesByNgContentIndex=null,this.elementRef=s.importExpr(a.Identifiers.ElementRef).instantiate([this.renderNode]),this._instances.add(a.identifierToken(a.Identifiers.ElementRef),this.elementRef),this.injector=s.THIS_EXPR.callMethod("injector",[s.literal(this.nodeIndex)]),this._instances.add(a.identifierToken(a.Identifiers.Injector),this.injector),this._instances.add(a.identifierToken(a.Identifiers.Renderer),s.THIS_EXPR.prop("renderer")),(this.hasViewContainer||this.hasEmbeddedView||c.isPresent(this.component))&&this._createAppElement()}return o(e,t),e.createNull=function(){return new e(null,null,null,null,null,null,[],[],!1,!1,{})},e.prototype._createAppElement=function(){var t="_appEl_"+this.nodeIndex,e=this.isRootElement()?null:this.parent.nodeIndex;this.view.fields.push(new s.ClassField(t,s.importType(a.Identifiers.AppElement),[s.StmtModifier.Private]));var n=s.THIS_EXPR.prop(t).set(s.importExpr(a.Identifiers.AppElement).instantiate([s.literal(this.nodeIndex),s.literal(e),s.THIS_EXPR,this.renderNode])).toStmt();this.view.createMethod.addStmt(n),this.appElement=s.THIS_EXPR.prop(t),this._instances.add(a.identifierToken(a.Identifiers.AppElement),this.appElement)},e.prototype.setComponentView=function(t){this._compViewExpr=t,this.contentNodesByNgContentIndex=p.ListWrapper.createFixedSize(this.component.template.ngContentSelectors.length);for(var e=0;e=i})),r._directives.length>0&&i++,r=r.parent;return e=this.view.componentView.viewQueries.get(t),c.isPresent(e)&&p.ListWrapper.addAll(n,e),n},e.prototype._addQuery=function(t,e){var n="_query_"+t.selectors[0].name+"_"+this.nodeIndex+"_"+this._queryCount++,r=d.createQueryList(t,e,n,this.view),i=new d.CompileQuery(t,r,e,this.view);return d.addQueryToTokenMap(this._queries,i),i},e.prototype._getLocalDependency=function(t,e){var n=null;if(c.isBlank(n)&&c.isPresent(e.query)&&(n=this._addQuery(e.query,null).queryList),c.isBlank(n)&&c.isPresent(e.viewQuery)&&(n=d.createQueryList(e.viewQuery,null,"_viewQuery_"+e.viewQuery.selectors[0].name+"_"+this.nodeIndex+"_"+this._componentConstructorViewQueryLists.length,this.view),this._componentConstructorViewQueryLists.push(n)),c.isPresent(e.token)){if(c.isBlank(n)&&e.token.equalsTo(a.identifierToken(a.Identifiers.ChangeDetectorRef)))return t===l.ProviderAstType.Component?this._compViewExpr.prop("ref"):s.THIS_EXPR.prop("ref");c.isBlank(n)&&(n=this._instances.get(e.token))}return n},e.prototype._getDependency=function(t,e){var n=this,r=null;for(e.isValue&&(r=s.literal(e.value)),c.isBlank(r)&&!e.isSkipSelf&&(r=this._getLocalDependency(t,e));c.isBlank(r)&&!n.parent.isNull();)n=n.parent,r=n._getLocalDependency(l.ProviderAstType.PublicService,new h.CompileDiDependencyMetadata({token:e.token}));return c.isBlank(r)&&(r=f.injectFromViewParentInjector(e.token,e.isOptional)),c.isBlank(r)&&(r=s.NULL_EXPR),f.getPropertyInView(r,this.view,n.view)},e}(y);e.CompileElement=m;var g=function(){function t(t,e){this.query=t,this.read=c.isPresent(t.meta.read)?t.meta.read:e}return t}()},function(t,e,n){"use strict";function r(t,e){if(i.isBlank(e))return c.NULL_EXPR;var n=i.resolveEnumToken(t.runtime,e);return c.importExpr(new o.CompileIdentifierMetadata({name:t.name+"."+n,moduleUrl:t.moduleUrl,runtime:e}))}var i=n(5),o=n(155),s=n(28),a=n(36),u=n(68),c=n(164),p=n(158),l=function(){function t(){}return t.fromValue=function(t){return r(p.Identifiers.ViewType,t)},t.HOST=t.fromValue(u.ViewType.HOST),t.COMPONENT=t.fromValue(u.ViewType.COMPONENT),t.EMBEDDED=t.fromValue(u.ViewType.EMBEDDED),t}();e.ViewTypeEnum=l;var h=function(){function t(){}return t.fromValue=function(t){return r(p.Identifiers.ViewEncapsulation,t)},t.Emulated=t.fromValue(a.ViewEncapsulation.Emulated),t.Native=t.fromValue(a.ViewEncapsulation.Native),t.None=t.fromValue(a.ViewEncapsulation.None),t}();e.ViewEncapsulationEnum=h;var f=function(){function t(){}return t.fromValue=function(t){return r(p.Identifiers.ChangeDetectorState,t)},t.NeverChecked=t.fromValue(s.ChangeDetectorState.NeverChecked),t.CheckedBefore=t.fromValue(s.ChangeDetectorState.CheckedBefore),t.Errored=t.fromValue(s.ChangeDetectorState.Errored),t}();e.ChangeDetectorStateEnum=f;var d=function(){function t(){}return t.fromValue=function(t){return r(p.Identifiers.ChangeDetectionStrategy,t)},t.CheckOnce=t.fromValue(s.ChangeDetectionStrategy.CheckOnce),t.Checked=t.fromValue(s.ChangeDetectionStrategy.Checked),t.CheckAlways=t.fromValue(s.ChangeDetectionStrategy.CheckAlways),t.Detached=t.fromValue(s.ChangeDetectionStrategy.Detached),t.OnPush=t.fromValue(s.ChangeDetectionStrategy.OnPush),t.Default=t.fromValue(s.ChangeDetectionStrategy.Default),t}();e.ChangeDetectionStrategyEnum=d;var v=function(){function t(){}return t.viewUtils=c.variable("viewUtils"),t.parentInjector=c.variable("parentInjector"),t.declarationEl=c.variable("declarationEl"),t}();e.ViewConstructorVars=v;var y=function(){function t(){}return t.renderer=c.THIS_EXPR.prop("renderer"),t.projectableNodes=c.THIS_EXPR.prop("projectableNodes"),t.viewUtils=c.THIS_EXPR.prop("viewUtils"),t}();e.ViewProperties=y;var m=function(){function t(){}return t.event=c.variable("$event"),t}();e.EventHandlerVars=m;var g=function(){function t(){}return t.token=c.variable("token"),t.requestNodeIndex=c.variable("requestNodeIndex"),t.notFoundResult=c.variable("notFoundResult"),t}();e.InjectMethodVars=g;var _=function(){function t(){}return t.throwOnChange=c.variable("throwOnChange"),t.changes=c.variable("changes"),t.changed=c.variable("changed"),t.valUnwrapper=c.variable("valUnwrapper"),t}();e.DetectChangesVars=_},function(t,e,n){"use strict";function r(t,e,n){if(e===n)return t;for(var r=l.THIS_EXPR,i=e;i!==n&&c.isPresent(i.declarationElement.view);)i=i.declarationElement.view,r=r.prop("parent");if(i!==n)throw new p.BaseException("Internal error: Could not calculate a property in a parent view: "+t);if(t instanceof l.ReadPropExpr){var o=t;(n.fields.some(function(t){return t.name==o.name})||n.getters.some(function(t){return t.name==o.name}))&&(r=r.cast(n.classType))}return l.replaceVarInExpression(l.THIS_EXPR.name,r,t)}function i(t,e){var n=[s(t)];return e&&n.push(l.NULL_EXPR),l.THIS_EXPR.prop("parentInjector").callMethod("get",n)}function o(t,e){return"viewFactory_"+t.type.name+e}function s(t){return c.isPresent(t.value)?l.literal(t.value):t.identifierIsInstance?l.importExpr(t.identifier).instantiate([],l.importType(t.identifier,[],[l.TypeModifier.Const])):l.importExpr(t.identifier)}function a(t){for(var e=[],n=l.literalArr([]),r=0;r0&&(n=n.callMethod(l.BuiltinMethod.ConcatArray,[l.literalArr(e)]),e=[]),n=n.callMethod(l.BuiltinMethod.ConcatArray,[i])):e.push(i)}return e.length>0&&(n=n.callMethod(l.BuiltinMethod.ConcatArray,[l.literalArr(e)])),n}function u(t,e,n,r){r.fields.push(new l.ClassField(n.name,null,[l.StmtModifier.Private]));var i=e0?s.values[s.values.length-1]:null;if(e instanceof h&&e.view===t.embeddedView)s=e;else{var n=new h(t.embeddedView,[]);s.values.push(n),s=n}}),s.values.push(t),r.length>0&&e.dirtyParentQueriesMethod.addStmt(o.callMethod("setDirty",[]).toStmt())},t.prototype.afterChildren=function(t){var e=r(this._values),n=[this.queryList.callMethod("reset",[c.literalArr(e)]).toStmt()];if(a.isPresent(this.ownerDirectiveExpression)){var i=this.meta.first?this.queryList.prop("first"):this.queryList;n.push(this.ownerDirectiveExpression.prop(this.meta.propertyName).set(i).toStmt())}this.meta.first||n.push(this.queryList.callMethod("notifyOnChanges",[]).toStmt()),t.addStmt(new c.IfStmt(this.queryList.prop("dirty"),n))},t}();e.CompileQuery=f,e.createQueryList=o,e.addQueryToTokenMap=s},function(t,e,n){"use strict";var r=n(5),i=n(15),o=n(164),s=function(){function t(t,e){this.nodeIndex=t,this.sourceAst=e}return t}(),a=new s(null,null),u=function(){function t(t){this._view=t,this._newState=a,this._currState=a,this._bodyStatements=[],this._debugEnabled=this._view.genConfig.genDebugInfo}return t.prototype._updateDebugContextIfNeeded=function(){if(this._newState.nodeIndex!==this._currState.nodeIndex||this._newState.sourceAst!==this._currState.sourceAst){var t=this._updateDebugContext(this._newState);r.isPresent(t)&&this._bodyStatements.push(t.toStmt())}},t.prototype._updateDebugContext=function(t){if(this._currState=this._newState=t,this._debugEnabled){var e=r.isPresent(t.sourceAst)?t.sourceAst.sourceSpan.start:null;return o.THIS_EXPR.callMethod("debug",[o.literal(t.nodeIndex),r.isPresent(e)?o.literal(e.line):o.NULL_EXPR,r.isPresent(e)?o.literal(e.col):o.NULL_EXPR])}return null},t.prototype.resetDebugInfoExpr=function(t,e){var n=this._updateDebugContext(new s(t,e));return r.isPresent(n)?n:o.NULL_EXPR},t.prototype.resetDebugInfo=function(t,e){this._newState=new s(t,e)},t.prototype.addStmt=function(t){this._updateDebugContextIfNeeded(),this._bodyStatements.push(t)},t.prototype.addStmts=function(t){this._updateDebugContextIfNeeded(),i.ListWrapper.addAll(this._bodyStatements,t)},t.prototype.finish=function(){return this._bodyStatements},t.prototype.isEmpty=function(){return 0===this._bodyStatements.length},t}();e.CompileMethod=u},function(t,e,n){"use strict";function r(t,e){return e>0?l.ViewType.EMBEDDED:t.type.isHost?l.ViewType.HOST:l.ViewType.COMPONENT}var i=n(5),o=n(15),s=n(164),a=n(170),u=n(172),c=n(173),p=n(175),l=n(68),h=n(155),f=n(171),d=function(){function t(t,e,n,a,p,d,v){var y=this;this.component=t,this.genConfig=e,this.pipeMetas=n,this.styles=a,this.viewIndex=p,this.declarationElement=d,this.templateVariableBindings=v,this.nodes=[],this.rootNodesOrAppElements=[],this.bindings=[],this.classStatements=[],this.eventHandlerMethods=[],this.fields=[],this.getters=[],this.disposables=[],this.subscriptions=[],this.purePipes=new Map,this.pipes=[],this.variables=new Map,this.literalArrayCount=0,this.literalMapCount=0,this.pipeCount=0,this.createMethod=new c.CompileMethod(this),this.injectorGetMethod=new c.CompileMethod(this),this.updateContentQueriesMethod=new c.CompileMethod(this),this.dirtyParentQueriesMethod=new c.CompileMethod(this),this.updateViewQueriesMethod=new c.CompileMethod(this),this.detectChangesInInputsMethod=new c.CompileMethod(this),this.detectChangesRenderPropertiesMethod=new c.CompileMethod(this),this.afterContentLifecycleCallbacksMethod=new c.CompileMethod(this),this.afterViewLifecycleCallbacksMethod=new c.CompileMethod(this),this.destroyMethod=new c.CompileMethod(this),this.viewType=r(t,p),this.className="_View_"+t.type.name+p,this.classType=s.importType(new h.CompileIdentifierMetadata({name:this.className})),this.viewFactory=s.variable(f.getViewFactoryName(t,p)),this.viewType===l.ViewType.COMPONENT||this.viewType===l.ViewType.HOST?this.componentView=this:this.componentView=this.declarationElement.view.componentView;var m=new h.CompileTokenMap;if(this.viewType===l.ViewType.COMPONENT){var g=s.THIS_EXPR.prop("context");o.ListWrapper.forEachWithIndex(this.component.viewQueries,function(t,e){var n="_viewQuery_"+t.selectors[0].name+"_"+e,r=u.createQueryList(t,g,n,y),i=new u.CompileQuery(t,r,g,y);u.addQueryToTokenMap(m,i)});var _=0;this.component.type.diDeps.forEach(function(t){if(i.isPresent(t.viewQuery)){var e=s.THIS_EXPR.prop("declarationAppElement").prop("componentConstructorViewQueries").key(s.literal(_++)),n=new u.CompileQuery(t.viewQuery,e,null,y);u.addQueryToTokenMap(m,n)}})}this.viewQueries=m,v.forEach(function(t){y.variables.set(t[1],s.THIS_EXPR.prop("locals").key(s.literal(t[0])))}),this.declarationElement.isNull()||this.declarationElement.setEmbeddedView(this)}return t.prototype.callPipe=function(t,e,n){var r=this.componentView,o=r.purePipes.get(t);return i.isBlank(o)&&(o=new p.CompilePipe(r,t),o.pure&&r.purePipes.set(t,o),r.pipes.push(o)),o.call(this,[e].concat(n))},t.prototype.getVariable=function(t){if(t==a.EventHandlerVars.event.name)return a.EventHandlerVars.event;for(var e=this,n=e.variables.get(t);i.isBlank(n)&&i.isPresent(e.declarationElement.view);)e=e.declarationElement.view,n=e.variables.get(t);return i.isPresent(n)?f.getPropertyInView(n,this,e):null},t.prototype.createLiteralArray=function(t){for(var e=s.THIS_EXPR.prop("_arr_"+this.literalArrayCount++),n=[],r=[],i=0;i=0;r--){var s=t.pipeMetas[r];if(s.name==e){n=s;break}}if(i.isBlank(n))throw new o.BaseException("Illegal state: Could not find pipe "+e+" although the parser should have detected this error!");return n}var i=n(5),o=n(12),s=n(164),a=n(158),u=n(171),c=function(){function t(t,e){this.instance=t,this.argCount=e}return t}(),p=function(){function t(t,e){this.view=t,this._purePipeProxies=[],this.meta=r(t,e),this.instance=s.THIS_EXPR.prop("_pipe_"+e+"_"+t.pipeCount++)}return Object.defineProperty(t.prototype,"pure",{get:function(){return this.meta.pure},enumerable:!0,configurable:!0}),t.prototype.create=function(){var t=this,e=this.meta.type.diDeps.map(function(t){return t.token.equalsTo(a.identifierToken(a.Identifiers.ChangeDetectorRef))?s.THIS_EXPR.prop("ref"):u.injectFromViewParentInjector(t.token,!1)});this.view.fields.push(new s.ClassField(this.instance.name,s.importType(this.meta.type),[s.StmtModifier.Private])),this.view.createMethod.resetDebugInfo(null,null),this.view.createMethod.addStmt(s.THIS_EXPR.prop(this.instance.name).set(s.importExpr(this.meta.type).instantiate(e)).toStmt()),this._purePipeProxies.forEach(function(e){u.createPureProxy(t.instance.prop("transform").callMethod(s.BuiltinMethod.bind,[t.instance]),e.argCount,e.instance,t.view)})},t.prototype.call=function(t,e){if(this.meta.pure){var n=new c(s.THIS_EXPR.prop(this.instance.name+"_"+this._purePipeProxies.length),e.length);return this._purePipeProxies.push(n),u.getPropertyInView(s.importExpr(a.Identifiers.castByValue).callFn([n.instance,this.instance.prop("transform")]),t,this.view).callFn(e)}return u.getPropertyInView(this.instance,t,this.view).callMethod("transform",e)},t}();e.CompilePipe=p},function(t,e,n){"use strict";function r(t,e,n,r){var i=new L(t,n,r);return S.templateVisitAll(i,e,t.declarationElement.isNull()?t.declarationElement:t.declarationElement.parent),I.bindView(t,e),t.afterNodes(),c(t,r),i.nestedViewCount}function i(t,e){var n={};return _.StringMapWrapper.forEach(t,function(t,e){n[e]=t}),e.forEach(function(t){_.StringMapWrapper.forEach(t.hostAttributes,function(t,e){var r=n[e];n[e]=g.isPresent(r)?a(e,r,t):t})}),u(n)}function o(t){var e={};return t.forEach(function(t){e[t.name]=t.value}),e}function s(t,e,n){var r={},i=null;return e.forEach(function(t){t.directive.isComponent&&(i=t.directive),t.exportAsVars.forEach(function(e){r[e.name]=P.identifierToken(t.directive.type)})}),t.forEach(function(t){r[t.name]=g.isPresent(i)?P.identifierToken(i.type):null}),r}function a(t,e,n){return t==k||t==N?e+" "+n:n}function u(t){var e=[];_.StringMapWrapper.forEach(t,function(t,n){e.push([n,t])}),_.ListWrapper.sort(e,function(t,e){return g.StringWrapper.compare(t[0],e[0])});var n=[];return e.forEach(function(t){n.push([t[0],t[1]])}),n}function c(t,e){var n=b.NULL_EXPR;t.genConfig.genDebugInfo&&(n=b.variable("nodeDebugInfos_"+t.component.type.name+t.viewIndex),e.push(n.set(b.literalArr(t.nodes.map(p),new b.ArrayType(new b.ExternalType(P.Identifiers.StaticNodeDebugInfo),[b.TypeModifier.Const]))).toDeclStmt(null,[b.StmtModifier.Final])));var r=b.variable("renderType_"+t.component.type.name);0===t.viewIndex&&e.push(r.set(b.NULL_EXPR).toDeclStmt(b.importType(P.Identifiers.RenderComponentType)));var i=l(t,r,n);e.push(i),e.push(h(t,i,r))}function p(t){var e=t instanceof R.CompileElement?t:null,n=[],r=b.NULL_EXPR,i=[];return g.isPresent(e)&&(n=e.getProviderTokens(),g.isPresent(e.component)&&(r=O.createDiTokenExpression(P.identifierToken(e.component.type))),_.StringMapWrapper.forEach(e.variableTokens,function(t,e){i.push([e,g.isPresent(t)?O.createDiTokenExpression(t):b.NULL_EXPR])})),b.importExpr(P.Identifiers.StaticNodeDebugInfo).instantiate([b.literalArr(n,new b.ArrayType(b.DYNAMIC_TYPE,[b.TypeModifier.Const])),r,b.literalMap(i,new b.MapType(b.DYNAMIC_TYPE,[b.TypeModifier.Const]))],b.importType(P.Identifiers.StaticNodeDebugInfo,null,[b.TypeModifier.Const]))}function l(t,e,n){var r=t.templateVariableBindings.map(function(t){return[t[0],b.NULL_EXPR]}),i=[new b.FnParam(E.ViewConstructorVars.viewUtils.name,b.importType(P.Identifiers.ViewUtils)),new b.FnParam(E.ViewConstructorVars.parentInjector.name,b.importType(P.Identifiers.Injector)),new b.FnParam(E.ViewConstructorVars.declarationEl.name,b.importType(P.Identifiers.AppElement))],o=new b.ClassMethod(null,i,[b.SUPER_EXPR.callFn([b.variable(t.className),e,E.ViewTypeEnum.fromValue(t.viewType),b.literalMap(r),E.ViewConstructorVars.viewUtils,E.ViewConstructorVars.parentInjector,E.ViewConstructorVars.declarationEl,E.ChangeDetectionStrategyEnum.fromValue(m(t)),n]).toStmt()]),s=[new b.ClassMethod("createInternal",[new b.FnParam(V.name,b.STRING_TYPE)],f(t),b.importType(P.Identifiers.AppElement)),new b.ClassMethod("injectorGetInternal",[new b.FnParam(E.InjectMethodVars.token.name,b.DYNAMIC_TYPE),new b.FnParam(E.InjectMethodVars.requestNodeIndex.name,b.NUMBER_TYPE),new b.FnParam(E.InjectMethodVars.notFoundResult.name,b.DYNAMIC_TYPE)],v(t.injectorGetMethod.finish(),E.InjectMethodVars.notFoundResult),b.DYNAMIC_TYPE),new b.ClassMethod("detectChangesInternal",[new b.FnParam(E.DetectChangesVars.throwOnChange.name,b.BOOL_TYPE)],d(t)),new b.ClassMethod("dirtyParentQueriesInternal",[],t.dirtyParentQueriesMethod.finish()),new b.ClassMethod("destroyInternal",[],t.destroyMethod.finish())].concat(t.eventHandlerMethods),a=new b.ClassStmt(t.className,b.importExpr(P.Identifiers.AppView,[y(t)]),t.fields,t.getters,o,s.filter(function(t){return t.body.length>0}));return a}function h(t,e,n){var r,i=[new b.FnParam(E.ViewConstructorVars.viewUtils.name,b.importType(P.Identifiers.ViewUtils)),new b.FnParam(E.ViewConstructorVars.parentInjector.name,b.importType(P.Identifiers.Injector)),new b.FnParam(E.ViewConstructorVars.declarationEl.name,b.importType(P.Identifiers.AppElement))],o=[];return r=t.component.template.templateUrl==t.component.type.moduleUrl?t.component.type.moduleUrl+" class "+t.component.type.name+" - inline template":t.component.template.templateUrl,0===t.viewIndex&&(o=[new b.IfStmt(n.identical(b.NULL_EXPR),[n.set(E.ViewConstructorVars.viewUtils.callMethod("createRenderComponentType",[b.literal(r),b.literal(t.component.template.ngContentSelectors.length),E.ViewEncapsulationEnum.fromValue(t.component.template.encapsulation),t.styles])).toStmt()])]), -b.fn(i,o.concat([new b.ReturnStatement(b.variable(e.name).instantiate(e.constructorMethod.params.map(function(t){return b.variable(t.name)})))]),b.importType(P.Identifiers.AppView,[y(t)])).toDeclStmt(t.viewFactory.name,[b.StmtModifier.Final])}function f(t){var e=b.NULL_EXPR,n=[];t.viewType===T.ViewType.COMPONENT&&(e=E.ViewProperties.renderer.callMethod("createViewRoot",[b.THIS_EXPR.prop("declarationAppElement").prop("nativeElement")]),n=[D.set(e).toDeclStmt(b.importType(t.genConfig.renderTypes.renderNode),[b.StmtModifier.Final])]);var r;return r=t.viewType===T.ViewType.HOST?t.nodes[0].appElement:b.NULL_EXPR,n.concat(t.createMethod.finish()).concat([b.THIS_EXPR.callMethod("init",[O.createFlatArray(t.rootNodesOrAppElements),b.literalArr(t.nodes.map(function(t){return t.renderNode})),b.literalArr(t.disposables),b.literalArr(t.subscriptions)]).toStmt(),new b.ReturnStatement(r)])}function d(t){var e=[];if(t.detectChangesInInputsMethod.isEmpty()&&t.updateContentQueriesMethod.isEmpty()&&t.afterContentLifecycleCallbacksMethod.isEmpty()&&t.detectChangesRenderPropertiesMethod.isEmpty()&&t.updateViewQueriesMethod.isEmpty()&&t.afterViewLifecycleCallbacksMethod.isEmpty())return e;_.ListWrapper.addAll(e,t.detectChangesInInputsMethod.finish()),e.push(b.THIS_EXPR.callMethod("detectContentChildrenChanges",[E.DetectChangesVars.throwOnChange]).toStmt());var n=t.updateContentQueriesMethod.finish().concat(t.afterContentLifecycleCallbacksMethod.finish());n.length>0&&e.push(new b.IfStmt(b.not(E.DetectChangesVars.throwOnChange),n)),_.ListWrapper.addAll(e,t.detectChangesRenderPropertiesMethod.finish()),e.push(b.THIS_EXPR.callMethod("detectViewChildrenChanges",[E.DetectChangesVars.throwOnChange]).toStmt());var r=t.updateViewQueriesMethod.finish().concat(t.afterViewLifecycleCallbacksMethod.finish());r.length>0&&e.push(new b.IfStmt(b.not(E.DetectChangesVars.throwOnChange),r));var i=[],o=b.findReadVarNames(e);return _.SetWrapper.has(o,E.DetectChangesVars.changed.name)&&i.push(E.DetectChangesVars.changed.set(b.literal(!0)).toDeclStmt(b.BOOL_TYPE)),_.SetWrapper.has(o,E.DetectChangesVars.changes.name)&&i.push(E.DetectChangesVars.changes.set(b.NULL_EXPR).toDeclStmt(new b.MapType(b.importType(P.Identifiers.SimpleChange)))),_.SetWrapper.has(o,E.DetectChangesVars.valUnwrapper.name)&&i.push(E.DetectChangesVars.valUnwrapper.set(b.importExpr(P.Identifiers.ValueUnwrapper).instantiate([])).toDeclStmt(null,[b.StmtModifier.Final])),i.concat(e)}function v(t,e){return t.length>0?t.concat([new b.ReturnStatement(e)]):t}function y(t){var e=t.component.type;return e.isHost?b.DYNAMIC_TYPE:b.importType(e)}function m(t){var e;return e=t.viewType===T.ViewType.COMPONENT?w.isDefaultChangeDetectionStrategy(t.component.changeDetection)?w.ChangeDetectionStrategy.CheckAlways:w.ChangeDetectionStrategy.CheckOnce:w.ChangeDetectionStrategy.CheckAlways}var g=n(5),_=n(15),b=n(164),P=n(158),E=n(170),w=n(28),C=n(174),R=n(169),S=n(139),O=n(171),T=n(68),x=n(36),A=n(155),I=n(177),M="$implicit",k="class",N="style",D=b.variable("parentRenderNode"),V=b.variable("rootSelector"),j=function(){function t(t,e){this.comp=t,this.factoryPlaceholder=e}return t}();e.ViewCompileDependency=j,e.buildView=r;var L=function(){function t(t,e,n){this.view=t,this.targetDependencies=e,this.targetStatements=n,this.nestedViewCount=0}return t.prototype._isRootNode=function(t){return t.view!==this.view},t.prototype._addRootNodeAndProject=function(t,e,n){var r=t instanceof R.CompileElement&&t.hasViewContainer?t.appElement:null;this._isRootNode(n)?this.view.viewType!==T.ViewType.COMPONENT&&this.view.rootNodesOrAppElements.push(g.isPresent(r)?r:t.renderNode):g.isPresent(n.component)&&g.isPresent(e)&&n.addContentNode(e,g.isPresent(r)?r:t.renderNode)},t.prototype._getParentRenderNode=function(t){return this._isRootNode(t)?this.view.viewType===T.ViewType.COMPONENT?D:b.NULL_EXPR:g.isPresent(t.component)&&t.component.template.encapsulation!==x.ViewEncapsulation.Native?b.NULL_EXPR:t.renderNode},t.prototype.visitBoundText=function(t,e){return this._visitText(t,"",t.ngContentIndex,e)},t.prototype.visitText=function(t,e){return this._visitText(t,t.value,t.ngContentIndex,e)},t.prototype._visitText=function(t,e,n,r){var i="_text_"+this.view.nodes.length;this.view.fields.push(new b.ClassField(i,b.importType(this.view.genConfig.renderTypes.renderText),[b.StmtModifier.Private]));var o=b.THIS_EXPR.prop(i),s=new R.CompileNode(r,this.view,this.view.nodes.length,o,t),a=b.THIS_EXPR.prop(i).set(E.ViewProperties.renderer.callMethod("createText",[this._getParentRenderNode(r),b.literal(e),this.view.createMethod.resetDebugInfoExpr(this.view.nodes.length,t)])).toStmt();return this.view.nodes.push(s),this.view.createMethod.addStmt(a),this._addRootNodeAndProject(s,n,r),o},t.prototype.visitNgContent=function(t,e){this.view.createMethod.resetDebugInfo(null,t);var n=this._getParentRenderNode(e),r=E.ViewProperties.projectableNodes.key(b.literal(t.index),new b.ArrayType(b.importType(this.view.genConfig.renderTypes.renderNode)));return n!==b.NULL_EXPR?this.view.createMethod.addStmt(E.ViewProperties.renderer.callMethod("projectNodes",[n,b.importExpr(P.Identifiers.flattenNestedViewRenderNodes).callFn([r])]).toStmt()):this._isRootNode(e)?this.view.viewType!==T.ViewType.COMPONENT&&this.view.rootNodesOrAppElements.push(r):g.isPresent(e.component)&&g.isPresent(t.ngContentIndex)&&e.addContentNode(t.ngContentIndex,r),null},t.prototype.visitElement=function(t,e){var n,r=this.view.nodes.length,a=this.view.createMethod.resetDebugInfoExpr(r,t);n=0===r&&this.view.viewType===T.ViewType.HOST?b.THIS_EXPR.callMethod("selectOrCreateHostElement",[b.literal(t.name),V,a]):E.ViewProperties.renderer.callMethod("createElement",[this._getParentRenderNode(e),b.literal(t.name),a]);var u="_el_"+r;this.view.fields.push(new b.ClassField(u,b.importType(this.view.genConfig.renderTypes.renderElement),[b.StmtModifier.Private])),this.view.createMethod.addStmt(b.THIS_EXPR.prop(u).set(n).toStmt());for(var c=b.THIS_EXPR.prop(u),p=t.getComponent(),l=t.directives.map(function(t){return t.directive}),h=s(t.exportAsVars,t.directives,this.view.viewType),f=o(t.attrs),d=i(f,l),v=0;v0?t.value:M,t.name]}),a=t.directives.map(function(t){return t.directive}),u=new R.CompileElement(e,this.view,n,o,t,null,a,t.providers,t.hasViewContainer,!0,{});this.view.nodes.push(u),this.nestedViewCount++;var c=new C.CompileView(this.view.component,this.view.genConfig,this.view.pipeMetas,b.NULL_EXPR,this.view.viewIndex+this.nestedViewCount,u,s);return this.nestedViewCount+=r(c,t.children,this.targetDependencies,this.targetStatements),u.beforeChildren(),this._addRootNodeAndProject(u,t.ngContentIndex,e),u.afterChildren(0),null},t.prototype.visitAttr=function(t,e){return null},t.prototype.visitDirective=function(t,e){return null},t.prototype.visitEvent=function(t,e){return null},t.prototype.visitVariable=function(t,e){return null},t.prototype.visitDirectiveProperty=function(t,e){return null},t.prototype.visitElementProperty=function(t,e){return null},t}()},function(t,e,n){"use strict";function r(t,e){var n=new c(t);o.templateVisitAll(n,e),t.pipes.forEach(function(t){u.bindPipeDestroyLifecycleCallbacks(t.meta,t.instance,t.view)})}var i=n(15),o=n(139),s=n(178),a=n(181),u=n(182);e.bindView=r;var c=function(){function t(t){this.view=t,this._nodeIndex=0}return t.prototype.visitBoundText=function(t,e){var n=this.view.nodes[this._nodeIndex++];return s.bindRenderText(t,n,this.view),null},t.prototype.visitText=function(t,e){return this._nodeIndex++,null},t.prototype.visitNgContent=function(t,e){return null},t.prototype.visitElement=function(t,e){var n=this.view.nodes[this._nodeIndex++],r=a.collectEventListeners(t.outputs,t.directives,n);return s.bindRenderInputs(t.inputs,n),a.bindRenderOutputs(r),i.ListWrapper.forEachWithIndex(t.directives,function(t,e){var i=n.directiveInstances[e];s.bindDirectiveInputs(t,i,n),u.bindDirectiveDetectChangesLifecycleCallbacks(t,i,n),s.bindDirectiveHostProps(t,i,n),a.bindDirectiveOutputs(t,i,r)}),o.templateVisitAll(this,t.children,n),i.ListWrapper.forEachWithIndex(t.directives,function(t,e){var r=n.directiveInstances[e];u.bindDirectiveAfterContentLifecycleCallbacks(t.directive,r,n),u.bindDirectiveAfterViewLifecycleCallbacks(t.directive,r,n),u.bindDirectiveDestroyLifecycleCallbacks(t.directive,r,n)}),null},t.prototype.visitEmbeddedTemplate=function(t,e){var n=this.view.nodes[this._nodeIndex++],r=a.collectEventListeners(t.outputs,t.directives,n);return i.ListWrapper.forEachWithIndex(t.directives,function(t,e){var i=n.directiveInstances[e];s.bindDirectiveInputs(t,i,n),u.bindDirectiveDetectChangesLifecycleCallbacks(t,i,n),a.bindDirectiveOutputs(t,i,r),u.bindDirectiveAfterContentLifecycleCallbacks(t.directive,i,n),u.bindDirectiveAfterViewLifecycleCallbacks(t.directive,i,n),u.bindDirectiveDestroyLifecycleCallbacks(t.directive,i,n)}),null},t.prototype.visitAttr=function(t,e){return null},t.prototype.visitDirective=function(t,e){return null},t.prototype.visitEvent=function(t,e){return null},t.prototype.visitVariable=function(t,e){return null},t.prototype.visitDirectiveProperty=function(t,e){return null},t.prototype.visitElementProperty=function(t,e){return null},t}()},function(t,e,n){"use strict";function r(t){return h.THIS_EXPR.prop("_expr_"+t)}function i(t){return h.variable("currVal_"+t)}function o(t,e,n,r,i,o,s){var a=b.convertCdExpressionToIr(t,i,r,d.DetectChangesVars.valUnwrapper);if(!y.isBlank(a.expression)){if(t.fields.push(new h.ClassField(n.name,null,[h.StmtModifier.Private])),t.createMethod.addStmt(h.THIS_EXPR.prop(n.name).set(h.importExpr(f.Identifiers.uninitialized)).toStmt()),a.needsValueUnwrapper){var u=d.DetectChangesVars.valUnwrapper.callMethod("reset",[]).toStmt();s.addStmt(u)}s.addStmt(e.set(a.expression).toDeclStmt(null,[h.StmtModifier.Final]));var c=h.importExpr(f.Identifiers.checkBinding).callFn([d.DetectChangesVars.throwOnChange,n,e]);a.needsValueUnwrapper&&(c=d.DetectChangesVars.valUnwrapper.prop("hasWrappedValue").or(c)),s.addStmt(new h.IfStmt(c,o.concat([h.THIS_EXPR.prop(n.name).set(e).toStmt()])))}}function s(t,e,n){var s=n.bindings.length;n.bindings.push(new P.CompileBinding(e,t));var a=i(s),u=r(s);n.detectChangesRenderPropertiesMethod.resetDebugInfo(e.nodeIndex,t),o(n,a,u,t.value,h.THIS_EXPR.prop("context"),[h.THIS_EXPR.prop("renderer").callMethod("setText",[e.renderNode,a]).toStmt()],n.detectChangesRenderPropertiesMethod)}function a(t,e,n){var s=n.view,a=n.renderNode;t.forEach(function(t){var u=s.bindings.length;s.bindings.push(new P.CompileBinding(n,t)),s.detectChangesRenderPropertiesMethod.resetDebugInfo(n.nodeIndex,t);var c,p=r(u),f=i(u),d=f,m=[];switch(t.type){case v.PropertyBindingType.Property:c="setElementProperty",s.genConfig.logBindingUpdate&&m.push(l(a,t.name,f));break;case v.PropertyBindingType.Attribute:c="setElementAttribute",d=d.isBlank().conditional(h.NULL_EXPR,d.callMethod("toString",[]));break;case v.PropertyBindingType.Class:c="setElementClass";break;case v.PropertyBindingType.Style:c="setElementStyle";var g=d.callMethod("toString",[]);y.isPresent(t.unit)&&(g=g.plus(h.literal(t.unit))),d=d.isBlank().conditional(h.NULL_EXPR,g)}m.push(h.THIS_EXPR.prop("renderer").callMethod(c,[a,h.literal(t.name),d]).toStmt()),o(s,f,p,t.value,e,m,s.detectChangesRenderPropertiesMethod)})}function u(t,e){a(t,h.THIS_EXPR.prop("context"),e)}function c(t,e,n){a(t.hostProperties,e,n)}function p(t,e,n){if(0!==t.inputs.length){var s=n.view,a=s.detectChangesInInputsMethod;a.resetDebugInfo(n.nodeIndex,n.sourceAst);var u=t.directive.lifecycleHooks,c=-1!==u.indexOf(m.LifecycleHooks.OnChanges),p=t.directive.isComponent&&!g.isDefaultChangeDetectionStrategy(t.directive.changeDetection);c&&a.addStmt(d.DetectChangesVars.changes.set(h.NULL_EXPR).toStmt()),p&&a.addStmt(d.DetectChangesVars.changed.set(h.literal(!1)).toStmt()),t.inputs.forEach(function(t){var u=s.bindings.length;s.bindings.push(new P.CompileBinding(n,t)),a.resetDebugInfo(n.nodeIndex,t);var v=r(u),y=i(u),m=[e.prop(t.directiveName).set(y).toStmt()];c&&(m.push(new h.IfStmt(d.DetectChangesVars.changes.identical(h.NULL_EXPR),[d.DetectChangesVars.changes.set(h.literalMap([],new h.MapType(h.importType(f.Identifiers.SimpleChange)))).toStmt()])),m.push(d.DetectChangesVars.changes.key(h.literal(t.directiveName)).set(h.importExpr(f.Identifiers.SimpleChange).instantiate([v,y])).toStmt())),p&&m.push(d.DetectChangesVars.changed.set(h.literal(!0)).toStmt()),s.genConfig.logBindingUpdate&&m.push(l(n.renderNode,t.directiveName,y)),o(s,y,v,t.value,h.THIS_EXPR.prop("context"),m,a)}),p&&a.addStmt(new h.IfStmt(d.DetectChangesVars.changed,[n.appElement.prop("componentView").callMethod("markAsCheckOnce",[]).toStmt()]))}}function l(t,e,n){return h.THIS_EXPR.prop("renderer").callMethod("setBindingDebugInfo",[t,h.literal("ng-reflect-"+_.camelCaseToDashCase(e)),n.isBlank().conditional(h.NULL_EXPR,n.callMethod("toString",[]))]).toStmt()}var h=n(164),f=n(158),d=n(170),v=n(139),y=n(5),m=n(156),g=n(33),_=n(153),b=n(179),P=n(180);e.bindRenderText=s,e.bindRenderInputs=u,e.bindDirectiveHostProps=c,e.bindDirectiveInputs=p},function(t,e,n){"use strict";function r(t,e,n,r){var i=new y(t,e,r),o=n.visit(i,v.Expression);return new d(o,i.needsValueUnwrapper)}function i(t,e,n){var r=new y(t,e,null),i=[];return u(n.visit(r,v.Statement),i),i}function o(t,e){if(t!==v.Statement)throw new l.BaseException("Expected a statement, but saw "+e)}function s(t,e){if(t!==v.Expression)throw new l.BaseException("Expected an expression, but saw "+e)}function a(t,e){return t===v.Statement?e.toStmt():e}function u(t,e){h.isArray(t)?t.forEach(function(t){return u(t,e)}):e.push(t)}var c=n(164),p=n(158),l=n(12),h=n(5),f=c.variable("#implicit"),d=function(){function t(t,e){this.expression=t,this.needsValueUnwrapper=e}return t}();e.ExpressionWithWrappedValueInfo=d,e.convertCdExpressionToIr=r,e.convertCdStatementToIr=i;var v;!function(t){t[t.Statement=0]="Statement",t[t.Expression=1]="Expression"}(v||(v={}));var y=function(){function t(t,e,n){this._nameResolver=t,this._implicitReceiver=e,this._valueUnwrapper=n,this.needsValueUnwrapper=!1}return t.prototype.visitBinary=function(t,e){var n;switch(t.operation){case"+":n=c.BinaryOperator.Plus;break;case"-":n=c.BinaryOperator.Minus;break;case"*":n=c.BinaryOperator.Multiply;break;case"/":n=c.BinaryOperator.Divide;break;case"%":n=c.BinaryOperator.Modulo;break;case"&&":n=c.BinaryOperator.And;break;case"||":n=c.BinaryOperator.Or;break;case"==":n=c.BinaryOperator.Equals;break;case"!=":n=c.BinaryOperator.NotEquals;break;case"===":n=c.BinaryOperator.Identical;break;case"!==":n=c.BinaryOperator.NotIdentical;break;case"<":n=c.BinaryOperator.Lower;break;case">":n=c.BinaryOperator.Bigger;break;case"<=":n=c.BinaryOperator.LowerEquals;break;case">=":n=c.BinaryOperator.BiggerEquals;break;default:throw new l.BaseException("Unsupported operation "+t.operation)}return a(e,new c.BinaryOperatorExpr(n,t.left.visit(this,v.Expression),t.right.visit(this,v.Expression)))},t.prototype.visitChain=function(t,e){return o(e,t),this.visitAll(t.expressions,e)},t.prototype.visitConditional=function(t,e){var n=t.condition.visit(this,v.Expression);return a(e,n.conditional(t.trueExp.visit(this,v.Expression),t.falseExp.visit(this,v.Expression)))},t.prototype.visitPipe=function(t,e){var n=t.exp.visit(this,v.Expression),r=this.visitAll(t.args,v.Expression),i=this._nameResolver.callPipe(t.name,n,r);return this.needsValueUnwrapper=!0,a(e,this._valueUnwrapper.callMethod("unwrap",[i]))},t.prototype.visitFunctionCall=function(t,e){return a(e,t.target.visit(this,v.Expression).callFn(this.visitAll(t.args,v.Expression)))},t.prototype.visitImplicitReceiver=function(t,e){return s(e,t),f},t.prototype.visitInterpolation=function(t,e){s(e,t);for(var n=[c.literal(t.expressions.length)],r=0;r=0){var a=i[o],c=s(a),p=l.variable("pd_"+this._actionResultExprs.length);this._actionResultExprs.push(p),u.isPresent(c)&&(i[o]=p.set(c.cast(l.DYNAMIC_TYPE).notIdentical(l.literal(!1))).toDeclStmt(null,[l.StmtModifier.Final]))}this._method.addStmts(i)},t.prototype.finishMethod=function(){var t=this._hasComponentHostListener?this.compileElement.appElement.prop("componentView"):l.THIS_EXPR,e=l.literal(!0);this._actionResultExprs.forEach(function(t){e=e.and(t)});var n=[t.callMethod("markPathToRootAsCheckOnce",[]).toStmt()].concat(this._method.finish()).concat([new l.ReturnStatement(e)]);this.compileElement.view.eventHandlerMethods.push(new l.ClassMethod(this._methodName,[this._eventParam],n,l.BOOL_TYPE,[l.StmtModifier.Private]))},t.prototype.listenToRenderer=function(){var t,e=l.THIS_EXPR.callMethod("eventHandler",[l.fn([this._eventParam],[new l.ReturnStatement(l.THIS_EXPR.callMethod(this._methodName,[p.EventHandlerVars.event]))])]);t=u.isPresent(this.eventTarget)?p.ViewProperties.renderer.callMethod("listenGlobal",[l.literal(this.eventTarget),l.literal(this.eventName),e]):p.ViewProperties.renderer.callMethod("listen",[this.compileElement.renderNode,l.literal(this.eventName),e]);var n=l.variable("disposable_"+this.compileElement.view.disposables.length);this.compileElement.view.disposables.push(n),this.compileElement.view.createMethod.addStmt(n.set(t).toDeclStmt(l.FUNCTION_TYPE,[l.StmtModifier.Private]))},t.prototype.listenToDirective=function(t,e){var n=l.variable("subscription_"+this.compileElement.view.subscriptions.length);this.compileElement.view.subscriptions.push(n);var r=l.THIS_EXPR.callMethod("eventHandler",[l.fn([this._eventParam],[l.THIS_EXPR.callMethod(this._methodName,[p.EventHandlerVars.event]).toStmt()])]);this.compileElement.view.createMethod.addStmt(n.set(t.prop(e).callMethod(l.BuiltinMethod.SubscribeObservable,[r])).toDeclStmt(null,[l.StmtModifier.Final]))},t}();e.CompileEventListener=v,e.collectEventListeners=r,e.bindDirectiveOutputs=i,e.bindRenderOutputs=o},function(t,e,n){"use strict";function r(t,e,n){var r=n.view,i=r.detectChangesInInputsMethod,o=t.directive.lifecycleHooks;-1!==o.indexOf(p.LifecycleHooks.OnChanges)&&t.inputs.length>0&&i.addStmt(new u.IfStmt(c.DetectChangesVars.changes.notIdentical(u.NULL_EXPR),[e.callMethod("ngOnChanges",[c.DetectChangesVars.changes]).toStmt()])),-1!==o.indexOf(p.LifecycleHooks.OnInit)&&i.addStmt(new u.IfStmt(l.and(h),[e.callMethod("ngOnInit",[]).toStmt()])),-1!==o.indexOf(p.LifecycleHooks.DoCheck)&&i.addStmt(new u.IfStmt(h,[e.callMethod("ngDoCheck",[]).toStmt()]))}function i(t,e,n){var r=n.view,i=t.lifecycleHooks,o=r.afterContentLifecycleCallbacksMethod;o.resetDebugInfo(n.nodeIndex,n.sourceAst),-1!==i.indexOf(p.LifecycleHooks.AfterContentInit)&&o.addStmt(new u.IfStmt(l,[e.callMethod("ngAfterContentInit",[]).toStmt()])),-1!==i.indexOf(p.LifecycleHooks.AfterContentChecked)&&o.addStmt(e.callMethod("ngAfterContentChecked",[]).toStmt())}function o(t,e,n){var r=n.view,i=t.lifecycleHooks,o=r.afterViewLifecycleCallbacksMethod;o.resetDebugInfo(n.nodeIndex,n.sourceAst),-1!==i.indexOf(p.LifecycleHooks.AfterViewInit)&&o.addStmt(new u.IfStmt(l,[e.callMethod("ngAfterViewInit",[]).toStmt()])),-1!==i.indexOf(p.LifecycleHooks.AfterViewChecked)&&o.addStmt(e.callMethod("ngAfterViewChecked",[]).toStmt())}function s(t,e,n){var r=n.view.destroyMethod;r.resetDebugInfo(n.nodeIndex,n.sourceAst),-1!==t.lifecycleHooks.indexOf(p.LifecycleHooks.OnDestroy)&&r.addStmt(e.callMethod("ngOnDestroy",[]).toStmt())}function a(t,e,n){var r=n.destroyMethod;-1!==t.lifecycleHooks.indexOf(p.LifecycleHooks.OnDestroy)&&r.addStmt(e.callMethod("ngOnDestroy",[]).toStmt())}var u=n(164),c=n(170),p=n(156),l=u.THIS_EXPR.prop("cdState").identical(c.ChangeDetectorStateEnum.NeverChecked),h=u.not(c.DetectChangesVars.throwOnChange);e.bindDirectiveDetectChangesLifecycleCallbacks=r,e.bindDirectiveAfterContentLifecycleCallbacks=i,e.bindDirectiveAfterViewLifecycleCallbacks=o,e.bindDirectiveDestroyLifecycleCallbacks=s,e.bindPipeDestroyLifecycleCallbacks=a},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(155),s=n(5),a=n(12),u=n(40),c=n(184),p=n(157),l=n(152),h=n(6),f=n(36),d=n(145),v=n(144),y=n(151),m=function(){function t(t,e,n){this._xhr=t,this._urlResolver=e,this._htmlParser=n}return t.prototype.normalizeDirective=function(t){return t.isComponent?this.normalizeTemplate(t.type,t.template).then(function(e){return new o.CompileDirectiveMetadata({type:t.type,isComponent:t.isComponent,selector:t.selector,exportAs:t.exportAs,changeDetection:t.changeDetection,inputs:t.inputs,outputs:t.outputs,hostListeners:t.hostListeners,hostProperties:t.hostProperties,hostAttributes:t.hostAttributes,lifecycleHooks:t.lifecycleHooks,providers:t.providers,viewProviders:t.viewProviders,queries:t.queries,viewQueries:t.viewQueries,template:e})}):u.PromiseWrapper.resolve(t)},t.prototype.normalizeTemplate=function(t,e){var n=this;if(s.isPresent(e.template))return u.PromiseWrapper.resolve(this.normalizeLoadedTemplate(t,e,e.template,t.moduleUrl));if(s.isPresent(e.templateUrl)){var r=this._urlResolver.resolve(t.moduleUrl,e.templateUrl);return this._xhr.get(r).then(function(i){return n.normalizeLoadedTemplate(t,e,i,r)})}throw new a.BaseException("No template specified for component "+t.name)},t.prototype.normalizeLoadedTemplate=function(t,e,n,r){var i=this,s=this._htmlParser.parse(n,t.name);if(s.errors.length>0){var u=s.errors.join("\n");throw new a.BaseException("Template parse errors:\n"+u)}var c=new g;d.htmlVisitAll(c,s.rootNodes);var p=e.styles.concat(c.styles),h=c.styleUrls.filter(l.isStyleUrlResolvable).map(function(t){return i._urlResolver.resolve(r,t)}).concat(e.styleUrls.filter(l.isStyleUrlResolvable).map(function(e){return i._urlResolver.resolve(t.moduleUrl,e)})),v=p.map(function(t){var e=l.extractStyleUrls(i._urlResolver,r,t);return e.styleUrls.forEach(function(t){return h.push(t)}),e.style}),y=e.encapsulation;return y===f.ViewEncapsulation.Emulated&&0===v.length&&0===h.length&&(y=f.ViewEncapsulation.None),new o.CompileTemplateMetadata({encapsulation:y,template:n,templateUrl:r,styles:v,styleUrls:h,ngContentSelectors:c.ngContentSelectors})},t=r([h.Injectable(),i("design:paramtypes",[c.XHR,p.UrlResolver,v.HtmlParser])],t)}();e.DirectiveNormalizer=m;var g=function(){function t(){this.ngContentSelectors=[],this.styles=[],this.styleUrls=[],this.ngNonBindableStackCount=0}return t.prototype.visitElement=function(t,e){var n=y.preparseElement(t);switch(n.type){case y.PreparsedElementType.NG_CONTENT:0===this.ngNonBindableStackCount&&this.ngContentSelectors.push(n.selectAttr);break;case y.PreparsedElementType.STYLE:var r="";t.children.forEach(function(t){t instanceof d.HtmlTextAst&&(r+=t.value)}),this.styles.push(r);break;case y.PreparsedElementType.STYLESHEET:this.styleUrls.push(n.hrefAttr)}return n.nonBindable&&this.ngNonBindableStackCount++,d.htmlVisitAll(this,t.children),n.nonBindable&&this.ngNonBindableStackCount--,null},t.prototype.visitComment=function(t,e){return null},t.prototype.visitAttr=function(t,e){return null},t.prototype.visitText=function(t,e){return null},t.prototype.visitExpansion=function(t,e){return null},t.prototype.visitExpansionCase=function(t,e){return null},t}()},function(t,e){"use strict";var n=function(){function t(){}return t.prototype.get=function(t){return null},t}();e.XHR=n},function(t,e,n){"use strict";function r(t,e){var n=[];return h.isPresent(e)&&o(e,n),h.isPresent(t.directives)&&o(t.directives,n),n}function i(t,e){var n=[];return h.isPresent(e)&&o(e,n),h.isPresent(t.pipes)&&o(t.pipes,n),n}function o(t,e){for(var n=0;n0?r:"package:"+r+O.MODULE_SUFFIX}return t.importUri(e)}var u=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},c=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},p=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},l=n(6),h=n(5),f=n(15),d=n(12),v=n(23),y=n(155),m=n(26),g=n(4),_=n(186),b=n(187),P=n(188),E=n(189),w=n(156),C=n(18),R=n(6),S=n(84),O=n(153),T=n(190),x=n(157),A=n(24),I=n(17),M=n(7),k=n(4),N=n(20),D=function(){function t(t,e,n,r,i,o){this._directiveResolver=t,this._pipeResolver=e,this._viewResolver=n,this._platformDirectives=r,this._platformPipes=i,this._directiveCache=new Map,this._pipeCache=new Map,this._anonymousTypes=new Map,this._anonymousTypeIndex=0,h.isPresent(o)?this._reflector=o:this._reflector=C.reflector}return t.prototype.sanitizeTokenName=function(t){var e=h.stringify(t);if(e.indexOf("(")>=0){var n=this._anonymousTypes.get(t);h.isBlank(n)&&(this._anonymousTypes.set(t,this._anonymousTypeIndex++),n=this._anonymousTypes.get(t)),e="anonymous_token_"+n+"_"}return O.sanitizeIdentifier(e)},t.prototype.getDirectiveMetadata=function(t){var e=this._directiveCache.get(t);if(h.isBlank(e)){var n=this._directiveResolver.resolve(t),r=null,i=null,o=null,s=[];if(n instanceof m.ComponentMetadata){T.assertArrayOfStrings("styles",n.styles);var u=n;r=a(this._reflector,t,u);var c=this._viewResolver.resolve(t);T.assertArrayOfStrings("styles",c.styles),i=new y.CompileTemplateMetadata({encapsulation:c.encapsulation,template:c.template,templateUrl:c.templateUrl,styles:c.styles,styleUrls:c.styleUrls}),o=u.changeDetection,h.isPresent(n.viewProviders)&&(s=this.getProvidersMetadata(n.viewProviders))}var p=[];h.isPresent(n.providers)&&(p=this.getProvidersMetadata(n.providers));var l=[],f=[];h.isPresent(n.queries)&&(l=this.getQueriesMetadata(n.queries,!1), -f=this.getQueriesMetadata(n.queries,!0)),e=y.CompileDirectiveMetadata.create({selector:n.selector,exportAs:n.exportAs,isComponent:h.isPresent(i),type:this.getTypeMetadata(t,r),template:i,changeDetection:o,inputs:n.inputs,outputs:n.outputs,host:n.host,lifecycleHooks:w.LIFECYCLE_HOOKS_VALUES.filter(function(e){return E.hasLifecycleHook(e,t)}),providers:p,viewProviders:s,queries:l,viewQueries:f}),this._directiveCache.set(t,e)}return e},t.prototype.getTypeMetadata=function(t,e){return new y.CompileTypeMetadata({name:this.sanitizeTokenName(t),moduleUrl:e,runtime:t,diDeps:this.getDependenciesMetadata(t,null)})},t.prototype.getFactoryMetadata=function(t,e){return new y.CompileFactoryMetadata({name:this.sanitizeTokenName(t),moduleUrl:e,runtime:t,diDeps:this.getDependenciesMetadata(t,null)})},t.prototype.getPipeMetadata=function(t){var e=this._pipeCache.get(t);if(h.isBlank(e)){var n=this._pipeResolver.resolve(t),r=this._reflector.importUri(t);e=new y.CompilePipeMetadata({type:this.getTypeMetadata(t,r),name:n.name,pure:n.pure,lifecycleHooks:w.LIFECYCLE_HOOKS_VALUES.filter(function(e){return E.hasLifecycleHook(e,t)})}),this._pipeCache.set(t,e)}return e},t.prototype.getViewDirectivesMetadata=function(t){for(var e=this,n=this._viewResolver.resolve(t),i=r(n,this._platformDirectives),o=0;oo?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(6),a=n(5),u=n(12),c=n(15),p=n(3),l=n(18),h=n(20),f=function(){function t(t){a.isPresent(t)?this._reflector=t:this._reflector=l.reflector}return t.prototype.resolve=function(t){var e=this._reflector.annotations(s.resolveForwardRef(t));if(a.isPresent(e)){var n=e.find(r);if(a.isPresent(n)){var i=this._reflector.propMetadata(t);return this._mergeWithPropertyMetadata(n,i,t)}}throw new u.BaseException("No Directive annotation found on "+a.stringify(t))},t.prototype._mergeWithPropertyMetadata=function(t,e,n){var r=[],i=[],o={},s={};return c.StringMapWrapper.forEach(e,function(t,e){t.forEach(function(t){if(t instanceof p.InputMetadata&&(a.isPresent(t.bindingPropertyName)?r.push(e+": "+t.bindingPropertyName):r.push(e)),t instanceof p.OutputMetadata&&(a.isPresent(t.bindingPropertyName)?i.push(e+": "+t.bindingPropertyName):i.push(e)),t instanceof p.HostBindingMetadata&&(a.isPresent(t.hostPropertyName)?o["["+t.hostPropertyName+"]"]=e:o["["+e+"]"]=e),t instanceof p.HostListenerMetadata){var n=a.isPresent(t.args)?t.args.join(", "):"";o["("+t.eventName+")"]=e+"("+n+")"}t instanceof p.ContentChildrenMetadata&&(s[e]=t),t instanceof p.ViewChildrenMetadata&&(s[e]=t),t instanceof p.ContentChildMetadata&&(s[e]=t),t instanceof p.ViewChildMetadata&&(s[e]=t)})}),this._merge(t,r,i,o,s,n)},t.prototype._merge=function(t,e,n,r,i,o){var s,l=a.isPresent(t.inputs)?c.ListWrapper.concat(t.inputs,e):e;a.isPresent(t.outputs)?(t.outputs.forEach(function(t){if(c.ListWrapper.contains(n,t))throw new u.BaseException("Output event '"+t+"' defined multiple times in '"+a.stringify(o)+"'")}),s=c.ListWrapper.concat(t.outputs,n)):s=n;var h=a.isPresent(t.host)?c.StringMapWrapper.merge(t.host,r):r,f=a.isPresent(t.queries)?c.StringMapWrapper.merge(t.queries,i):i;return t instanceof p.ComponentMetadata?new p.ComponentMetadata({selector:t.selector,inputs:l,outputs:s,host:h,exportAs:t.exportAs,moduleId:t.moduleId,queries:f,changeDetection:t.changeDetection,providers:t.providers,viewProviders:t.viewProviders}):new p.DirectiveMetadata({selector:t.selector,inputs:l,outputs:s,host:h,exportAs:t.exportAs,queries:f,providers:t.providers})},t=i([s.Injectable(),o("design:paramtypes",[h.ReflectorReader])],t)}();e.DirectiveResolver=f,e.CODEGEN_DIRECTIVE_RESOLVER=new f(l.reflector)},function(t,e,n){"use strict";function r(t){return t instanceof c.PipeMetadata}var i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(6),a=n(5),u=n(12),c=n(3),p=n(20),l=n(18),h=function(){function t(t){a.isPresent(t)?this._reflector=t:this._reflector=l.reflector}return t.prototype.resolve=function(t){var e=this._reflector.annotations(s.resolveForwardRef(t));if(a.isPresent(e)){var n=e.find(r);if(a.isPresent(n))return n}throw new u.BaseException("No Pipe decorator found on "+a.stringify(t))},t=i([s.Injectable(),o("design:paramtypes",[p.ReflectorReader])],t)}();e.PipeResolver=h,e.CODEGEN_PIPE_RESOLVER=new h(l.reflector)},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(6),s=n(36),a=n(26),u=n(5),c=n(12),p=n(15),l=n(20),h=n(18),f=function(){function t(t){this._cache=new p.Map,u.isPresent(t)?this._reflector=t:this._reflector=h.reflector}return t.prototype.resolve=function(t){var e=this._cache.get(t);return u.isBlank(e)&&(e=this._resolve(t),this._cache.set(t,e)),e},t.prototype._resolve=function(t){var e,n;if(this._reflector.annotations(t).forEach(function(t){t instanceof s.ViewMetadata&&(n=t),t instanceof a.ComponentMetadata&&(e=t)}),!u.isPresent(e)){if(u.isBlank(n))throw new c.BaseException("Could not compile '"+u.stringify(t)+"' because it is not a component.");return n}if(u.isBlank(e.template)&&u.isBlank(e.templateUrl)&&u.isBlank(n))throw new c.BaseException("Component '"+u.stringify(t)+"' must have either 'template' or 'templateUrl' set.");if(u.isPresent(e.template)&&u.isPresent(n))this._throwMixingViewAndComponent("template",t);else if(u.isPresent(e.templateUrl)&&u.isPresent(n))this._throwMixingViewAndComponent("templateUrl",t);else if(u.isPresent(e.directives)&&u.isPresent(n))this._throwMixingViewAndComponent("directives",t);else if(u.isPresent(e.pipes)&&u.isPresent(n))this._throwMixingViewAndComponent("pipes",t);else if(u.isPresent(e.encapsulation)&&u.isPresent(n))this._throwMixingViewAndComponent("encapsulation",t);else if(u.isPresent(e.styles)&&u.isPresent(n))this._throwMixingViewAndComponent("styles",t);else{if(!u.isPresent(e.styleUrls)||!u.isPresent(n))return u.isPresent(n)?n:new s.ViewMetadata({templateUrl:e.templateUrl,template:e.template,directives:e.directives,pipes:e.pipes,encapsulation:e.encapsulation,styles:e.styles,styleUrls:e.styleUrls});this._throwMixingViewAndComponent("styleUrls",t)}return null},t.prototype._throwMixingViewAndComponent=function(t,e){throw new c.BaseException("Component '"+u.stringify(e)+"' cannot have both '"+t+"' and '@View' set at the same time\"")},t=r([o.Injectable(),i("design:paramtypes",[l.ReflectorReader])],t)}();e.ViewResolver=f},function(t,e,n){"use strict";function r(t,e){if(!(e instanceof i.Type))return!1;var n=e.prototype;switch(t){case o.LifecycleHooks.AfterContentInit:return!!n.ngAfterContentInit;case o.LifecycleHooks.AfterContentChecked:return!!n.ngAfterContentChecked;case o.LifecycleHooks.AfterViewInit:return!!n.ngAfterViewInit;case o.LifecycleHooks.AfterViewChecked:return!!n.ngAfterViewChecked;case o.LifecycleHooks.OnChanges:return!!n.ngOnChanges;case o.LifecycleHooks.DoCheck:return!!n.ngDoCheck;case o.LifecycleHooks.OnDestroy:return!!n.ngOnDestroy;case o.LifecycleHooks.OnInit:return!!n.ngOnInit;default:return!1}}var i=n(5),o=n(156);e.hasLifecycleHook=r},function(t,e,n){"use strict";function r(t,e){if(i.assertionsEnabled()&&!i.isBlank(e)){if(!i.isArray(e))throw new o.BaseException("Expected '"+t+"' to be an array of strings.");for(var n=0;nn;n++)e+=" ";return e}var o=n(5),s=n(12),a=n(164),u=/'|\\|\n|\r|\$/g;e.CATCH_ERROR_VAR=a.variable("error"),e.CATCH_STACK_VAR=a.variable("stack");var c=function(){function t(){}return t}();e.OutputEmitter=c;var p=function(){function t(t){this.indent=t,this.parts=[]}return t}(),l=function(){function t(t,e){this._exportedVars=t,this._indent=e,this._classes=[],this._lines=[new p(e)]}return t.createRoot=function(e){return new t(e,0)},Object.defineProperty(t.prototype,"_currentLine",{get:function(){return this._lines[this._lines.length-1]},enumerable:!0,configurable:!0}),t.prototype.isExportedVar=function(t){return-1!==this._exportedVars.indexOf(t)},t.prototype.println=function(t){void 0===t&&(t=""),this.print(t,!0)},t.prototype.lineIsEmpty=function(){return 0===this._currentLine.parts.length},t.prototype.print=function(t,e){void 0===e&&(e=!1),t.length>0&&this._currentLine.parts.push(t),e&&this._lines.push(new p(this._indent))},t.prototype.removeEmptyLastLine=function(){this.lineIsEmpty()&&this._lines.pop()},t.prototype.incIndent=function(){this._indent++,this._currentLine.indent=this._indent},t.prototype.decIndent=function(){this._indent--,this._currentLine.indent=this._indent},t.prototype.pushClass=function(t){this._classes.push(t)},t.prototype.popClass=function(){return this._classes.pop()},Object.defineProperty(t.prototype,"currentClass",{get:function(){return this._classes.length>0?this._classes[this._classes.length-1]:null},enumerable:!0,configurable:!0}),t.prototype.toSource=function(){var t=this._lines;return 0===t[t.length-1].parts.length&&(t=t.slice(0,t.length-1)),t.map(function(t){return t.parts.length>0?i(t.indent)+t.parts.join(""):""}).join("\n")},t}();e.EmitterVisitorContext=l;var h=function(){function t(t){this._escapeDollarInStrings=t}return t.prototype.visitExpressionStmt=function(t,e){return t.expr.visitExpression(this,e),e.println(";"),null},t.prototype.visitReturnStmt=function(t,e){return e.print("return "),t.value.visitExpression(this,e),e.println(";"),null},t.prototype.visitIfStmt=function(t,e){e.print("if ("),t.condition.visitExpression(this,e),e.print(") {");var n=o.isPresent(t.falseCase)&&t.falseCase.length>0;return t.trueCase.length<=1&&!n?(e.print(" "),this.visitAllStatements(t.trueCase,e),e.removeEmptyLastLine(),e.print(" ")):(e.println(),e.incIndent(),this.visitAllStatements(t.trueCase,e),e.decIndent(),n&&(e.println("} else {"),e.incIndent(),this.visitAllStatements(t.falseCase,e),e.decIndent())),e.println("}"),null},t.prototype.visitThrowStmt=function(t,e){return e.print("throw "),t.error.visitExpression(this,e),e.println(";"),null},t.prototype.visitCommentStmt=function(t,e){var n=t.comment.split("\n");return n.forEach(function(t){e.println("// "+t)}),null},t.prototype.visitWriteVarExpr=function(t,e){var n=e.lineIsEmpty();return n||e.print("("),e.print(t.name+" = "),t.value.visitExpression(this,e),n||e.print(")"),null},t.prototype.visitWriteKeyExpr=function(t,e){var n=e.lineIsEmpty();return n||e.print("("),t.receiver.visitExpression(this,e),e.print("["),t.index.visitExpression(this,e),e.print("] = "),t.value.visitExpression(this,e),n||e.print(")"),null},t.prototype.visitWritePropExpr=function(t,e){var n=e.lineIsEmpty();return n||e.print("("),t.receiver.visitExpression(this,e),e.print("."+t.name+" = "),t.value.visitExpression(this,e),n||e.print(")"),null},t.prototype.visitInvokeMethodExpr=function(t,e){t.receiver.visitExpression(this,e);var n=t.name;return o.isPresent(t.builtin)&&(n=this.getBuiltinMethodName(t.builtin),o.isBlank(n))?null:(e.print("."+n+"("),this.visitAllExpressions(t.args,e,","),e.print(")"),null)},t.prototype.visitInvokeFunctionExpr=function(t,e){return t.fn.visitExpression(this,e),e.print("("),this.visitAllExpressions(t.args,e,","),e.print(")"),null},t.prototype.visitReadVarExpr=function(t,n){var r=t.name;if(o.isPresent(t.builtin))switch(t.builtin){case a.BuiltinVar.Super:r="super";break;case a.BuiltinVar.This:r="this";break;case a.BuiltinVar.CatchError:r=e.CATCH_ERROR_VAR.name;break;case a.BuiltinVar.CatchStack:r=e.CATCH_STACK_VAR.name;break;default:throw new s.BaseException("Unknown builtin variable "+t.builtin)}return n.print(r),null},t.prototype.visitInstantiateExpr=function(t,e){return e.print("new "),t.classExpr.visitExpression(this,e),e.print("("),this.visitAllExpressions(t.args,e,","),e.print(")"),null},t.prototype.visitLiteralExpr=function(t,e){var n=t.value;return o.isString(n)?e.print(r(n,this._escapeDollarInStrings)):o.isBlank(n)?e.print("null"):e.print(""+n),null},t.prototype.visitConditionalExpr=function(t,e){return t.condition.visitExpression(this,e),e.print("? "),t.trueCase.visitExpression(this,e),e.print(": "),t.falseCase.visitExpression(this,e),null},t.prototype.visitNotExpr=function(t,e){return e.print("!"),t.condition.visitExpression(this,e),null},t.prototype.visitBinaryOperatorExpr=function(t,e){var n;switch(t.operator){case a.BinaryOperator.Equals:n="==";break;case a.BinaryOperator.Identical:n="===";break;case a.BinaryOperator.NotEquals:n="!=";break;case a.BinaryOperator.NotIdentical:n="!==";break;case a.BinaryOperator.And:n="&&";break;case a.BinaryOperator.Or:n="||";break;case a.BinaryOperator.Plus:n="+";break;case a.BinaryOperator.Minus:n="-";break;case a.BinaryOperator.Divide:n="/";break;case a.BinaryOperator.Multiply:n="*";break;case a.BinaryOperator.Modulo:n="%";break;case a.BinaryOperator.Lower:n="<";break;case a.BinaryOperator.LowerEquals:n="<=";break;case a.BinaryOperator.Bigger:n=">";break;case a.BinaryOperator.BiggerEquals:n=">=";break;default:throw new s.BaseException("Unknown operator "+t.operator)}return e.print("("),t.lhs.visitExpression(this,e),e.print(" "+n+" "),t.rhs.visitExpression(this,e),e.print(")"),null},t.prototype.visitReadPropExpr=function(t,e){return t.receiver.visitExpression(this,e),e.print("."),e.print(t.name),null},t.prototype.visitReadKeyExpr=function(t,e){return t.receiver.visitExpression(this,e),e.print("["),t.index.visitExpression(this,e),e.print("]"),null},t.prototype.visitLiteralArrayExpr=function(t,e){var n=t.entries.length>1;return e.print("[",n),e.incIndent(),this.visitAllExpressions(t.entries,e,",",n),e.decIndent(),e.print("]",n),null},t.prototype.visitLiteralMapExpr=function(t,e){var n=this,i=t.entries.length>1;return e.print("{",i),e.incIndent(),this.visitAllObjects(function(t){e.print(r(t[0],n._escapeDollarInStrings)+": "),t[1].visitExpression(n,e)},t.entries,e,",",i),e.decIndent(),e.print("}",i),null},t.prototype.visitAllExpressions=function(t,e,n,r){var i=this;void 0===r&&(r=!1),this.visitAllObjects(function(t){return t.visitExpression(i,e)},t,e,n,r)},t.prototype.visitAllObjects=function(t,e,n,r,i){void 0===i&&(i=!1);for(var o=0;o0&&n.print(r,i),t(e[o]);i&&n.println()},t.prototype.visitAllStatements=function(t,e){var n=this;t.forEach(function(t){return t.visitStatement(n,e)})},t}();e.AbstractEmitterVisitor=h,e.escapeSingleQuoteString=r},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(12),s=n(164),a=n(192),u=function(t){function e(){t.call(this,!1)}return r(e,t),e.prototype.visitDeclareClassStmt=function(t,e){var n=this;return e.pushClass(t),this._visitClassConstructor(t,e),i.isPresent(t.parent)&&(e.print(t.name+".prototype = Object.create("),t.parent.visitExpression(this,e),e.println(".prototype);")),t.getters.forEach(function(r){return n._visitClassGetter(t,r,e)}),t.methods.forEach(function(r){return n._visitClassMethod(t,r,e)}),e.popClass(),null},e.prototype._visitClassConstructor=function(t,e){e.print("function "+t.name+"("),i.isPresent(t.constructorMethod)&&this._visitParams(t.constructorMethod.params,e),e.println(") {"),e.incIndent(),i.isPresent(t.constructorMethod)&&t.constructorMethod.body.length>0&&(e.println("var self = this;"),this.visitAllStatements(t.constructorMethod.body,e)),e.decIndent(),e.println("}")},e.prototype._visitClassGetter=function(t,e,n){n.println("Object.defineProperty("+t.name+".prototype, '"+e.name+"', { get: function() {"),n.incIndent(),e.body.length>0&&(n.println("var self = this;"),this.visitAllStatements(e.body,n)),n.decIndent(),n.println("}});")},e.prototype._visitClassMethod=function(t,e,n){n.print(t.name+".prototype."+e.name+" = function("),this._visitParams(e.params,n),n.println(") {"),n.incIndent(),e.body.length>0&&(n.println("var self = this;"),this.visitAllStatements(e.body,n)),n.decIndent(),n.println("};")},e.prototype.visitReadVarExpr=function(e,n){if(e.builtin===s.BuiltinVar.This)n.print("self");else{if(e.builtin===s.BuiltinVar.Super)throw new o.BaseException("'super' needs to be handled at a parent ast node, not at the variable level!");t.prototype.visitReadVarExpr.call(this,e,n)}return null},e.prototype.visitDeclareVarStmt=function(t,e){return e.print("var "+t.name+" = "),t.value.visitExpression(this,e),e.println(";"),null},e.prototype.visitCastExpr=function(t,e){return t.value.visitExpression(this,e),null},e.prototype.visitInvokeFunctionExpr=function(e,n){var r=e.fn;return r instanceof s.ReadVarExpr&&r.builtin===s.BuiltinVar.Super?(n.currentClass.parent.visitExpression(this,n),n.print(".call(this"),e.args.length>0&&(n.print(", "),this.visitAllExpressions(e.args,n,",")),n.print(")")):t.prototype.visitInvokeFunctionExpr.call(this,e,n),null},e.prototype.visitFunctionExpr=function(t,e){return e.print("function("),this._visitParams(t.params,e),e.println(") {"),e.incIndent(),this.visitAllStatements(t.statements,e),e.decIndent(),e.print("}"),null},e.prototype.visitDeclareFunctionStmt=function(t,e){return e.print("function "+t.name+"("),this._visitParams(t.params,e),e.println(") {"),e.incIndent(),this.visitAllStatements(t.statements,e),e.decIndent(),e.println("}"),null},e.prototype.visitTryCatchStmt=function(t,e){e.println("try {"),e.incIndent(),this.visitAllStatements(t.bodyStmts,e),e.decIndent(),e.println("} catch ("+a.CATCH_ERROR_VAR.name+") {"),e.incIndent();var n=[a.CATCH_STACK_VAR.set(a.CATCH_ERROR_VAR.prop("stack")).toDeclStmt(null,[s.StmtModifier.Final])].concat(t.catchStmts);return this.visitAllStatements(n,e),e.decIndent(),e.println("}"),null},e.prototype._visitParams=function(t,e){this.visitAllObjects(function(t){return e.print(t.name)},t,e,",")},e.prototype.getBuiltinMethodName=function(t){var e;switch(t){case s.BuiltinMethod.ConcatArray:e="concat";break;case s.BuiltinMethod.SubscribeObservable:e="subscribe";break;case s.BuiltinMethod.bind:e="bind";break;default:throw new o.BaseException("Unknown builtin method: "+t)}return e},e}(a.AbstractEmitterVisitor);e.AbstractJsEmitterVisitor=u},function(t,e,n){"use strict";function r(t,e,n){var r=t.concat([new c.ReturnStatement(c.variable(e))]),i=new y(null,null,null,null,new Map,new Map,new Map,new Map,n),o=new _,s=o.visitAllStatements(r,i);return a.isPresent(s)?s.value:null}function i(t){return a.IS_DART?t instanceof v:a.isPresent(t)&&a.isPresent(t.props)&&a.isPresent(t.getters)&&a.isPresent(t.methods)}function o(t,e,n,r,i){for(var o=r.createChildWihtLocalVars(),s=0;si();case c.BinaryOperator.BiggerEquals:return r()>=i();default:throw new l.BaseException("Unknown operator "+t.operator)}},t.prototype.visitReadPropExpr=function(t,e){var n,r=t.receiver.visitExpression(this,e);if(i(r)){var o=r;n=o.props.has(t.name)?o.props.get(t.name):o.getters.has(t.name)?o.getters.get(t.name)():o.methods.has(t.name)?o.methods.get(t.name):p.reflector.getter(t.name)(r)}else n=p.reflector.getter(t.name)(r);return n},t.prototype.visitReadKeyExpr=function(t,e){var n=t.receiver.visitExpression(this,e),r=t.index.visitExpression(this,e);return n[r]},t.prototype.visitLiteralArrayExpr=function(t,e){return this.visitAllExpressions(t.entries,e)},t.prototype.visitLiteralMapExpr=function(t,e){var n=this,r={};return t.entries.forEach(function(t){return r[t[0]]=t[1].visitExpression(n,e)}),r},t.prototype.visitAllExpressions=function(t,e){var n=this;return t.map(function(t){return t.visitExpression(n,e)})},t.prototype.visitAllStatements=function(t,e){for(var n=0;n0?i(n[0]):null;a.isPresent(r)&&(e.print(": "),r.visitExpression(this,e),n=n.slice(1)),e.println(" {"),e.incIndent(),this.visitAllStatements(n,e),e.decIndent(),e.println("}")},e.prototype._visitClassMethod=function(t,e){a.isPresent(t.type)?t.type.visitType(this,e):e.print("void"),e.print(" "+t.name+"("),this._visitParams(t.params,e),e.println(") {"),e.incIndent(),this.visitAllStatements(t.body,e),e.decIndent(),e.println("}")},e.prototype.visitFunctionExpr=function(t,e){return e.print("("),this._visitParams(t.params,e),e.println(") {"),e.incIndent(),this.visitAllStatements(t.statements,e),e.decIndent(),e.print("}"),null},e.prototype.visitDeclareFunctionStmt=function(t,e){return a.isPresent(t.type)?t.type.visitType(this,e):e.print("void"),e.print(" "+t.name+"("),this._visitParams(t.params,e),e.println(") {"),e.incIndent(),this.visitAllStatements(t.statements,e),e.decIndent(),e.println("}"),null},e.prototype.getBuiltinMethodName=function(t){var e;switch(t){case c.BuiltinMethod.ConcatArray:e=".addAll";break;case c.BuiltinMethod.SubscribeObservable:e="listen";break;case c.BuiltinMethod.bind:e=null;break;default:throw new u.BaseException("Unknown builtin method: "+t)}return e},e.prototype.visitTryCatchStmt=function(t,e){return e.println("try {"),e.incIndent(),this.visitAllStatements(t.bodyStmts,e),e.decIndent(),e.println("} catch ("+p.CATCH_ERROR_VAR.name+", "+p.CATCH_STACK_VAR.name+") {"),e.incIndent(),this.visitAllStatements(t.catchStmts,e),e.decIndent(),e.println("}"),null},e.prototype.visitBinaryOperatorExpr=function(e,n){switch(e.operator){case c.BinaryOperator.Identical:n.print("identical("),e.lhs.visitExpression(this,n),n.print(", "),e.rhs.visitExpression(this,n),n.print(")");break;case c.BinaryOperator.NotIdentical:n.print("!identical("),e.lhs.visitExpression(this,n),n.print(", "),e.rhs.visitExpression(this,n),n.print(")");break;default:t.prototype.visitBinaryOperatorExpr.call(this,e,n)}return null},e.prototype.visitLiteralArrayExpr=function(e,n){return o(e.type)&&n.print("const "),t.prototype.visitLiteralArrayExpr.call(this,e,n)},e.prototype.visitLiteralMapExpr=function(e,n){return o(e.type)&&n.print("const "),a.isPresent(e.valueType)&&(n.print("")),t.prototype.visitLiteralMapExpr.call(this,e,n)},e.prototype.visitInstantiateExpr=function(t,e){return e.print(o(t.type)?"const":"new"),e.print(" "),t.classExpr.visitExpression(this,e),e.print("("),this.visitAllExpressions(t.args,e,","),e.print(")"),null},e.prototype.visitBuiltintType=function(t,e){var n;switch(t.name){case c.BuiltinTypeName.Bool:n="bool";break;case c.BuiltinTypeName.Dynamic:n="dynamic";break;case c.BuiltinTypeName.Function:n="Function";break;case c.BuiltinTypeName.Number:n="num";break;case c.BuiltinTypeName.Int:n="int";break;case c.BuiltinTypeName.String:n="String";break;default:throw new u.BaseException("Unsupported builtin type "+t.name)}return e.print(n),null},e.prototype.visitExternalType=function(t,e){return this._visitIdentifier(t.value,t.typeParams,e),null},e.prototype.visitArrayType=function(t,e){return e.print("List<"),a.isPresent(t.of)?t.of.visitType(this,e):e.print("dynamic"),e.print(">"),null},e.prototype.visitMapType=function(t,e){return e.print("Map"),null},e.prototype._visitParams=function(t,e){var n=this;this.visitAllObjects(function(t){a.isPresent(t.type)&&(t.type.visitType(n,e),e.print(" ")),e.print(t.name)},t,e,",")},e.prototype._visitIdentifier=function(t,e,n){var r=this;if(a.isPresent(t.moduleUrl)&&t.moduleUrl!=this._moduleUrl){var i=this.importsWithPrefixes.get(t.moduleUrl);a.isBlank(i)&&(i="import"+this.importsWithPrefixes.size,this.importsWithPrefixes.set(t.moduleUrl,i)),n.print(i+".")}n.print(t.name),a.isPresent(e)&&e.length>0&&(n.print("<"),this.visitAllObjects(function(t){return t.visitType(r,n)},e,n,","),n.print(">"))},e}(p.AbstractEmitterVisitor)},function(t,e,n){"use strict";function r(t,e,n){var r=n===l.Dart?"package:":"",o=h.parse(t,!1),u=h.parse(e,!0);if(a.isBlank(u))return e;if(o.firstLevelDir==u.firstLevelDir&&o.packageName==u.packageName)return i(o.modulePath,u.modulePath,n);if("lib"==u.firstLevelDir)return""+r+u.packageName+"/"+u.modulePath;throw new s.BaseException("Can't import url "+e+" from "+t)}function i(t,e,n){for(var r=t.split(p),i=e.split(p),s=o(r,i),a=[],u=r.length-1-s,h=0;u>h;h++)a.push("..");0>=u&&n===l.JS&&a.push(".");for(var h=s;hn&&t[n]==e[n];)n++;return n}var s=n(12),a=n(5),u=/asset:([^\/]+)\/([^\/]+)\/(.+)/g,c="/",p=/\//g;!function(t){t[t.Dart=0]="Dart",t[t.JS=1]="JS"}(e.ImportEnv||(e.ImportEnv={}));var l=e.ImportEnv;e.getImportModulePath=r;var h=function(){function t(t,e,n){this.packageName=t,this.firstLevelDir=e,this.modulePath=n}return t.parse=function(e,n){var r=a.RegExpWrapper.firstMatch(u,e);if(a.isPresent(r))return new t(r[1],r[2],r[3]);if(n)return null;throw new s.BaseException("Url "+e+" is not a valid asset: url")},t}();e.getRelativePath=i,e.getLongestPathSegmentPrefix=o},function(t,e,n){"use strict";function r(t){var e,n=new h(p),r=u.EmitterVisitorContext.createRoot([]);return e=s.isArray(t)?t:[t],e.forEach(function(t){if(t instanceof o.Statement)t.visitStatement(n,r);else if(t instanceof o.Expression)t.visitExpression(n,r);else{if(!(t instanceof o.Type))throw new a.BaseException("Don't know how to print debug info for "+t);t.visitType(n,r)}}),r.toSource()}var i=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},o=n(164),s=n(5),a=n(12),u=n(192),c=n(196),p="asset://debug/lib";e.debugOutputAstAsTypeScript=r;var l=function(){function t(){}return t.prototype.emitStatements=function(t,e,n){var r=new h(t),i=u.EmitterVisitorContext.createRoot(n);r.visitAllStatements(e,i);var o=[];return r.importsWithPrefixes.forEach(function(e,n){o.push("imp"+("ort * as "+e+" from '"+c.getImportModulePath(t,n,c.ImportEnv.JS)+"';"))}),o.push(i.toSource()),o.join("\n")},t}();e.TypeScriptEmitter=l;var h=function(t){function e(e){t.call(this,!1),this._moduleUrl=e,this.importsWithPrefixes=new Map}return i(e,t),e.prototype.visitExternalExpr=function(t,e){return this._visitIdentifier(t.value,t.typeParams,e),null},e.prototype.visitDeclareVarStmt=function(t,e){return e.isExportedVar(t.name)&&e.print("export "),t.hasModifier(o.StmtModifier.Final)?e.print("const"):e.print("var"),e.print(" "+t.name),s.isPresent(t.type)&&(e.print(":"),t.type.visitType(this,e)),e.print(" = "),t.value.visitExpression(this,e),e.println(";"),null},e.prototype.visitCastExpr=function(t,e){return e.print("(<"),t.type.visitType(this,e),e.print(">"),t.value.visitExpression(this,e),e.print(")"),null},e.prototype.visitDeclareClassStmt=function(t,e){var n=this;return e.pushClass(t),e.isExportedVar(t.name)&&e.print("export "),e.print("class "+t.name),s.isPresent(t.parent)&&(e.print(" extends "),t.parent.visitExpression(this,e)),e.println(" {"),e.incIndent(),t.fields.forEach(function(t){return n._visitClassField(t,e)}),s.isPresent(t.constructorMethod)&&this._visitClassConstructor(t,e),t.getters.forEach(function(t){return n._visitClassGetter(t,e)}),t.methods.forEach(function(t){return n._visitClassMethod(t,e)}),e.decIndent(),e.println("}"),e.popClass(),null},e.prototype._visitClassField=function(t,e){t.hasModifier(o.StmtModifier.Private)&&e.print("private "),e.print(t.name),s.isPresent(t.type)?(e.print(":"),t.type.visitType(this,e)):e.print(": any"),e.println(";")},e.prototype._visitClassGetter=function(t,e){t.hasModifier(o.StmtModifier.Private)&&e.print("private "),e.print("get "+t.name+"()"),s.isPresent(t.type)&&(e.print(":"),t.type.visitType(this,e)),e.println(" {"),e.incIndent(),this.visitAllStatements(t.body,e),e.decIndent(),e.println("}")},e.prototype._visitClassConstructor=function(t,e){e.print("constructor("),this._visitParams(t.constructorMethod.params,e),e.println(") {"),e.incIndent(),this.visitAllStatements(t.constructorMethod.body,e),e.decIndent(),e.println("}")},e.prototype._visitClassMethod=function(t,e){t.hasModifier(o.StmtModifier.Private)&&e.print("private "),e.print(t.name+"("),this._visitParams(t.params,e),e.print("):"),s.isPresent(t.type)?t.type.visitType(this,e):e.print("void"),e.println(" {"),e.incIndent(),this.visitAllStatements(t.body,e),e.decIndent(),e.println("}")},e.prototype.visitFunctionExpr=function(t,e){return e.print("("),this._visitParams(t.params,e),e.print("):"),s.isPresent(t.type)?t.type.visitType(this,e):e.print("void"),e.println(" => {"),e.incIndent(),this.visitAllStatements(t.statements,e),e.decIndent(),e.print("}"),null},e.prototype.visitDeclareFunctionStmt=function(t,e){return e.isExportedVar(t.name)&&e.print("export "),e.print("function "+t.name+"("),this._visitParams(t.params,e),e.print("):"),s.isPresent(t.type)?t.type.visitType(this,e):e.print("void"),e.println(" {"),e.incIndent(),this.visitAllStatements(t.statements,e),e.decIndent(),e.println("}"),null},e.prototype.visitTryCatchStmt=function(t,e){e.println("try {"),e.incIndent(),this.visitAllStatements(t.bodyStmts,e),e.decIndent(),e.println("} catch ("+u.CATCH_ERROR_VAR.name+") {"),e.incIndent();var n=[u.CATCH_STACK_VAR.set(u.CATCH_ERROR_VAR.prop("stack")).toDeclStmt(null,[o.StmtModifier.Final])].concat(t.catchStmts);return this.visitAllStatements(n,e),e.decIndent(),e.println("}"),null},e.prototype.visitBuiltintType=function(t,e){var n;switch(t.name){case o.BuiltinTypeName.Bool:n="boolean";break;case o.BuiltinTypeName.Dynamic:n="any";break;case o.BuiltinTypeName.Function:n="Function";break;case o.BuiltinTypeName.Number:n="number";break;case o.BuiltinTypeName.Int:n="number";break;case o.BuiltinTypeName.String:n="string";break;default:throw new a.BaseException("Unsupported builtin type "+t.name)}return e.print(n),null},e.prototype.visitExternalType=function(t,e){return this._visitIdentifier(t.value,t.typeParams,e),null},e.prototype.visitArrayType=function(t,e){return s.isPresent(t.of)?t.of.visitType(this,e):e.print("any"),e.print("[]"),null},e.prototype.visitMapType=function(t,e){return e.print("{[key: string]:"),s.isPresent(t.valueType)?t.valueType.visitType(this,e):e.print("any"),e.print("}"),null},e.prototype.getBuiltinMethodName=function(t){var e;switch(t){case o.BuiltinMethod.ConcatArray:e="concat";break;case o.BuiltinMethod.SubscribeObservable:e="subscribe";break;case o.BuiltinMethod.bind:e="bind";break;default:throw new a.BaseException("Unknown builtin method: "+t)}return e},e.prototype._visitParams=function(t,e){var n=this;this.visitAllObjects(function(t){e.print(t.name),s.isPresent(t.type)&&(e.print(":"),t.type.visitType(n,e))},t,e,",")},e.prototype._visitIdentifier=function(t,e,n){var r=this;if(s.isPresent(t.moduleUrl)&&t.moduleUrl!=this._moduleUrl){var i=this.importsWithPrefixes.get(t.moduleUrl);s.isBlank(i)&&(i="import"+this.importsWithPrefixes.size,this.importsWithPrefixes.set(t.moduleUrl,i)),n.print(i+".")}n.print(t.name),s.isPresent(e)&&e.length>0&&(n.print("<"),this.visitAllObjects(function(t){return t.visitType(r,n)},e,n,","),n.print(">"))},e}(u.AbstractEmitterVisitor)},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(159),s=n(12),a=function(){function t(){}return t.prototype.createInstance=function(t,e,n,r,i,a){if(t===o.AppView)return new u(n,r,i,a);throw new s.BaseException("Can't instantiate class "+t+" in interpretative mode")},t}();e.InterpretiveAppViewInstanceFactory=a;var u=function(t){function e(e,n,r,i){t.call(this,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]),this.props=n,this.getters=r,this.methods=i}return r(e,t),e.prototype.createInternal=function(e){var n=this.methods.get("createInternal");return i.isPresent(n)?n(e):t.prototype.createInternal.call(this,e)},e.prototype.injectorGetInternal=function(e,n,r){var o=this.methods.get("injectorGetInternal");return i.isPresent(o)?o(e,n,r):t.prototype.injectorGet.call(this,e,n,r)},e.prototype.destroyInternal=function(){var e=this.methods.get("destroyInternal");return i.isPresent(e)?e():t.prototype.destroyInternal.call(this)},e.prototype.dirtyParentQueriesInternal=function(){var e=this.methods.get("dirtyParentQueriesInternal");return i.isPresent(e)?e():t.prototype.dirtyParentQueriesInternal.call(this)},e.prototype.detectChangesInternal=function(e){var n=this.methods.get("detectChangesInternal");return i.isPresent(n)?n(e):t.prototype.detectChangesInternal.call(this,e)},e}(o.AppView)},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(6),a=n(5),u=n(15),c=n(200),p=n(148),l=n(150),h=a.CONST_EXPR({xlink:"http://www.w3.org/1999/xlink",svg:"http://www.w3.org/2000/svg"}),f=function(t){function e(){t.apply(this,arguments),this._protoElements=new Map}return r(e,t),e.prototype._getProtoElement=function(t){var e=this._protoElements.get(t);if(a.isBlank(e)){var n=p.splitNsName(t);e=a.isPresent(n[0])?c.DOM.createElementNS(h[n[0]],n[1]):c.DOM.createElement(n[1]),this._protoElements.set(t,e)}return e},e.prototype.hasProperty=function(t,e){if(-1!==t.indexOf("-"))return!0;var n=this._getProtoElement(t);return c.DOM.hasProperty(n,e)},e.prototype.getMappedPropName=function(t){var e=u.StringMapWrapper.get(c.DOM.attrToPropMap,t);return a.isPresent(e)?e:t},e=i([s.Injectable(),o("design:paramtypes",[])],e)}(l.ElementSchemaRegistry);e.DomElementSchemaRegistry=f},function(t,e,n){"use strict";function r(t){i.isBlank(e.DOM)&&(e.DOM=t)}var i=n(5);e.DOM=null,e.setRootDomAdapter=r;var o=function(){function t(){}return Object.defineProperty(t.prototype,"attrToPropMap",{get:function(){return this._attrToPropMap},set:function(t){this._attrToPropMap=t},enumerable:!0,configurable:!0}),t}();e.DomAdapter=o},function(t,e,n){"use strict";function r(){return s.isBlank(c.getPlatform())&&c.createPlatform(c.ReflectiveInjector.resolveAndCreate(a.BROWSER_PROVIDERS)),c.assertPlatform(a.BROWSER_PLATFORM_MARKER)}function i(t,n){c.reflector.reflectionCapabilities=new p.ReflectionCapabilities;var i=c.ReflectiveInjector.resolveAndCreate([e.BROWSER_APP_PROVIDERS,s.isPresent(n)?n:[]],r().injector);return c.coreLoadAndBootstrap(i,t)}var o=n(202);e.BROWSER_PROVIDERS=o.BROWSER_PROVIDERS,e.CACHED_TEMPLATE_PROVIDER=o.CACHED_TEMPLATE_PROVIDER,e.ELEMENT_PROBE_PROVIDERS=o.ELEMENT_PROBE_PROVIDERS,e.ELEMENT_PROBE_PROVIDERS_PROD_MODE=o.ELEMENT_PROBE_PROVIDERS_PROD_MODE,e.inspectNativeElement=o.inspectNativeElement,e.BrowserDomAdapter=o.BrowserDomAdapter,e.By=o.By,e.Title=o.Title,e.DOCUMENT=o.DOCUMENT,e.enableDebugTools=o.enableDebugTools,e.disableDebugTools=o.disableDebugTools;var s=n(5),a=n(202),u=n(137),c=n(2),p=n(21),l=n(220),h=n(137),f=n(6);e.BROWSER_APP_PROVIDERS=s.CONST_EXPR([a.BROWSER_APP_COMMON_PROVIDERS,u.COMPILER_PROVIDERS,new f.Provider(h.XHR,{useClass:l.XHRImpl})]),e.browserPlatform=r,e.bootstrap=i},function(t,e,n){"use strict";function r(){return new c.ExceptionHandler(h.DOM,!s.IS_DART)}function i(){return h.DOM.defaultDoc()}function o(){E.BrowserDomAdapter.makeCurrent(),R.wtfInit(),w.BrowserGetTestability.init()}var s=n(5),a=n(6),u=n(184),c=n(2),p=n(87),l=n(63),h=n(200),f=n(203),d=n(205),v=n(206),y=n(208),m=n(209),g=n(217),_=n(217),b=n(216),P=n(210),E=n(218),w=n(221),C=n(222),R=n(223),S=n(204),O=n(206),T=n(224),x=n(208);e.DOCUMENT=x.DOCUMENT;var A=n(228);e.Title=A.Title;var I=n(224);e.ELEMENT_PROBE_PROVIDERS=I.ELEMENT_PROBE_PROVIDERS,e.ELEMENT_PROBE_PROVIDERS_PROD_MODE=I.ELEMENT_PROBE_PROVIDERS_PROD_MODE,e.inspectNativeElement=I.inspectNativeElement,e.By=I.By;var M=n(218);e.BrowserDomAdapter=M.BrowserDomAdapter;var k=n(229);e.enableDebugTools=k.enableDebugTools,e.disableDebugTools=k.disableDebugTools;var N=n(206);e.HAMMER_GESTURE_CONFIG=N.HAMMER_GESTURE_CONFIG,e.HammerGestureConfig=N.HammerGestureConfig,e.BROWSER_PLATFORM_MARKER=s.CONST_EXPR(new a.OpaqueToken("BrowserPlatformMarker")),e.BROWSER_PROVIDERS=s.CONST_EXPR([new a.Provider(e.BROWSER_PLATFORM_MARKER,{useValue:!0}),c.PLATFORM_COMMON_PROVIDERS,new a.Provider(c.PLATFORM_INITIALIZER,{useValue:o,multi:!0})]),e.BROWSER_APP_COMMON_PROVIDERS=s.CONST_EXPR([c.APPLICATION_COMMON_PROVIDERS,p.FORM_PROVIDERS,new a.Provider(c.PLATFORM_PIPES,{useValue:p.COMMON_PIPES,multi:!0}),new a.Provider(c.PLATFORM_DIRECTIVES,{useValue:p.COMMON_DIRECTIVES,multi:!0}),new a.Provider(c.ExceptionHandler,{useFactory:r,deps:[]}),new a.Provider(y.DOCUMENT,{useFactory:i,deps:[]}),new a.Provider(S.EVENT_MANAGER_PLUGINS,{useClass:f.DomEventsPlugin,multi:!0}),new a.Provider(S.EVENT_MANAGER_PLUGINS,{useClass:d.KeyEventsPlugin,multi:!0}),new a.Provider(S.EVENT_MANAGER_PLUGINS,{useClass:v.HammerGesturesPlugin,multi:!0}),new a.Provider(O.HAMMER_GESTURE_CONFIG,{useClass:O.HammerGestureConfig}),new a.Provider(m.DomRootRenderer,{useClass:m.DomRootRenderer_}),new a.Provider(c.RootRenderer,{useExisting:m.DomRootRenderer}),new a.Provider(_.SharedStylesHost,{useExisting:g.DomSharedStylesHost}),g.DomSharedStylesHost,l.Testability,b.BrowserDetails,P.AnimationBuilder,S.EventManager,T.ELEMENT_PROBE_PROVIDERS]),e.CACHED_TEMPLATE_PROVIDER=s.CONST_EXPR([new a.Provider(u.XHR,{useClass:C.CachedXHR})]),e.initDomAdapter=o},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(200),a=n(2),u=n(204),c=function(t){function e(){t.apply(this,arguments)}return r(e,t),e.prototype.supports=function(t){return!0},e.prototype.addEventListener=function(t,e,n){var r=this.manager.getZone(),i=function(t){return r.runGuarded(function(){return n(t)})};return this.manager.getZone().runOutsideAngular(function(){return s.DOM.onAndCancel(t,e,i)})},e.prototype.addGlobalEventListener=function(t,e,n){var r=s.DOM.getGlobalEventTarget(t),i=this.manager.getZone(),o=function(t){return i.runGuarded(function(){return n(t)})};return this.manager.getZone().runOutsideAngular(function(){return s.DOM.onAndCancel(r,e,o)})},e=i([a.Injectable(),o("design:paramtypes",[])],e)}(u.EventManagerPlugin);e.DomEventsPlugin=c},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},s=n(5),a=n(12),u=n(6),c=n(60),p=n(15);e.EVENT_MANAGER_PLUGINS=s.CONST_EXPR(new u.OpaqueToken("EventManagerPlugins"));var l=function(){function t(t,e){var n=this;this._zone=e,t.forEach(function(t){return t.manager=n}),this._plugins=p.ListWrapper.reversed(t)}return t.prototype.addEventListener=function(t,e,n){var r=this._findPluginFor(e);return r.addEventListener(t,e,n)},t.prototype.addGlobalEventListener=function(t,e,n){var r=this._findPluginFor(e);return r.addGlobalEventListener(t,e,n)},t.prototype.getZone=function(){return this._zone},t.prototype._findPluginFor=function(t){for(var e=this._plugins,n=0;no?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(200),a=n(5),u=n(15),c=n(204),p=n(6),l=["alt","control","meta","shift"],h={alt:function(t){return t.altKey},control:function(t){return t.ctrlKey},meta:function(t){return t.metaKey},shift:function(t){return t.shiftKey}},f=function(t){function e(){t.call(this)}return r(e,t),e.prototype.supports=function(t){return a.isPresent(e.parseEventName(t))},e.prototype.addEventListener=function(t,n,r){var i=e.parseEventName(n),o=e.eventCallback(t,u.StringMapWrapper.get(i,"fullKey"),r,this.manager.getZone());return this.manager.getZone().runOutsideAngular(function(){return s.DOM.onAndCancel(t,u.StringMapWrapper.get(i,"domEventName"),o)})},e.parseEventName=function(t){var n=t.toLowerCase().split("."),r=n.shift();if(0===n.length||!a.StringWrapper.equals(r,"keydown")&&!a.StringWrapper.equals(r,"keyup"))return null;var i=e._normalizeKey(n.pop()),o="";if(l.forEach(function(t){u.ListWrapper.contains(n,t)&&(u.ListWrapper.remove(n,t),o+=t+".")}),o+=i,0!=n.length||0===i.length)return null;var s=u.StringMapWrapper.create();return u.StringMapWrapper.set(s,"domEventName",r),u.StringMapWrapper.set(s,"fullKey",o),s},e.getEventFullKey=function(t){var e="",n=s.DOM.getEventKey(t);return n=n.toLowerCase(),a.StringWrapper.equals(n," ")?n="space":a.StringWrapper.equals(n,".")&&(n="dot"),l.forEach(function(r){if(r!=n){var i=u.StringMapWrapper.get(h,r);i(t)&&(e+=r+".")}}),e+=n},e.eventCallback=function(t,n,r,i){return function(t){a.StringWrapper.equals(e.getEventFullKey(t),n)&&i.runGuarded(function(){return r(t)})}},e._normalizeKey=function(t){switch(t){case"esc":return"escape";default:return t}},e=i([p.Injectable(),o("design:paramtypes",[])],e)}(c.EventManagerPlugin);e.KeyEventsPlugin=f},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(207),u=n(5),c=n(12),p=n(2);e.HAMMER_GESTURE_CONFIG=u.CONST_EXPR(new p.OpaqueToken("HammerGestureConfig"));var l=function(){function t(){this.events=[],this.overrides={}}return t.prototype.buildHammer=function(t){var e=new Hammer(t);e.get("pinch").set({enable:!0}),e.get("rotate").set({enable:!0});for(var n in this.overrides)e.get(n).set(this.overrides[n]);return e},t=i([p.Injectable(),o("design:paramtypes",[])],t)}();e.HammerGestureConfig=l;var h=function(t){function n(e){t.call(this),this._config=e}return r(n,t),n.prototype.supports=function(e){if(!t.prototype.supports.call(this,e)&&!this.isCustomEvent(e))return!1;if(!u.isPresent(window.Hammer))throw new c.BaseException("Hammer.js is not loaded, can not bind "+e+" event");return!0},n.prototype.addEventListener=function(t,e,n){var r=this,i=this.manager.getZone();return e=e.toLowerCase(),i.runOutsideAngular(function(){var o=r._config.buildHammer(t),s=function(t){i.runGuarded(function(){n(t)})};return o.on(e,s),function(){o.off(e,s)}})},n.prototype.isCustomEvent=function(t){return this._config.events.indexOf(t)>-1},n=i([p.Injectable(),s(0,p.Inject(e.HAMMER_GESTURE_CONFIG)),o("design:paramtypes",[l])],n)}(a.HammerGesturesPluginCommon);e.HammerGesturesPlugin=h},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(204),o=n(15),s={pan:!0,panstart:!0,panmove:!0,panend:!0,pancancel:!0,panleft:!0,panright:!0,panup:!0,pandown:!0,pinch:!0,pinchstart:!0,pinchmove:!0,pinchend:!0,pinchcancel:!0,pinchin:!0,pinchout:!0,press:!0,pressup:!0,rotate:!0,rotatestart:!0,rotatemove:!0,rotateend:!0,rotatecancel:!0,swipe:!0,swipeleft:!0,swiperight:!0,swipeup:!0,swipedown:!0,tap:!0},a=function(t){function e(){t.call(this)}return r(e,t),e.prototype.supports=function(t){return t=t.toLowerCase(),o.StringMapWrapper.contains(s,t)},e}(i.EventManagerPlugin);e.HammerGesturesPluginCommon=a},function(t,e,n){"use strict";var r=n(6),i=n(5);e.DOCUMENT=i.CONST_EXPR(new r.OpaqueToken("DocumentToken"))},function(t,e,n){"use strict";function r(t,e){var n=E.DOM.parentElement(t);if(e.length>0&&y.isPresent(n)){var r=E.DOM.nextSibling(t);if(y.isPresent(r))for(var i=0;io?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s); -return o>3&&s&&Object.defineProperty(e,n,s),s},h=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},f=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},d=n(6),v=n(210),y=n(5),m=n(12),g=n(217),_=n(204),b=n(208),P=n(3),E=n(200),w=n(215),C=y.CONST_EXPR({xlink:"http://www.w3.org/1999/xlink",svg:"http://www.w3.org/2000/svg"}),R="template bindings={}",S=/^template bindings=(.*)$/g,O=function(){function t(t,e,n,r){this.document=t,this.eventManager=e,this.sharedStylesHost=n,this.animate=r,this._registeredComponents=new Map}return t.prototype.renderComponent=function(t){var e=this._registeredComponents.get(t.id);return y.isBlank(e)&&(e=new x(this,t),this._registeredComponents.set(t.id,e)),e},t}();e.DomRootRenderer=O;var T=function(t){function e(e,n,r,i){t.call(this,e,n,r,i)}return p(e,t),e=l([d.Injectable(),f(0,d.Inject(b.DOCUMENT)),h("design:paramtypes",[Object,_.EventManager,g.DomSharedStylesHost,v.AnimationBuilder])],e)}(O);e.DomRootRenderer_=T;var x=function(){function t(t,e){this._rootRenderer=t,this.componentProto=e,this._styles=u(e.id,e.styles,[]),e.encapsulation!==P.ViewEncapsulation.Native&&this._rootRenderer.sharedStylesHost.addStyles(this._styles),this.componentProto.encapsulation===P.ViewEncapsulation.Emulated?(this._contentAttr=s(e.id),this._hostAttr=a(e.id)):(this._contentAttr=null,this._hostAttr=null)}return t.prototype.selectRootElement=function(t,e){var n;if(y.isString(t)){if(n=E.DOM.querySelector(this._rootRenderer.document,t),y.isBlank(n))throw new m.BaseException('The selector "'+t+'" did not match any elements')}else n=t;return E.DOM.clearNodes(n),n},t.prototype.createElement=function(t,e,n){var r=c(e),i=y.isPresent(r[0])?E.DOM.createElementNS(C[r[0]],r[1]):E.DOM.createElement(r[1]);return y.isPresent(this._contentAttr)&&E.DOM.setAttribute(i,this._contentAttr,""),y.isPresent(t)&&E.DOM.appendChild(t,i),i},t.prototype.createViewRoot=function(t){var e;if(this.componentProto.encapsulation===P.ViewEncapsulation.Native){e=E.DOM.createShadowRoot(t),this._rootRenderer.sharedStylesHost.addHost(e);for(var n=0;no?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(6),s=n(211),a=n(216),u=function(){function t(t){this.browserDetails=t}return t.prototype.css=function(){return new s.CssAnimationBuilder(this.browserDetails)},t=r([o.Injectable(),i("design:paramtypes",[a.BrowserDetails])],t)}();e.AnimationBuilder=u},function(t,e,n){"use strict";var r=n(212),i=n(213),o=function(){function t(t){this.browserDetails=t,this.data=new r.CssAnimationOptions}return t.prototype.addAnimationClass=function(t){return this.data.animationClasses.push(t),this},t.prototype.addClass=function(t){return this.data.classesToAdd.push(t),this},t.prototype.removeClass=function(t){return this.data.classesToRemove.push(t),this},t.prototype.setDuration=function(t){return this.data.duration=t,this},t.prototype.setDelay=function(t){return this.data.delay=t,this},t.prototype.setStyles=function(t,e){return this.setFromStyles(t).setToStyles(e)},t.prototype.setFromStyles=function(t){return this.data.fromStyles=t,this},t.prototype.setToStyles=function(t){return this.data.toStyles=t,this},t.prototype.start=function(t){return new i.Animation(t,this.data,this.browserDetails)},t}();e.CssAnimationBuilder=o},function(t,e){"use strict";var n=function(){function t(){this.classesToAdd=[],this.classesToRemove=[],this.animationClasses=[]}return t}();e.CssAnimationOptions=n},function(t,e,n){"use strict";var r=n(5),i=n(214),o=n(215),s=n(15),a=n(200),u=function(){function t(t,e,n){var i=this;this.element=t,this.data=e,this.browserDetails=n,this.callbacks=[],this.eventClearFunctions=[],this.completed=!1,this._stringPrefix="",this.startTime=r.DateWrapper.toMillis(r.DateWrapper.now()),this._stringPrefix=a.DOM.getAnimationPrefix(),this.setup(),this.wait(function(t){return i.start()})}return Object.defineProperty(t.prototype,"totalTime",{get:function(){var t=null!=this.computedDelay?this.computedDelay:0,e=null!=this.computedDuration?this.computedDuration:0;return t+e},enumerable:!0,configurable:!0}),t.prototype.wait=function(t){this.browserDetails.raf(t,2)},t.prototype.setup=function(){null!=this.data.fromStyles&&this.applyStyles(this.data.fromStyles),null!=this.data.duration&&this.applyStyles({transitionDuration:this.data.duration.toString()+"ms"}),null!=this.data.delay&&this.applyStyles({transitionDelay:this.data.delay.toString()+"ms"})},t.prototype.start=function(){this.addClasses(this.data.classesToAdd),this.addClasses(this.data.animationClasses),this.removeClasses(this.data.classesToRemove),null!=this.data.toStyles&&this.applyStyles(this.data.toStyles);var t=a.DOM.getComputedStyle(this.element);this.computedDelay=i.Math.max(this.parseDurationString(t.getPropertyValue(this._stringPrefix+"transition-delay")),this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix+"transition-delay"))),this.computedDuration=i.Math.max(this.parseDurationString(t.getPropertyValue(this._stringPrefix+"transition-duration")),this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix+"transition-duration"))),this.addEvents()},t.prototype.applyStyles=function(t){var e=this;s.StringMapWrapper.forEach(t,function(t,n){var i=o.camelCaseToDashCase(n);r.isPresent(a.DOM.getStyle(e.element,i))?a.DOM.setStyle(e.element,i,t.toString()):a.DOM.setStyle(e.element,e._stringPrefix+i,t.toString())})},t.prototype.addClasses=function(t){for(var e=0,n=t.length;n>e;e++)a.DOM.addClass(this.element,t[e])},t.prototype.removeClasses=function(t){for(var e=0,n=t.length;n>e;e++)a.DOM.removeClass(this.element,t[e])},t.prototype.addEvents=function(){var t=this;this.totalTime>0?this.eventClearFunctions.push(a.DOM.onAndCancel(this.element,a.DOM.getTransitionEnd(),function(e){return t.handleAnimationEvent(e)})):this.handleAnimationCompleted()},t.prototype.handleAnimationEvent=function(t){var e=i.Math.round(1e3*t.elapsedTime);this.browserDetails.elapsedTimeIncludesDelay||(e+=this.computedDelay),t.stopPropagation(),e>=this.totalTime&&this.handleAnimationCompleted()},t.prototype.handleAnimationCompleted=function(){this.removeClasses(this.data.animationClasses),this.callbacks.forEach(function(t){return t()}),this.callbacks=[],this.eventClearFunctions.forEach(function(t){return t()}),this.eventClearFunctions=[],this.completed=!0},t.prototype.onComplete=function(t){return this.completed?t():this.callbacks.push(t),this},t.prototype.parseDurationString=function(t){var e=0;if(null==t||t.length<2)return e;if("ms"==t.substring(t.length-2)){var n=r.NumberWrapper.parseInt(this.stripLetters(t),10);n>e&&(e=n)}else if("s"==t.substring(t.length-1)){var o=1e3*r.NumberWrapper.parseFloat(this.stripLetters(t)),n=i.Math.floor(o);n>e&&(e=n)}return e},t.prototype.stripLetters=function(t){return r.StringWrapper.replaceAll(t,r.RegExpWrapper.create("[^0-9]+$",""),"")},t}();e.Animation=u},function(t,e,n){"use strict";var r=n(5);e.Math=r.global.Math,e.NaN=typeof e.NaN},function(t,e,n){"use strict";function r(t){return o.StringWrapper.replaceAllMapped(t,s,function(t){return"-"+t[1].toLowerCase()})}function i(t){return o.StringWrapper.replaceAllMapped(t,a,function(t){return t[1].toUpperCase()})}var o=n(5),s=/([A-Z])/g,a=/-([a-z])/g;e.camelCaseToDashCase=r,e.dashCaseToCamelCase=i},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(6),s=n(214),a=n(200),u=function(){function t(){this.elapsedTimeIncludesDelay=!1,this.doesElapsedTimeIncludesDelay()}return t.prototype.doesElapsedTimeIncludesDelay=function(){var t=this,e=a.DOM.createElement("div");a.DOM.setAttribute(e,"style","position: absolute; top: -9999px; left: -9999px; width: 1px;\n height: 1px; transition: all 1ms linear 1ms;"),this.raf(function(n){a.DOM.on(e,"transitionend",function(n){var r=s.Math.round(1e3*n.elapsedTime);t.elapsedTimeIncludesDelay=2==r,a.DOM.remove(e)}),a.DOM.setStyle(e,"width","2px")},2)},t.prototype.raf=function(t,e){void 0===e&&(e=1);var n=new c(t,e);return function(){return n.cancel()}},t=r([o.Injectable(),i("design:paramtypes",[])],t)}();e.BrowserDetails=u;var c=function(){function t(t,e){this.callback=t,this.frames=e,this._raf()}return t.prototype._raf=function(){var t=this;this.currentFrameId=a.DOM.requestAnimationFrame(function(e){return t._nextFrame(e)})},t.prototype._nextFrame=function(t){this.frames--,this.frames>0?this._raf():this.callback(t)},t.prototype.cancel=function(){a.DOM.cancelAnimationFrame(this.currentFrameId),this.currentFrameId=null},t}()},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(200),u=n(6),c=n(15),p=n(208),l=function(){function t(){this._styles=[],this._stylesSet=new Set}return t.prototype.addStyles=function(t){var e=this,n=[];t.forEach(function(t){c.SetWrapper.has(e._stylesSet,t)||(e._stylesSet.add(t),e._styles.push(t),n.push(t))}),this.onStylesAdded(n)},t.prototype.onStylesAdded=function(t){},t.prototype.getAllStyles=function(){return this._styles},t=i([u.Injectable(),o("design:paramtypes",[])],t)}();e.SharedStylesHost=l;var h=function(t){function e(e){t.call(this),this._hostNodes=new Set,this._hostNodes.add(e.head)}return r(e,t),e.prototype._addStylesToHost=function(t,e){for(var n=0;n0},e.prototype.tagName=function(t){return t.tagName},e.prototype.attributeMap=function(t){for(var e=new Map,n=t.attributes,r=0;r=200&&300>=i?e.resolve(r):e.reject("Failed to load "+t,null)},n.onerror=function(){e.reject("Failed to load "+t,null)},n.send(),e.promise},e}(s.XHR);e.XHRImpl=a},function(t,e,n){"use strict";var r=n(15),i=n(5),o=n(200),s=n(2),a=function(){function t(t){this._testability=t}return t.prototype.isStable=function(){return this._testability.isStable()},t.prototype.whenStable=function(t){this._testability.whenStable(t)},t.prototype.findBindings=function(t,e,n){return this.findProviders(t,e,n)},t.prototype.findProviders=function(t,e,n){return this._testability.findBindings(t,e,n)},t}(),u=function(){function t(){}return t.init=function(){s.setTestabilityGetter(new t)},t.prototype.addToWindow=function(t){i.global.getAngularTestability=function(e,n){void 0===n&&(n=!0);var r=t.findTestabilityInTree(e,n);if(null==r)throw new Error("Could not find testability for element.");return new a(r)},i.global.getAllAngularTestabilities=function(){var e=t.getAllTestabilities();return e.map(function(t){return new a(t)})},i.global.getAllAngularRootElements=function(){return t.getAllRootElements()};var e=function(t){var e=i.global.getAllAngularTestabilities(),n=e.length,r=!1,o=function(e){r=r||e,n--,0==n&&t(r)};e.forEach(function(t){t.whenStable(o)})};i.global.frameworkStabilizers||(i.global.frameworkStabilizers=r.ListWrapper.createGrowableSize(0)),i.global.frameworkStabilizers.push(e)},t.prototype.findTestabilityInTree=function(t,e,n){if(null==e)return null;var r=t.getTestability(e);return i.isPresent(r)?r:n?o.DOM.isShadowRoot(e)?this.findTestabilityInTree(t,o.DOM.getHost(e),!0):this.findTestabilityInTree(t,o.DOM.parentElement(e),!0):null},t}();e.BrowserGetTestability=u},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(184),o=n(12),s=n(5),a=n(41),u=function(t){function e(){if(t.call(this),this._cache=s.global.$templateCache,null==this._cache)throw new o.BaseException("CachedXHR: Template cache was not found in $templateCache.")}return r(e,t),e.prototype.get=function(t){return this._cache.hasOwnProperty(t)?a.PromiseWrapper.resolve(this._cache[t]):a.PromiseWrapper.reject("CachedXHR: Did not find cached template for "+t,null)},e}(i.XHR);e.CachedXHR=u},function(t,e){"use strict";function n(){}e.wtfInit=n},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var i=n(200);e.DOM=i.DOM,e.setRootDomAdapter=i.setRootDomAdapter,e.DomAdapter=i.DomAdapter;var o=n(209);e.DomRenderer=o.DomRenderer;var s=n(208);e.DOCUMENT=s.DOCUMENT;var a=n(217);e.SharedStylesHost=a.SharedStylesHost,e.DomSharedStylesHost=a.DomSharedStylesHost;var u=n(203);e.DomEventsPlugin=u.DomEventsPlugin;var c=n(204);e.EVENT_MANAGER_PLUGINS=c.EVENT_MANAGER_PLUGINS,e.EventManager=c.EventManager,e.EventManagerPlugin=c.EventManagerPlugin,r(n(225)),r(n(226))},function(t,e,n){"use strict";var r=n(5),i=n(200),o=function(){function t(){}return t.all=function(){return function(t){return!0}},t.css=function(t){return function(e){return r.isPresent(e.nativeElement)?i.DOM.elementMatches(e.nativeElement,t):!1}},t.directive=function(t){return function(e){return-1!==e.providerTokens.indexOf(t)}},t}();e.By=o},function(t,e,n){"use strict";function r(t){return c.getDebugNode(t)}function i(t){return s.assertionsEnabled()?o(t):t}function o(t){return u.DOM.setGlobalVar(d,r),u.DOM.setGlobalVar(v,f),new h.DebugDomRootRenderer(t)}var s=n(5),a=n(6),u=n(200),c=n(83),p=n(209),l=n(2),h=n(227),f=s.CONST_EXPR({ApplicationRef:l.ApplicationRef,NgZone:l.NgZone}),d="ng.probe",v="ng.coreTokens";e.inspectNativeElement=r,e.ELEMENT_PROBE_PROVIDERS=s.CONST_EXPR([new a.Provider(l.RootRenderer,{useFactory:i,deps:[p.DomRootRenderer]})]),e.ELEMENT_PROBE_PROVIDERS_PROD_MODE=s.CONST_EXPR([new a.Provider(l.RootRenderer,{useFactory:o,deps:[p.DomRootRenderer]})])},function(t,e,n){"use strict";var r=n(5),i=n(83),o=function(){function t(t){this._delegate=t}return t.prototype.renderComponent=function(t){return new s(this._delegate.renderComponent(t))},t}();e.DebugDomRootRenderer=o;var s=function(){function t(t){this._delegate=t}return t.prototype.selectRootElement=function(t,e){var n=this._delegate.selectRootElement(t,e),r=new i.DebugElement(n,null,e);return i.indexDebugNode(r),n},t.prototype.createElement=function(t,e,n){var r=this._delegate.createElement(t,e,n),o=new i.DebugElement(r,i.getDebugNode(t),n);return o.name=e,i.indexDebugNode(o),r},t.prototype.createViewRoot=function(t){return this._delegate.createViewRoot(t)},t.prototype.createTemplateAnchor=function(t,e){var n=this._delegate.createTemplateAnchor(t,e),r=new i.DebugNode(n,i.getDebugNode(t),e);return i.indexDebugNode(r),n},t.prototype.createText=function(t,e,n){var r=this._delegate.createText(t,e,n),o=new i.DebugNode(r,i.getDebugNode(t),n);return i.indexDebugNode(o),r},t.prototype.projectNodes=function(t,e){var n=i.getDebugNode(t);if(r.isPresent(n)&&n instanceof i.DebugElement){var o=n;e.forEach(function(t){o.addChild(i.getDebugNode(t))})}this._delegate.projectNodes(t,e)},t.prototype.attachViewAfter=function(t,e){var n=i.getDebugNode(t);if(r.isPresent(n)){var o=n.parent;if(e.length>0&&r.isPresent(o)){var s=[];e.forEach(function(t){return s.push(i.getDebugNode(t))}),o.insertChildrenAfter(n,s)}}this._delegate.attachViewAfter(t,e)},t.prototype.detachView=function(t){t.forEach(function(t){var e=i.getDebugNode(t);r.isPresent(e)&&r.isPresent(e.parent)&&e.parent.removeChild(e)}),this._delegate.detachView(t)},t.prototype.destroyView=function(t,e){e.forEach(function(t){i.removeDebugNodeFromIndex(i.getDebugNode(t))}),this._delegate.destroyView(t,e)},t.prototype.listen=function(t,e,n){var o=i.getDebugNode(t);return r.isPresent(o)&&o.listeners.push(new i.EventListener(e,n)),this._delegate.listen(t,e,n)},t.prototype.listenGlobal=function(t,e,n){return this._delegate.listenGlobal(t,e,n)},t.prototype.setElementProperty=function(t,e,n){ -var o=i.getDebugNode(t);r.isPresent(o)&&o instanceof i.DebugElement&&(o.properties[e]=n),this._delegate.setElementProperty(t,e,n)},t.prototype.setElementAttribute=function(t,e,n){var o=i.getDebugNode(t);r.isPresent(o)&&o instanceof i.DebugElement&&(o.attributes[e]=n),this._delegate.setElementAttribute(t,e,n)},t.prototype.setBindingDebugInfo=function(t,e,n){this._delegate.setBindingDebugInfo(t,e,n)},t.prototype.setElementClass=function(t,e,n){this._delegate.setElementClass(t,e,n)},t.prototype.setElementStyle=function(t,e,n){this._delegate.setElementStyle(t,e,n)},t.prototype.invokeElementMethod=function(t,e,n){this._delegate.invokeElementMethod(t,e,n)},t.prototype.setText=function(t,e){this._delegate.setText(t,e)},t}();e.DebugDomRenderer=s},function(t,e,n){"use strict";var r=n(200),i=function(){function t(){}return t.prototype.getTitle=function(){return r.DOM.getTitle()},t.prototype.setTitle=function(t){r.DOM.setTitle(t)},t}();e.Title=i},function(t,e,n){"use strict";function r(t){a.ng=new s.AngularTools(t)}function i(){delete a.ng}var o=n(5),s=n(230),a=o.global;e.enableDebugTools=r,e.disableDebugTools=i},function(t,e,n){"use strict";var r=n(59),i=n(5),o=n(231),s=n(200),a=function(){function t(t,e){this.msPerTick=t,this.numTicks=e}return t}();e.ChangeDetectionPerfRecord=a;var u=function(){function t(t){this.profiler=new c(t)}return t}();e.AngularTools=u;var c=function(){function t(t){this.appRef=t.injector.get(r.ApplicationRef)}return t.prototype.timeChangeDetection=function(t){var e=i.isPresent(t)&&t.record,n="Change Detection",r=i.isPresent(o.window.console.profile);e&&r&&o.window.console.profile(n);for(var u=s.DOM.performanceNow(),c=0;5>c||s.DOM.performanceNow()-u<500;)this.appRef.tick(),c++;var p=s.DOM.performanceNow();e&&r&&o.window.console.profileEnd(n);var l=(p-u)/c;return o.window.console.log("ran "+c+" change detection cycles"),o.window.console.log(i.NumberWrapper.toFixed(l,2)+" ms per check"),new a(l,c)},t}();e.AngularProfiler=c},function(t,e){"use strict";var n=window;e.window=n,e.document=window.document,e.location=window.location,e.gc=window.gc?function(){return window.gc()}:function(){return null},e.performance=window.performance?window.performance:null,e.Event=window.Event,e.MouseEvent=window.MouseEvent,e.KeyboardEvent=window.KeyboardEvent,e.EventTarget=window.EventTarget,e.History=window.History,e.Location=window.Location,e.EventListener=window.EventListener},function(t,e,n){"use strict";var r=n(2),i=n(233),o=n(241),s=n(245),a=n(244),u=n(246),c=n(239),p=n(243),l=n(235);e.Request=l.Request;var h=n(242);e.Response=h.Response;var f=n(234);e.Connection=f.Connection,e.ConnectionBackend=f.ConnectionBackend;var d=n(244);e.BrowserXhr=d.BrowserXhr;var v=n(239);e.BaseRequestOptions=v.BaseRequestOptions,e.RequestOptions=v.RequestOptions;var y=n(243);e.BaseResponseOptions=y.BaseResponseOptions,e.ResponseOptions=y.ResponseOptions;var m=n(241);e.XHRBackend=m.XHRBackend,e.XHRConnection=m.XHRConnection;var g=n(245);e.JSONPBackend=g.JSONPBackend,e.JSONPConnection=g.JSONPConnection;var _=n(233);e.Http=_.Http,e.Jsonp=_.Jsonp;var b=n(236);e.Headers=b.Headers;var P=n(238);e.ResponseType=P.ResponseType,e.ReadyState=P.ReadyState,e.RequestMethod=P.RequestMethod;var E=n(240);e.URLSearchParams=E.URLSearchParams,e.HTTP_PROVIDERS=[r.provide(i.Http,{useFactory:function(t,e){return new i.Http(t,e)},deps:[o.XHRBackend,c.RequestOptions]}),a.BrowserXhr,r.provide(c.RequestOptions,{useClass:c.BaseRequestOptions}),r.provide(p.ResponseOptions,{useClass:p.BaseResponseOptions}),o.XHRBackend],e.HTTP_BINDINGS=e.HTTP_PROVIDERS,e.JSONP_PROVIDERS=[r.provide(i.Jsonp,{useFactory:function(t,e){return new i.Jsonp(t,e)},deps:[s.JSONPBackend,c.RequestOptions]}),u.BrowserJsonp,r.provide(c.RequestOptions,{useClass:c.BaseRequestOptions}),r.provide(p.ResponseOptions,{useClass:p.BaseResponseOptions}),r.provide(s.JSONPBackend,{useClass:s.JSONPBackend_})],e.JSON_BINDINGS=e.JSONP_PROVIDERS},function(t,e,n){"use strict";function r(t,e){return t.createConnection(e).response}function i(t,e,n,r){var i=t;return u.isPresent(e)?i.merge(new f.RequestOptions({method:e.method||n,url:e.url||r,search:e.search,headers:e.headers,body:e.body})):u.isPresent(n)?i.merge(new f.RequestOptions({method:n,url:r})):i.merge(new f.RequestOptions({url:r}))}var o=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},s=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},a=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},u=n(5),c=n(12),p=n(2),l=n(234),h=n(235),f=n(239),d=n(238),v=function(){function t(t,e){this._backend=t,this._defaultOptions=e}return t.prototype.request=function(t,e){var n;if(u.isString(t))n=r(this._backend,new h.Request(i(this._defaultOptions,e,d.RequestMethod.Get,t)));else{if(!(t instanceof h.Request))throw c.makeTypeError("First argument must be a url string or Request instance.");n=r(this._backend,t)}return n},t.prototype.get=function(t,e){return r(this._backend,new h.Request(i(this._defaultOptions,e,d.RequestMethod.Get,t)))},t.prototype.post=function(t,e,n){return r(this._backend,new h.Request(i(this._defaultOptions.merge(new f.RequestOptions({body:e})),n,d.RequestMethod.Post,t)))},t.prototype.put=function(t,e,n){return r(this._backend,new h.Request(i(this._defaultOptions.merge(new f.RequestOptions({body:e})),n,d.RequestMethod.Put,t)))},t.prototype["delete"]=function(t,e){return r(this._backend,new h.Request(i(this._defaultOptions,e,d.RequestMethod.Delete,t)))},t.prototype.patch=function(t,e,n){return r(this._backend,new h.Request(i(this._defaultOptions.merge(new f.RequestOptions({body:e})),n,d.RequestMethod.Patch,t)))},t.prototype.head=function(t,e){return r(this._backend,new h.Request(i(this._defaultOptions,e,d.RequestMethod.Head,t)))},t=s([p.Injectable(),a("design:paramtypes",[l.ConnectionBackend,f.RequestOptions])],t)}();e.Http=v;var y=function(t){function e(e,n){t.call(this,e,n)}return o(e,t),e.prototype.request=function(t,e){var n;if(u.isString(t)&&(t=new h.Request(i(this._defaultOptions,e,d.RequestMethod.Get,t))),!(t instanceof h.Request))throw c.makeTypeError("First argument must be a url string or Request instance.");return t.method!==d.RequestMethod.Get&&c.makeTypeError("JSONP requests must use GET request method."),n=r(this._backend,t)},e=s([p.Injectable(),a("design:paramtypes",[l.ConnectionBackend,f.RequestOptions])],e)}(v);e.Jsonp=y},function(t,e){"use strict";var n=function(){function t(){}return t}();e.ConnectionBackend=n;var r=function(){function t(){}return t}();e.Connection=r},function(t,e,n){"use strict";var r=n(236),i=n(237),o=n(5),s=function(){function t(t){var e=t.url;if(this.url=t.url,o.isPresent(t.search)){var n=t.search.toString();if(n.length>0){var s="?";o.StringWrapper.contains(this.url,"?")&&(s="&"==this.url[this.url.length-1]?"":"&"),this.url=e+s+n}}this._body=t.body,this.method=i.normalizeMethodName(t.method),this.headers=new r.Headers(t.headers)}return t.prototype.text=function(){return o.isPresent(this._body)?this._body.toString():""},t}();e.Request=s},function(t,e,n){"use strict";var r=n(5),i=n(12),o=n(15),s=function(){function t(e){var n=this;return e instanceof t?void(this._headersMap=e._headersMap):(this._headersMap=new o.Map,void(r.isBlank(e)||o.StringMapWrapper.forEach(e,function(t,e){n._headersMap.set(e,o.isListLikeIterable(t)?t:[t])})))}return t.fromResponseHeaderString=function(e){return e.trim().split("\n").map(function(t){return t.split(":")}).map(function(t){var e=t[0],n=t.slice(1);return[e.trim(),n.join(":").trim()]}).reduce(function(t,e){var n=e[0],r=e[1];return!t.set(n,r)&&t},new t)},t.prototype.append=function(t,e){var n=this._headersMap.get(t),r=o.isListLikeIterable(n)?n:[];r.push(e),this._headersMap.set(t,r)},t.prototype["delete"]=function(t){this._headersMap["delete"](t)},t.prototype.forEach=function(t){this._headersMap.forEach(t)},t.prototype.get=function(t){return o.ListWrapper.first(this._headersMap.get(t))},t.prototype.has=function(t){return this._headersMap.has(t)},t.prototype.keys=function(){return o.MapWrapper.keys(this._headersMap)},t.prototype.set=function(t,e){var n=[];if(o.isListLikeIterable(e)){var r=e.join(",");n.push(r)}else n.push(e);this._headersMap.set(t,n)},t.prototype.values=function(){return o.MapWrapper.values(this._headersMap)},t.prototype.toJSON=function(){var t={};return this._headersMap.forEach(function(e,n){var r=[];o.iterateListLike(e,function(t){return r=o.ListWrapper.concat(r,t.split(","))}),t[n]=r}),t},t.prototype.getAll=function(t){var e=this._headersMap.get(t);return o.isListLikeIterable(e)?e:[]},t.prototype.entries=function(){throw new i.BaseException('"entries" method is not implemented on Headers class')},t}();e.Headers=s},function(t,e,n){"use strict";function r(t){if(o.isString(t)){var e=t;if(t=t.replace(/(\w)(\w*)/g,function(t,e,n){return e.toUpperCase()+n.toLowerCase()}),t=s.RequestMethod[t],"number"!=typeof t)throw a.makeTypeError('Invalid request method. The method "'+e+'" is not supported.')}return t}function i(t){return"responseURL"in t?t.responseURL:/^X-Request-URL:/m.test(t.getAllResponseHeaders())?t.getResponseHeader("X-Request-URL"):void 0}var o=n(5),s=n(238),a=n(12);e.normalizeMethodName=r,e.isSuccess=function(t){return t>=200&&300>t},e.getResponseURL=i;var u=n(5);e.isJsObject=u.isJsObject},function(t,e){"use strict";!function(t){t[t.Get=0]="Get",t[t.Post=1]="Post",t[t.Put=2]="Put",t[t.Delete=3]="Delete",t[t.Options=4]="Options",t[t.Head=5]="Head",t[t.Patch=6]="Patch"}(e.RequestMethod||(e.RequestMethod={}));e.RequestMethod;!function(t){t[t.Unsent=0]="Unsent",t[t.Open=1]="Open",t[t.HeadersReceived=2]="HeadersReceived",t[t.Loading=3]="Loading",t[t.Done=4]="Done",t[t.Cancelled=5]="Cancelled"}(e.ReadyState||(e.ReadyState={}));e.ReadyState;!function(t){t[t.Basic=0]="Basic",t[t.Cors=1]="Cors",t[t.Default=2]="Default",t[t.Error=3]="Error",t[t.Opaque=4]="Opaque"}(e.ResponseType||(e.ResponseType={}));e.ResponseType},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(5),a=n(236),u=n(238),c=n(2),p=n(240),l=n(237),h=function(){function t(t){var e=void 0===t?{}:t,n=e.method,r=e.headers,i=e.body,o=e.url,a=e.search;this.method=s.isPresent(n)?l.normalizeMethodName(n):null,this.headers=s.isPresent(r)?r:null,this.body=s.isPresent(i)?i:null,this.url=s.isPresent(o)?o:null,this.search=s.isPresent(a)?s.isString(a)?new p.URLSearchParams(a):a:null}return t.prototype.merge=function(e){return new t({method:s.isPresent(e)&&s.isPresent(e.method)?e.method:this.method,headers:s.isPresent(e)&&s.isPresent(e.headers)?e.headers:this.headers,body:s.isPresent(e)&&s.isPresent(e.body)?e.body:this.body,url:s.isPresent(e)&&s.isPresent(e.url)?e.url:this.url,search:s.isPresent(e)&&s.isPresent(e.search)?s.isString(e.search)?new p.URLSearchParams(e.search):e.search.clone():this.search})},t}();e.RequestOptions=h;var f=function(t){function e(){t.call(this,{method:u.RequestMethod.Get,headers:new a.Headers})}return r(e,t),e=i([c.Injectable(),o("design:paramtypes",[])],e)}(h);e.BaseRequestOptions=f},function(t,e,n){"use strict";function r(t){void 0===t&&(t="");var e=new o.Map;if(t.length>0){var n=t.split("&");n.forEach(function(t){var n=t.split("="),r=n[0],o=n[1],s=i.isPresent(e.get(r))?e.get(r):[];s.push(o),e.set(r,s)})}return e}var i=n(5),o=n(15),s=function(){function t(t){void 0===t&&(t=""),this.rawParams=t,this.paramsMap=r(t)}return t.prototype.clone=function(){var e=new t;return e.appendAll(this),e},t.prototype.has=function(t){return this.paramsMap.has(t)},t.prototype.get=function(t){var e=this.paramsMap.get(t);return o.isListLikeIterable(e)?o.ListWrapper.first(e):null},t.prototype.getAll=function(t){var e=this.paramsMap.get(t);return i.isPresent(e)?e:[]},t.prototype.set=function(t,e){var n=this.paramsMap.get(t),r=i.isPresent(n)?n:[];o.ListWrapper.clear(r),r.push(e),this.paramsMap.set(t,r)},t.prototype.setAll=function(t){var e=this;t.paramsMap.forEach(function(t,n){var r=e.paramsMap.get(n),s=i.isPresent(r)?r:[];o.ListWrapper.clear(s),s.push(t[0]),e.paramsMap.set(n,s)})},t.prototype.append=function(t,e){var n=this.paramsMap.get(t),r=i.isPresent(n)?n:[];r.push(e),this.paramsMap.set(t,r)},t.prototype.appendAll=function(t){var e=this;t.paramsMap.forEach(function(t,n){for(var r=e.paramsMap.get(n),o=i.isPresent(r)?r:[],s=0;so?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(238),s=n(242),a=n(236),u=n(243),c=n(2),p=n(244),l=n(5),h=n(42),f=n(237),d=function(){function t(t,e,n){var r=this;this.request=t,this.response=new h.Observable(function(i){var c=e.build();c.open(o.RequestMethod[t.method].toUpperCase(),t.url);var p=function(){var t=l.isPresent(c.response)?c.response:c.responseText,e=a.Headers.fromResponseHeaderString(c.getAllResponseHeaders()),r=f.getResponseURL(c),o=1223===c.status?204:c.status;0===o&&(o=t?200:0);var p=new u.ResponseOptions({body:t,status:o,headers:e,url:r});l.isPresent(n)&&(p=n.merge(p));var h=new s.Response(p);return f.isSuccess(o)?(i.next(h),void i.complete()):void i.error(h)},h=function(t){var e=new u.ResponseOptions({body:t,type:o.ResponseType.Error});l.isPresent(n)&&(e=n.merge(e)),i.error(new s.Response(e))};return l.isPresent(t.headers)&&t.headers.forEach(function(t,e){return c.setRequestHeader(e,t.join(","))}),c.addEventListener("load",p),c.addEventListener("error",h),c.send(r.request.text()),function(){c.removeEventListener("load",p),c.removeEventListener("error",h),c.abort()}})}return t}();e.XHRConnection=d;var v=function(){function t(t,e){this._browserXHR=t,this._baseResponseOptions=e}return t.prototype.createConnection=function(t){return new d(t,this._browserXHR,this._baseResponseOptions)},t=r([c.Injectable(),i("design:paramtypes",[p.BrowserXhr,u.ResponseOptions])],t)}();e.XHRBackend=v},function(t,e,n){"use strict";var r=n(5),i=n(12),o=n(237),s=function(){function t(t){this._body=t.body,this.status=t.status,this.ok=this.status>=200&&this.status<=299,this.statusText=t.statusText,this.headers=t.headers,this.type=t.type,this.url=t.url}return t.prototype.blob=function(){throw new i.BaseException('"blob()" method not implemented on Response superclass')},t.prototype.json=function(){var t;return o.isJsObject(this._body)?t=this._body:r.isString(this._body)&&(t=r.Json.parse(this._body)),t},t.prototype.text=function(){return this._body.toString()},t.prototype.arrayBuffer=function(){throw new i.BaseException('"arrayBuffer()" method not implemented on Response superclass')},t}();e.Response=s},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(2),a=n(5),u=n(236),c=n(238),p=function(){function t(t){var e=void 0===t?{}:t,n=e.body,r=e.status,i=e.headers,o=e.statusText,s=e.type,u=e.url;this.body=a.isPresent(n)?n:null,this.status=a.isPresent(r)?r:null,this.headers=a.isPresent(i)?i:null,this.statusText=a.isPresent(o)?o:null,this.type=a.isPresent(s)?s:null,this.url=a.isPresent(u)?u:null}return t.prototype.merge=function(e){return new t({body:a.isPresent(e)&&a.isPresent(e.body)?e.body:this.body,status:a.isPresent(e)&&a.isPresent(e.status)?e.status:this.status,headers:a.isPresent(e)&&a.isPresent(e.headers)?e.headers:this.headers,statusText:a.isPresent(e)&&a.isPresent(e.statusText)?e.statusText:this.statusText,type:a.isPresent(e)&&a.isPresent(e.type)?e.type:this.type,url:a.isPresent(e)&&a.isPresent(e.url)?e.url:this.url})},t}();e.ResponseOptions=p;var l=function(t){function e(){t.call(this,{status:200,statusText:"Ok",type:c.ResponseType.Default,headers:new u.Headers})}return r(e,t),e=i([s.Injectable(),o("design:paramtypes",[])],e)}(p);e.BaseResponseOptions=l},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=function(){function t(){}return t.prototype.build=function(){return new XMLHttpRequest},t=r([o.Injectable(),i("design:paramtypes",[])],t)}();e.BrowserXhr=s},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(234),a=n(238),u=n(242),c=n(243),p=n(2),l=n(246),h=n(12),f=n(5),d=n(42),v="JSONP injected script did not invoke callback.",y="JSONP requests must use GET request method.",m=function(){function t(){}return t}();e.JSONPConnection=m;var g=function(t){function e(e,n,r){var i=this;if(t.call(this),this._dom=n,this.baseResponseOptions=r,this._finished=!1,e.method!==a.RequestMethod.Get)throw h.makeTypeError(y);this.request=e,this.response=new d.Observable(function(t){i.readyState=a.ReadyState.Loading;var o=i._id=n.nextRequestID();n.exposeConnection(o,i);var s=n.requestCallback(i._id),p=e.url;p.indexOf("=JSONP_CALLBACK&")>-1?p=f.StringWrapper.replace(p,"=JSONP_CALLBACK&","="+s+"&"):p.lastIndexOf("=JSONP_CALLBACK")===p.length-"=JSONP_CALLBACK".length&&(p=p.substring(0,p.length-"=JSONP_CALLBACK".length)+("="+s));var l=i._script=n.build(p),h=function(e){if(i.readyState!==a.ReadyState.Cancelled){if(i.readyState=a.ReadyState.Done,n.cleanup(l),!i._finished){var o=new c.ResponseOptions({body:v,type:a.ResponseType.Error,url:p});return f.isPresent(r)&&(o=r.merge(o)),void t.error(new u.Response(o))}var s=new c.ResponseOptions({body:i._responseData,url:p});f.isPresent(i.baseResponseOptions)&&(s=i.baseResponseOptions.merge(s)),t.next(new u.Response(s)),t.complete()}},d=function(e){if(i.readyState!==a.ReadyState.Cancelled){i.readyState=a.ReadyState.Done,n.cleanup(l);var o=new c.ResponseOptions({body:e.message,type:a.ResponseType.Error});f.isPresent(r)&&(o=r.merge(o)),t.error(new u.Response(o))}};return l.addEventListener("load",h),l.addEventListener("error",d),n.send(l),function(){i.readyState=a.ReadyState.Cancelled,l.removeEventListener("load",h),l.removeEventListener("error",d),f.isPresent(l)&&i._dom.cleanup(l)}})}return r(e,t),e.prototype.finished=function(t){this._finished=!0,this._dom.removeConnection(this._id),this.readyState!==a.ReadyState.Cancelled&&(this._responseData=t)},e}(m);e.JSONPConnection_=g;var _=function(t){function e(){t.apply(this,arguments)}return r(e,t),e}(s.ConnectionBackend);e.JSONPBackend=_;var b=function(t){function e(e,n){t.call(this),this._browserJSONP=e,this._baseResponseOptions=n}return r(e,t),e.prototype.createConnection=function(t){return new g(t,this._browserJSONP,this._baseResponseOptions)},e=i([p.Injectable(),o("design:paramtypes",[l.BrowserJsonp,c.ResponseOptions])],e)}(_);e.JSONPBackend_=b},function(t,e,n){"use strict";function r(){return null===c&&(c=a.global[e.JSONP_HOME]={}),c}var i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(2),a=n(5),u=0;e.JSONP_HOME="__ng_jsonp__";var c=null,p=function(){function t(){}return t.prototype.build=function(t){var e=document.createElement("script");return e.src=t,e},t.prototype.nextRequestID=function(){return"__req"+u++},t.prototype.requestCallback=function(t){return e.JSONP_HOME+"."+t+".finished"},t.prototype.exposeConnection=function(t,e){var n=r();n[t]=e},t.prototype.removeConnection=function(t){var e=r();e[t]=null},t.prototype.send=function(t){document.body.appendChild(t)},t.prototype.cleanup=function(t){t.parentNode&&t.parentNode.removeChild(t)},t=i([s.Injectable(),o("design:paramtypes",[])],t)}();e.BrowserJsonp=p},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var i=n(248);e.Router=i.Router;var o=n(272);e.RouterOutlet=o.RouterOutlet;var s=n(274);e.RouterLink=s.RouterLink;var a=n(260);e.RouteParams=a.RouteParams,e.RouteData=a.RouteData;var u=n(256);e.RouteRegistry=u.RouteRegistry,e.ROUTER_PRIMARY_COMPONENT=u.ROUTER_PRIMARY_COMPONENT,r(n(269));var c=n(273);e.CanActivate=c.CanActivate;var p=n(260);e.Instruction=p.Instruction,e.ComponentInstruction=p.ComponentInstruction;var l=n(2);e.OpaqueToken=l.OpaqueToken;var h=n(275);e.ROUTER_PROVIDERS_COMMON=h.ROUTER_PROVIDERS_COMMON;var f=n(276);e.ROUTER_PROVIDERS=f.ROUTER_PROVIDERS,e.ROUTER_BINDINGS=f.ROUTER_BINDINGS;var d=n(272),v=n(274),y=n(5);e.ROUTER_DIRECTIVES=y.CONST_EXPR([d.RouterOutlet,v.RouterLink])},function(t,e,n){"use strict";function r(t,e){var n=y;return p.isBlank(t.component)?n:(p.isPresent(t.child)&&(n=r(t.child,p.isPresent(e)?e.child:null)),n.then(function(n){if(0==n)return!1;if(t.component.reuse)return!0;var r=v.getCanActivateHook(t.component.componentType);return p.isPresent(r)?r(t.component,p.isPresent(e)?e.component:null):!0}))}var i=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},o=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},s=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},a=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},u=n(40),c=n(15),p=n(5),l=n(12),h=n(249),f=n(2),d=n(256),v=n(270),y=u.PromiseWrapper.resolve(!0),m=u.PromiseWrapper.resolve(!1),g=function(){function t(t,e,n,r){this.registry=t,this.parent=e,this.hostComponent=n,this.root=r,this.navigating=!1,this.currentInstruction=null,this._currentNavigation=y,this._outlet=null,this._auxRouters=new c.Map,this._subject=new u.EventEmitter}return t.prototype.childRouter=function(t){return this._childRouter=new b(this,t)},t.prototype.auxRouter=function(t){return new b(this,t)},t.prototype.registerPrimaryOutlet=function(t){if(p.isPresent(t.name))throw new l.BaseException("registerPrimaryOutlet expects to be called with an unnamed outlet.");if(p.isPresent(this._outlet))throw new l.BaseException("Primary outlet is already registered.");return this._outlet=t,p.isPresent(this.currentInstruction)?this.commit(this.currentInstruction,!1):y},t.prototype.unregisterPrimaryOutlet=function(t){if(p.isPresent(t.name))throw new l.BaseException("registerPrimaryOutlet expects to be called with an unnamed outlet.");this._outlet=null},t.prototype.registerAuxOutlet=function(t){var e=t.name;if(p.isBlank(e))throw new l.BaseException("registerAuxOutlet expects to be called with an outlet with a name.");var n=this.auxRouter(this.hostComponent);this._auxRouters.set(e,n),n._outlet=t;var r;return p.isPresent(this.currentInstruction)&&p.isPresent(r=this.currentInstruction.auxInstruction[e])?n.commit(r):y},t.prototype.isRouteActive=function(t){var e=this,n=this;if(p.isBlank(this.currentInstruction))return!1;for(;p.isPresent(n.parent)&&p.isPresent(t.child);)n=n.parent,t=t.child;if(p.isBlank(t.component)||p.isBlank(this.currentInstruction.component)||this.currentInstruction.component.routeName!=t.component.routeName)return!1;var r=!0;return p.isPresent(this.currentInstruction.component.params)&&c.StringMapWrapper.forEach(t.component.params,function(t,n){e.currentInstruction.component.params[n]!==t&&(r=!1)}),r},t.prototype.config=function(t){var e=this;return t.forEach(function(t){e.registry.config(e.hostComponent,t)}),this.renavigate()},t.prototype.navigate=function(t){var e=this.generate(t);return this.navigateByInstruction(e,!1)},t.prototype.navigateByUrl=function(t,e){var n=this;return void 0===e&&(e=!1),this._currentNavigation=this._currentNavigation.then(function(r){return n.lastNavigationAttempt=t,n._startNavigating(),n._afterPromiseFinishNavigating(n.recognize(t).then(function(t){return p.isBlank(t)?!1:n._navigate(t,e)}))})},t.prototype.navigateByInstruction=function(t,e){var n=this;return void 0===e&&(e=!1),p.isBlank(t)?m:this._currentNavigation=this._currentNavigation.then(function(r){return n._startNavigating(),n._afterPromiseFinishNavigating(n._navigate(t,e))})},t.prototype._settleInstruction=function(t){var e=this;return t.resolveComponent().then(function(n){var r=[];return p.isPresent(t.component)&&(t.component.reuse=!1),p.isPresent(t.child)&&r.push(e._settleInstruction(t.child)),c.StringMapWrapper.forEach(t.auxInstruction,function(t,n){r.push(e._settleInstruction(t))}),u.PromiseWrapper.all(r)})},t.prototype._navigate=function(t,e){var n=this;return this._settleInstruction(t).then(function(e){return n._routerCanReuse(t)}).then(function(e){return n._canActivate(t)}).then(function(r){return r?n._routerCanDeactivate(t).then(function(r){return r?n.commit(t,e).then(function(e){return n._emitNavigationFinish(t.toRootUrl()),!0}):void 0}):!1})},t.prototype._emitNavigationFinish=function(t){u.ObservableWrapper.callEmit(this._subject,t)},t.prototype._emitNavigationFail=function(t){u.ObservableWrapper.callError(this._subject,t)},t.prototype._afterPromiseFinishNavigating=function(t){var e=this;return u.PromiseWrapper.catchError(t.then(function(t){return e._finishNavigating()}),function(t){throw e._finishNavigating(),t})},t.prototype._routerCanReuse=function(t){var e=this;return p.isBlank(this._outlet)?m:p.isBlank(t.component)?y:this._outlet.routerCanReuse(t.component).then(function(n){return t.component.reuse=n,n&&p.isPresent(e._childRouter)&&p.isPresent(t.child)?e._childRouter._routerCanReuse(t.child):void 0})},t.prototype._canActivate=function(t){return r(t,this.currentInstruction)},t.prototype._routerCanDeactivate=function(t){var e=this;if(p.isBlank(this._outlet))return y;var n,r=null,i=!1,o=null;return p.isPresent(t)&&(r=t.child,o=t.component,i=p.isBlank(t.component)||t.component.reuse),n=i?y:this._outlet.routerCanDeactivate(o),n.then(function(t){return 0==t?!1:p.isPresent(e._childRouter)?e._childRouter._routerCanDeactivate(r):!0})},t.prototype.commit=function(t,e){var n=this;void 0===e&&(e=!1),this.currentInstruction=t;var r=y;if(p.isPresent(this._outlet)&&p.isPresent(t.component)){var i=t.component;r=i.reuse?this._outlet.reuse(i):this.deactivate(t).then(function(t){return n._outlet.activate(i)}),p.isPresent(t.child)&&(r=r.then(function(e){return p.isPresent(n._childRouter)?n._childRouter.commit(t.child):void 0}))}var o=[];return this._auxRouters.forEach(function(e,n){p.isPresent(t.auxInstruction[n])&&o.push(e.commit(t.auxInstruction[n]))}),r.then(function(t){return u.PromiseWrapper.all(o)})},t.prototype._startNavigating=function(){this.navigating=!0},t.prototype._finishNavigating=function(){this.navigating=!1},t.prototype.subscribe=function(t,e){return u.ObservableWrapper.subscribe(this._subject,t,e)},t.prototype.deactivate=function(t){var e=this,n=null,r=null;p.isPresent(t)&&(n=t.child,r=t.component);var i=y;return p.isPresent(this._childRouter)&&(i=this._childRouter.deactivate(n)),p.isPresent(this._outlet)&&(i=i.then(function(t){return e._outlet.deactivate(r)})),i},t.prototype.recognize=function(t){var e=this._getAncestorInstructions();return this.registry.recognize(t,e)},t.prototype._getAncestorInstructions=function(){for(var t=[this.currentInstruction],e=this;p.isPresent(e=e.parent);)t.unshift(e.currentInstruction);return t},t.prototype.renavigate=function(){return p.isBlank(this.lastNavigationAttempt)?this._currentNavigation:this.navigateByUrl(this.lastNavigationAttempt)},t.prototype.generate=function(t){var e=this._getAncestorInstructions();return this.registry.generate(t,e)},t=o([f.Injectable(),s("design:paramtypes",[d.RouteRegistry,t,Object,t])],t)}();e.Router=g;var _=function(t){function e(e,n,r){var i=this;t.call(this,e,null,r),this.root=this,this._location=n,this._locationSub=this._location.subscribe(function(t){i.recognize(t.url).then(function(e){p.isPresent(e)?i.navigateByInstruction(e,p.isPresent(t.pop)).then(function(n){if(!p.isPresent(t.pop)||"hashchange"==t.type){var r=e.toUrlPath(),o=e.toUrlQuery();r.length>0&&"/"!=r[0]&&(r="/"+r),"hashchange"==t.type?e.toRootUrl()!=i._location.path()&&i._location.replaceState(r,o):i._location.go(r,o)}}):i._emitNavigationFail(t.url)})}),this.registry.configFromComponent(r),this.navigateByUrl(n.path())}return i(e,t),e.prototype.commit=function(e,n){var r=this;void 0===n&&(n=!1);var i=e.toUrlPath(),o=e.toUrlQuery();i.length>0&&"/"!=i[0]&&(i="/"+i);var s=t.prototype.commit.call(this,e);return n||(s=s.then(function(t){ -r._location.go(i,o)})),s},e.prototype.dispose=function(){p.isPresent(this._locationSub)&&(u.ObservableWrapper.dispose(this._locationSub),this._locationSub=null)},e=o([f.Injectable(),a(2,f.Inject(d.ROUTER_PRIMARY_COMPONENT)),s("design:paramtypes",[d.RouteRegistry,h.Location,p.Type])],e)}(g);e.RootRouter=_;var b=function(t){function e(e,n){t.call(this,e.registry,e,n,e.root),this.parent=e}return i(e,t),e.prototype.navigateByUrl=function(t,e){return void 0===e&&(e=!1),this.parent.navigateByUrl(t,e)},e.prototype.navigateByInstruction=function(t,e){return void 0===e&&(e=!1),this.parent.navigateByInstruction(t,e)},e}(g)},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}r(n(250))},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}r(n(251)),r(n(252)),r(n(253)),r(n(255)),r(n(254))},function(t,e){"use strict";var n=function(){function t(){}return Object.defineProperty(t.prototype,"pathname",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"search",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hash",{get:function(){return null},enumerable:!0,configurable:!0}),t}();e.PlatformLocation=n},function(t,e,n){"use strict";var r=n(5),i=n(2),o=function(){function t(){}return t}();e.LocationStrategy=o,e.APP_BASE_HREF=r.CONST_EXPR(new i.OpaqueToken("appBaseHref"))},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(2),u=n(252),c=n(254),p=n(251),l=n(5),h=function(t){function e(e,n){t.call(this),this._platformLocation=e,this._baseHref="",l.isPresent(n)&&(this._baseHref=n)}return r(e,t),e.prototype.onPopState=function(t){this._platformLocation.onPopState(t),this._platformLocation.onHashChange(t)},e.prototype.getBaseHref=function(){return this._baseHref},e.prototype.path=function(){var t=this._platformLocation.hash;return l.isPresent(t)||(t="#"),t.length>0?t.substring(1):t},e.prototype.prepareExternalUrl=function(t){var e=c.Location.joinWithSlash(this._baseHref,t);return e.length>0?"#"+e:e},e.prototype.pushState=function(t,e,n,r){var i=this.prepareExternalUrl(n+c.Location.normalizeQueryParams(r));0==i.length&&(i=this._platformLocation.pathname),this._platformLocation.pushState(t,e,i)},e.prototype.replaceState=function(t,e,n,r){var i=this.prepareExternalUrl(n+c.Location.normalizeQueryParams(r));0==i.length&&(i=this._platformLocation.pathname),this._platformLocation.replaceState(t,e,i)},e.prototype.forward=function(){this._platformLocation.forward()},e.prototype.back=function(){this._platformLocation.back()},e=i([a.Injectable(),s(1,a.Optional()),s(1,a.Inject(u.APP_BASE_HREF)),o("design:paramtypes",[p.PlatformLocation,String])],e)}(u.LocationStrategy);e.HashLocationStrategy=h},function(t,e,n){"use strict";function r(t,e){return t.length>0&&e.startsWith(t)?e.substring(t.length):e}function i(t){return/\/index.html$/g.test(t)?t.substring(0,t.length-11):t}var o=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},s=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},a=n(40),u=n(2),c=n(252),p=function(){function t(e){var n=this;this.platformStrategy=e,this._subject=new a.EventEmitter;var r=this.platformStrategy.getBaseHref();this._baseHref=t.stripTrailingSlash(i(r)),this.platformStrategy.onPopState(function(t){a.ObservableWrapper.callEmit(n._subject,{url:n.path(),pop:!0,type:t.type})})}return t.prototype.path=function(){return this.normalize(this.platformStrategy.path())},t.prototype.normalize=function(e){return t.stripTrailingSlash(r(this._baseHref,i(e)))},t.prototype.prepareExternalUrl=function(t){return t.length>0&&!t.startsWith("/")&&(t="/"+t),this.platformStrategy.prepareExternalUrl(t)},t.prototype.go=function(t,e){void 0===e&&(e=""),this.platformStrategy.pushState(null,"",t,e)},t.prototype.replaceState=function(t,e){void 0===e&&(e=""),this.platformStrategy.replaceState(null,"",t,e)},t.prototype.forward=function(){this.platformStrategy.forward()},t.prototype.back=function(){this.platformStrategy.back()},t.prototype.subscribe=function(t,e,n){return void 0===e&&(e=null),void 0===n&&(n=null),a.ObservableWrapper.subscribe(this._subject,t,e,n)},t.normalizeQueryParams=function(t){return t.length>0&&"?"!=t.substring(0,1)?"?"+t:t},t.joinWithSlash=function(t,e){if(0==t.length)return e;if(0==e.length)return t;var n=0;return t.endsWith("/")&&n++,e.startsWith("/")&&n++,2==n?t+e.substring(1):1==n?t+e:t+"/"+e},t.stripTrailingSlash=function(t){return/\/$/g.test(t)&&(t=t.substring(0,t.length-1)),t},t=o([u.Injectable(),s("design:paramtypes",[c.LocationStrategy])],t)}();e.Location=p},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},a=n(2),u=n(5),c=n(12),p=n(251),l=n(252),h=n(254),f=function(t){function e(e,n){if(t.call(this),this._platformLocation=e,u.isBlank(n)&&(n=this._platformLocation.getBaseHrefFromDOM()),u.isBlank(n))throw new c.BaseException("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");this._baseHref=n}return r(e,t),e.prototype.onPopState=function(t){this._platformLocation.onPopState(t),this._platformLocation.onHashChange(t)},e.prototype.getBaseHref=function(){return this._baseHref},e.prototype.prepareExternalUrl=function(t){return h.Location.joinWithSlash(this._baseHref,t)},e.prototype.path=function(){return this._platformLocation.pathname+h.Location.normalizeQueryParams(this._platformLocation.search)},e.prototype.pushState=function(t,e,n,r){var i=this.prepareExternalUrl(n+h.Location.normalizeQueryParams(r));this._platformLocation.pushState(t,e,i)},e.prototype.replaceState=function(t,e,n,r){var i=this.prepareExternalUrl(n+h.Location.normalizeQueryParams(r));this._platformLocation.replaceState(t,e,i)},e.prototype.forward=function(){this._platformLocation.forward()},e.prototype.back=function(){this._platformLocation.back()},e=i([a.Injectable(),s(1,a.Optional()),s(1,a.Inject(l.APP_BASE_HREF)),o("design:paramtypes",[p.PlatformLocation,String])],e)}(l.LocationStrategy);e.PathLocationStrategy=f},function(t,e,n){"use strict";function r(t){var e=[];return t.forEach(function(t){if(h.isString(t)){var n=t;e=e.concat(n.split("/"))}else e.push(t)}),e}function i(t){if(t=t.filter(function(t){return h.isPresent(t)}),0==t.length)return null;if(1==t.length)return t[0];var e=t[0],n=t.slice(1);return n.reduce(function(t,e){return-1==o(e.specificity,t.specificity)?e:t},e)}function o(t,e){for(var n=h.Math.min(t.length,e.length),r=0;n>r;r+=1){var i=h.StringWrapper.charCodeAt(t,r),o=h.StringWrapper.charCodeAt(e,r),s=o-i;if(0!=s)return s}return t.length-e.length}function s(t,e){if(h.isType(t)){var n=d.reflector.annotations(t);if(h.isPresent(n))for(var r=0;ro?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},u=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},c=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},p=n(15),l=n(40),h=n(5),f=n(12),d=n(18),v=n(2),y=n(257),m=n(258),g=n(261),_=n(260),b=n(268),P=n(259),E=l.PromiseWrapper.resolve(null);e.ROUTER_PRIMARY_COMPONENT=h.CONST_EXPR(new v.OpaqueToken("RouterPrimaryComponent"));var w=function(){function t(t){this._rootComponent=t,this._rules=new p.Map}return t.prototype.config=function(t,e){e=b.normalizeRouteConfig(e,this),e instanceof y.Route?b.assertComponentExists(e.component,e.path):e instanceof y.AuxRoute&&b.assertComponentExists(e.component,e.path);var n=this._rules.get(t);h.isBlank(n)&&(n=new g.RuleSet,this._rules.set(t,n));var r=n.config(e);e instanceof y.Route&&(r?s(e.component,e.path):this.configFromComponent(e.component))},t.prototype.configFromComponent=function(t){var e=this;if(h.isType(t)&&!this._rules.has(t)){var n=d.reflector.annotations(t);if(h.isPresent(n))for(var r=0;r0?[p.ListWrapper.last(e)]:[],i=r._auxRoutesToUnresolved(t.remainingAux,n),o=new _.ResolvedInstruction(t.instruction,null,i);if(h.isBlank(t.instruction)||t.instruction.terminal)return o;var s=e.concat([o]);return r._recognize(t.remaining,s).then(function(t){return h.isBlank(t)?null:t instanceof _.RedirectInstruction?t:(o.child=t,o)})}if(t instanceof m.RedirectMatch){var o=r.generate(t.redirectTo,e.concat([null]));return new _.RedirectInstruction(o.component,o.child,o.auxInstruction,t.specificity)}})});return!h.isBlank(t)&&""!=t.path||0!=u.length?l.PromiseWrapper.all(c).then(i):l.PromiseWrapper.resolve(this.generateDefault(s))},t.prototype._auxRoutesToUnresolved=function(t,e){var n=this,r={};return t.forEach(function(t){r[t.path]=new _.UnresolvedInstruction(function(){return n._recognize(t,e,!0)})}),r},t.prototype.generate=function(t,e,n){void 0===n&&(n=!1);var i,o=r(t);if(""==p.ListWrapper.first(o))o.shift(),i=p.ListWrapper.first(e),e=[];else if(i=e.length>0?e.pop():null,"."==p.ListWrapper.first(o))o.shift();else if(".."==p.ListWrapper.first(o))for(;".."==p.ListWrapper.first(o);){if(e.length<=0)throw new f.BaseException('Link "'+p.ListWrapper.toJSON(t)+'" has too many "../" segments.');i=e.pop(),o=p.ListWrapper.slice(o,1)}else{var s=p.ListWrapper.first(o),a=this._rootComponent,u=null;if(e.length>1){var c=e[e.length-1],l=e[e.length-2];a=c.component.componentType,u=l.component.componentType}else 1==e.length&&(a=e[0].component.componentType,u=this._rootComponent);var d=this.hasRoute(s,a),v=h.isPresent(u)&&this.hasRoute(s,u);if(v&&d){var y='Link "'+p.ListWrapper.toJSON(t)+'" is ambiguous, use "./" or "../" to disambiguate.';throw new f.BaseException(y)}v&&(i=e.pop())}if(""==o[o.length-1]&&o.pop(),o.length>0&&""==o[0]&&o.shift(),o.length<1){var y='Link "'+p.ListWrapper.toJSON(t)+'" must include a route name.';throw new f.BaseException(y)}for(var m=this._generate(o,e,i,n,t),g=e.length-1;g>=0;g--){var _=e[g];if(h.isBlank(_))break;m=_.replaceChild(m)}return m},t.prototype._generate=function(t,e,n,r,i){var o=this;void 0===r&&(r=!1);var s=this._rootComponent,a=null,u={},c=p.ListWrapper.last(e);if(h.isPresent(c)&&h.isPresent(c.component)&&(s=c.component.componentType),0==t.length){var l=this.generateDefault(s);if(h.isBlank(l))throw new f.BaseException('Link "'+p.ListWrapper.toJSON(i)+'" does not resolve to a terminal instruction.');return l}h.isPresent(n)&&!r&&(u=p.StringMapWrapper.merge(n.auxInstruction,u),a=n.component);var d=this._rules.get(s);if(h.isBlank(d))throw new f.BaseException('Component "'+h.getTypeNameForDebugging(s)+'" has no route config.');var v=0,y={};if(v=t.length;else{var O=e.concat([R]),T=t.slice(v);S=this._generate(T,O,null,!1,i)}R.child=S}return R},t.prototype.hasRoute=function(t,e){var n=this._rules.get(e);return h.isBlank(n)?!1:n.hasRoute(t)},t.prototype.generateDefault=function(t){var e=this;if(h.isBlank(t))return null;var n=this._rules.get(t);if(h.isBlank(n)||h.isBlank(n.defaultRule))return null;var r=null;if(h.isPresent(n.defaultRule.handler.componentType)){var i=n.defaultRule.generate({});return n.defaultRule.terminal||(r=this.generateDefault(n.defaultRule.handler.componentType)),new _.DefaultInstruction(i,r)}return new _.UnresolvedInstruction(function(){return n.defaultRule.handler.resolveComponentType().then(function(n){return e.generateDefault(t)})})},t=a([v.Injectable(),c(0,v.Inject(e.ROUTER_PRIMARY_COMPONENT)),u("design:paramtypes",[h.Type])],t)}();e.RouteRegistry=w},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(5),a=function(){function t(t){this.configs=t}return t=i([s.CONST(),o("design:paramtypes",[Array])],t)}();e.RouteConfig=a;var u=function(){function t(t){var e=t.name,n=t.useAsDefault,r=t.path,i=t.regex,o=t.serializer,s=t.data;this.name=e,this.useAsDefault=n,this.path=r,this.regex=i,this.serializer=o,this.data=s}return t=i([s.CONST(),o("design:paramtypes",[Object])],t)}();e.AbstractRoute=u;var c=function(t){function e(e){var n=e.name,r=e.useAsDefault,i=e.path,o=e.regex,s=e.serializer,a=e.data,u=e.component;t.call(this,{name:n,useAsDefault:r,path:i,regex:o,serializer:s,data:a}),this.aux=null,this.component=u}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object])],e)}(u);e.Route=c;var p=function(t){function e(e){var n=e.name,r=e.useAsDefault,i=e.path,o=e.regex,s=e.serializer,a=e.data,u=e.component;t.call(this,{name:n,useAsDefault:r,path:i,regex:o,serializer:s,data:a}),this.component=u}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object])],e)}(u);e.AuxRoute=p;var l=function(t){function e(e){var n=e.name,r=e.useAsDefault,i=e.path,o=e.regex,s=e.serializer,a=e.data,u=e.loader;t.call(this,{name:n,useAsDefault:r,path:i,regex:o,serializer:s,data:a}),this.aux=null,this.loader=u}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object])],e)}(u);e.AsyncRoute=l;var h=function(t){function e(e){var n=e.name,r=e.useAsDefault,i=e.path,o=e.regex,s=e.serializer,a=e.data,u=e.redirectTo;t.call(this,{name:n,useAsDefault:r,path:i,regex:o,serializer:s,data:a}),this.redirectTo=u}return r(e,t),e=i([s.CONST(),o("design:paramtypes",[Object])],e)}(u);e.Redirect=h},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(12),s=n(41),a=n(15),u=n(259),c=n(260),p=function(){function t(){}return t}();e.RouteMatch=p;var l=function(t){function e(e,n,r){t.call(this),this.instruction=e,this.remaining=n,this.remainingAux=r}return r(e,t),e}(p);e.PathMatch=l;var h=function(t){function e(e,n){t.call(this),this.redirectTo=e,this.specificity=n}return r(e,t),e}(p);e.RedirectMatch=h;var f=function(){function t(t,e){this._pathRecognizer=t,this.redirectTo=e,this.hash=this._pathRecognizer.hash}return Object.defineProperty(t.prototype,"path",{get:function(){return this._pathRecognizer.toString()},set:function(t){throw new o.BaseException("you cannot set the path of a RedirectRule directly")},enumerable:!0,configurable:!0}),t.prototype.recognize=function(t){var e=null;return i.isPresent(this._pathRecognizer.matchUrl(t))&&(e=new h(this.redirectTo,this._pathRecognizer.specificity)),s.PromiseWrapper.resolve(e)},t.prototype.generate=function(t){throw new o.BaseException("Tried to generate a redirect.")},t}();e.RedirectRule=f;var d=function(){function t(t,e,n){this._routePath=t,this.handler=e,this._routeName=n,this._cache=new a.Map,this.specificity=this._routePath.specificity,this.hash=this._routePath.hash,this.terminal=this._routePath.terminal}return Object.defineProperty(t.prototype,"path",{get:function(){return this._routePath.toString()},set:function(t){throw new o.BaseException("you cannot set the path of a RouteRule directly")},enumerable:!0,configurable:!0}),t.prototype.recognize=function(t){var e=this,n=this._routePath.matchUrl(t);return i.isBlank(n)?null:this.handler.resolveComponentType().then(function(t){var r=e._getInstruction(n.urlPath,n.urlParams,n.allParams);return new l(r,n.rest,n.auxiliary)})},t.prototype.generate=function(t){var e=this._routePath.generateUrl(t),n=e.urlPath,r=e.urlParams;return this._getInstruction(n,u.convertUrlParamsToArray(r),t)},t.prototype.generateComponentPathValues=function(t){return this._routePath.generateUrl(t)},t.prototype._getInstruction=function(t,e,n){if(i.isBlank(this.handler.componentType))throw new o.BaseException("Tried to get instruction before the type was loaded.");var r=t+"?"+e.join("&");if(this._cache.has(r))return this._cache.get(r);var s=new c.ComponentInstruction(t,e,this.handler.data,this.handler.componentType,this.terminal,this.specificity,n,this._routeName);return this._cache.set(r,s),s},t}();e.RouteRule=d},function(t,e,n){"use strict";function r(t){var e=[];return p.isBlank(t)?[]:(c.StringMapWrapper.forEach(t,function(t,n){e.push(t===!0?n:n+"="+t)}),e)}function i(t,e){return void 0===e&&(e="&"),r(t).join(e)}function o(t){for(var e=new h(t[t.length-1]),n=t.length-2;n>=0;n-=1)e=new h(t[n],e);return e}function s(t){var e=p.RegExpWrapper.firstMatch(d,t);return p.isPresent(e)?e[0]:""}function a(t){var e=p.RegExpWrapper.firstMatch(v,t);return p.isPresent(e)?e[0]:""}var u=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},c=n(15),p=n(5),l=n(12);e.convertUrlParamsToArray=r,e.serializeParams=i;var h=function(){function t(t,e,n,r){void 0===e&&(e=null),void 0===n&&(n=p.CONST_EXPR([])),void 0===r&&(r=p.CONST_EXPR({})),this.path=t,this.child=e,this.auxiliary=n,this.params=r}return t.prototype.toString=function(){return this.path+this._matrixParamsToString()+this._auxToString()+this._childString()},t.prototype.segmentToString=function(){return this.path+this._matrixParamsToString()},t.prototype._auxToString=function(){return this.auxiliary.length>0?"("+this.auxiliary.map(function(t){return t.toString()}).join("//")+")":""},t.prototype._matrixParamsToString=function(){var t=i(this.params,";");return t.length>0?";"+t:""},t.prototype._childString=function(){return p.isPresent(this.child)?"/"+this.child.toString():""},t}();e.Url=h;var f=function(t){function e(e,n,r,i){void 0===n&&(n=null),void 0===r&&(r=p.CONST_EXPR([])),void 0===i&&(i=null),t.call(this,e,n,r,i)}return u(e,t),e.prototype.toString=function(){return this.path+this._auxToString()+this._childString()+this._queryParamsToString()},e.prototype.segmentToString=function(){return this.path+this._queryParamsToString()},e.prototype._queryParamsToString=function(){return p.isBlank(this.params)?"":"?"+i(this.params)},e}(h);e.RootUrl=f,e.pathSegmentsToUrl=o;var d=p.RegExpWrapper.create("^[^\\/\\(\\)\\?;=&#]+"),v=p.RegExpWrapper.create("^[^\\(\\)\\?;&#]+"),y=function(){function t(){}return t.prototype.peekStartsWith=function(t){return this._remaining.startsWith(t)},t.prototype.capture=function(t){if(!this._remaining.startsWith(t))throw new l.BaseException('Expected "'+t+'".');this._remaining=this._remaining.substring(t.length)},t.prototype.parse=function(t){return this._remaining=t,""==t||"/"==t?new h(""):this.parseRoot()},t.prototype.parseRoot=function(){this.peekStartsWith("/")&&this.capture("/");var t=s(this._remaining);this.capture(t);var e=[];this.peekStartsWith("(")&&(e=this.parseAuxiliaryRoutes()),this.peekStartsWith(";")&&this.parseMatrixParams();var n=null;this.peekStartsWith("/")&&!this.peekStartsWith("//")&&(this.capture("/"),n=this.parseSegment());var r=null;return this.peekStartsWith("?")&&(r=this.parseQueryParams()),new f(t,n,e,r)},t.prototype.parseSegment=function(){if(0==this._remaining.length)return null;this.peekStartsWith("/")&&this.capture("/");var t=s(this._remaining);this.capture(t);var e=null;this.peekStartsWith(";")&&(e=this.parseMatrixParams());var n=[];this.peekStartsWith("(")&&(n=this.parseAuxiliaryRoutes());var r=null;return this.peekStartsWith("/")&&!this.peekStartsWith("//")&&(this.capture("/"),r=this.parseSegment()),new h(t,r,n,e)},t.prototype.parseQueryParams=function(){var t={};for(this.capture("?"),this.parseQueryParam(t);this._remaining.length>0&&this.peekStartsWith("&");)this.capture("&"),this.parseQueryParam(t);return t},t.prototype.parseMatrixParams=function(){for(var t={};this._remaining.length>0&&this.peekStartsWith(";");)this.capture(";"),this.parseParam(t);return t},t.prototype.parseParam=function(t){var e=s(this._remaining);if(!p.isBlank(e)){this.capture(e);var n=!0;if(this.peekStartsWith("=")){this.capture("=");var r=s(this._remaining);p.isPresent(r)&&(n=r,this.capture(n))}t[e]=n}},t.prototype.parseQueryParam=function(t){var e=s(this._remaining);if(!p.isBlank(e)){this.capture(e);var n=!0;if(this.peekStartsWith("=")){this.capture("=");var r=a(this._remaining);p.isPresent(r)&&(n=r,this.capture(n))}t[e]=n}},t.prototype.parseAuxiliaryRoutes=function(){var t=[];for(this.capture("(");!this.peekStartsWith(")")&&this._remaining.length>0;)t.push(this.parseSegment()),this.peekStartsWith("//")&&this.capture("//");return this.capture(")"),t},t}();e.UrlParser=y,e.parser=new y},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(15),o=n(5),s=n(40),a=function(){function t(t){this.params=t}return t.prototype.get=function(t){return o.normalizeBlank(i.StringMapWrapper.get(this.params,t))},t}();e.RouteParams=a;var u=function(){function t(t){void 0===t&&(t=o.CONST_EXPR({})),this.data=t}return t.prototype.get=function(t){return o.normalizeBlank(i.StringMapWrapper.get(this.data,t))},t}();e.RouteData=u,e.BLANK_ROUTE_DATA=new u;var c=function(){function t(t,e,n){this.component=t,this.child=e,this.auxInstruction=n}return Object.defineProperty(t.prototype,"urlPath",{get:function(){return o.isPresent(this.component)?this.component.urlPath:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"urlParams",{get:function(){return o.isPresent(this.component)?this.component.urlParams:[]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"specificity",{get:function(){var t="";return o.isPresent(this.component)&&(t+=this.component.specificity),o.isPresent(this.child)&&(t+=this.child.specificity),t},enumerable:!0,configurable:!0}),t.prototype.toRootUrl=function(){return this.toUrlPath()+this.toUrlQuery()},t.prototype._toNonRootUrl=function(){return this._stringifyPathMatrixAuxPrefixed()+(o.isPresent(this.child)?this.child._toNonRootUrl():"")},t.prototype.toUrlQuery=function(){return this.urlParams.length>0?"?"+this.urlParams.join("&"):""},t.prototype.replaceChild=function(t){return new p(this.component,t,this.auxInstruction)},t.prototype.toUrlPath=function(){return this.urlPath+this._stringifyAux()+(o.isPresent(this.child)?this.child._toNonRootUrl():"")},t.prototype.toLinkUrl=function(){return this.urlPath+this._stringifyAux()+(o.isPresent(this.child)?this.child._toLinkUrl():"")+this.toUrlQuery()},t.prototype._toLinkUrl=function(){return this._stringifyPathMatrixAuxPrefixed()+(o.isPresent(this.child)?this.child._toLinkUrl():"")},t.prototype._stringifyPathMatrixAuxPrefixed=function(){var t=this._stringifyPathMatrixAux();return t.length>0&&(t="/"+t),t},t.prototype._stringifyMatrixParams=function(){return this.urlParams.length>0?";"+this.urlParams.join(";"):""},t.prototype._stringifyPathMatrixAux=function(){return o.isBlank(this.component)?"":this.urlPath+this._stringifyMatrixParams()+this._stringifyAux()},t.prototype._stringifyAux=function(){var t=[];return i.StringMapWrapper.forEach(this.auxInstruction,function(e,n){t.push(e._stringifyPathMatrixAux())}),t.length>0?"("+t.join("//")+")":""},t}();e.Instruction=c;var p=function(t){function e(e,n,r){t.call(this,e,n,r)}return r(e,t),e.prototype.resolveComponent=function(){return s.PromiseWrapper.resolve(this.component)},e}(c);e.ResolvedInstruction=p;var l=function(t){function e(e,n){t.call(this,e,n,{})}return r(e,t),e.prototype.toLinkUrl=function(){return""},e.prototype._toLinkUrl=function(){return""},e}(p);e.DefaultInstruction=l;var h=function(t){function e(e,n,r){void 0===n&&(n=""),void 0===r&&(r=o.CONST_EXPR([])),t.call(this,null,null,{}),this._resolver=e,this._urlPath=n,this._urlParams=r}return r(e,t),Object.defineProperty(e.prototype,"urlPath",{get:function(){return o.isPresent(this.component)?this.component.urlPath:o.isPresent(this._urlPath)?this._urlPath:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"urlParams",{get:function(){return o.isPresent(this.component)?this.component.urlParams:o.isPresent(this._urlParams)?this._urlParams:[]},enumerable:!0,configurable:!0}),e.prototype.resolveComponent=function(){var t=this;return o.isPresent(this.component)?s.PromiseWrapper.resolve(this.component):this._resolver().then(function(e){return t.child=o.isPresent(e)?e.child:null,t.component=o.isPresent(e)?e.component:null})},e}(c);e.UnresolvedInstruction=h;var f=function(t){function e(e,n,r,i){t.call(this,e,n,r),this._specificity=i}return r(e,t),Object.defineProperty(e.prototype,"specificity",{get:function(){return this._specificity},enumerable:!0,configurable:!0}),e}(p);e.RedirectInstruction=f;var d=function(){function t(t,n,r,i,s,a,u,c){void 0===u&&(u=null),this.urlPath=t,this.urlParams=n,this.componentType=i,this.terminal=s,this.specificity=a,this.params=u,this.routeName=c,this.reuse=!1,this.routeData=o.isPresent(r)?r:e.BLANK_ROUTE_DATA}return t}();e.ComponentInstruction=d},function(t,e,n){"use strict";var r=n(5),i=n(12),o=n(15),s=n(40),a=n(258),u=n(257),c=n(262),p=n(263),l=n(264),h=n(267),f=function(){function t(){this.rulesByName=new o.Map,this.auxRulesByName=new o.Map,this.auxRulesByPath=new o.Map,this.rules=[],this.defaultRule=null}return t.prototype.config=function(t){var e;if(r.isPresent(t.name)&&t.name[0].toUpperCase()!=t.name[0]){var n=t.name[0].toUpperCase()+t.name.substring(1);throw new i.BaseException('Route "'+t.path+'" with name "'+t.name+'" does not begin with an uppercase letter. Route names should be CamelCase like "'+n+'".')}if(t instanceof u.AuxRoute){e=new p.SyncRouteHandler(t.component,t.data);var o=this._getRoutePath(t),s=new a.RouteRule(o,e,t.name);return this.auxRulesByPath.set(o.toString(),s),r.isPresent(t.name)&&this.auxRulesByName.set(t.name,s),s.terminal}var l=!1;if(t instanceof u.Redirect){var h=this._getRoutePath(t),f=new a.RedirectRule(h,t.redirectTo);return this._assertNoHashCollision(f.hash,t.path),this.rules.push(f),!0}t instanceof u.Route?(e=new p.SyncRouteHandler(t.component,t.data),l=r.isPresent(t.useAsDefault)&&t.useAsDefault):t instanceof u.AsyncRoute&&(e=new c.AsyncRouteHandler(t.loader,t.data),l=r.isPresent(t.useAsDefault)&&t.useAsDefault);var d=this._getRoutePath(t),v=new a.RouteRule(d,e,t.name);if(this._assertNoHashCollision(v.hash,t.path),l){if(r.isPresent(this.defaultRule))throw new i.BaseException("Only one route can be default");this.defaultRule=v}return this.rules.push(v),r.isPresent(t.name)&&this.rulesByName.set(t.name,v),v.terminal},t.prototype.recognize=function(t){var e=[];return this.rules.forEach(function(n){var i=n.recognize(t);r.isPresent(i)&&e.push(i)}),0==e.length&&r.isPresent(t)&&t.auxiliary.length>0?[s.PromiseWrapper.resolve(new a.PathMatch(null,null,t.auxiliary))]:e},t.prototype.recognizeAuxiliary=function(t){var e=this.auxRulesByPath.get(t.path);return r.isPresent(e)?[e.recognize(t)]:[s.PromiseWrapper.resolve(null)]},t.prototype.hasRoute=function(t){return this.rulesByName.has(t)},t.prototype.componentLoaded=function(t){return this.hasRoute(t)&&r.isPresent(this.rulesByName.get(t).handler.componentType)},t.prototype.loadComponent=function(t){return this.rulesByName.get(t).handler.resolveComponentType()},t.prototype.generate=function(t,e){var n=this.rulesByName.get(t);return r.isBlank(n)?null:n.generate(e)},t.prototype.generateAuxiliary=function(t,e){var n=this.auxRulesByName.get(t);return r.isBlank(n)?null:n.generate(e)},t.prototype._assertNoHashCollision=function(t,e){this.rules.forEach(function(n){if(t==n.hash)throw new i.BaseException("Configuration '"+e+"' conflicts with existing route '"+n.path+"'")})},t.prototype._getRoutePath=function(t){if(r.isPresent(t.regex)){if(r.isFunction(t.serializer))return new h.RegexRoutePath(t.regex,t.serializer);throw new i.BaseException("Route provides a regex property, '"+t.regex+"', but no serializer property")}if(r.isPresent(t.path)){var e=t instanceof u.AuxRoute&&t.path.startsWith("/")?t.path.substring(1):t.path;return new l.ParamRoutePath(e)}throw new i.BaseException("Route must provide either a path or regex property")},t}();e.RuleSet=f},function(t,e,n){"use strict";var r=n(5),i=n(260),o=function(){function t(t,e){void 0===e&&(e=null),this._loader=t,this._resolvedComponent=null,this.data=r.isPresent(e)?new i.RouteData(e):i.BLANK_ROUTE_DATA}return t.prototype.resolveComponentType=function(){ -var t=this;return r.isPresent(this._resolvedComponent)?this._resolvedComponent:this._resolvedComponent=this._loader().then(function(e){return t.componentType=e,e})},t}();e.AsyncRouteHandler=o},function(t,e,n){"use strict";var r=n(40),i=n(5),o=n(260),s=function(){function t(t,e){this.componentType=t,this._resolvedComponent=null,this._resolvedComponent=r.PromiseWrapper.resolve(t),this.data=i.isPresent(e)?new o.RouteData(e):o.BLANK_ROUTE_DATA}return t.prototype.resolveComponentType=function(){return this._resolvedComponent},t}();e.SyncRouteHandler=s},function(t,e,n){"use strict";function r(t){return o.isBlank(t)?null:(t=o.StringWrapper.replaceAll(t,y,"%25"),t=o.StringWrapper.replaceAll(t,m,"%2F"),t=o.StringWrapper.replaceAll(t,g,"%28"),t=o.StringWrapper.replaceAll(t,_,"%29"),t=o.StringWrapper.replaceAll(t,b,"%3B"))}function i(t){return o.isBlank(t)?null:(t=o.StringWrapper.replaceAll(t,P,";"),t=o.StringWrapper.replaceAll(t,E,")"),t=o.StringWrapper.replaceAll(t,w,"("),t=o.StringWrapper.replaceAll(t,C,"/"),t=o.StringWrapper.replaceAll(t,R,"%"))}var o=n(5),s=n(12),a=n(15),u=n(265),c=n(259),p=n(266),l=function(){function t(){this.name="",this.specificity="",this.hash="..."}return t.prototype.generate=function(t){return""},t.prototype.match=function(t){return!0},t}(),h=function(){function t(t){this.path=t,this.name="",this.specificity="2",this.hash=t}return t.prototype.match=function(t){return t==this.path},t.prototype.generate=function(t){return this.path},t}(),f=function(){function t(t){this.name=t,this.specificity="1",this.hash=":"}return t.prototype.match=function(t){return t.length>0},t.prototype.generate=function(t){if(!a.StringMapWrapper.contains(t.map,this.name))throw new s.BaseException("Route generator for '"+this.name+"' was not included in parameters passed.");return r(u.normalizeString(t.get(this.name)))},t.paramMatcher=/^:([^\/]+)$/g,t}(),d=function(){function t(t){this.name=t,this.specificity="0",this.hash="*"}return t.prototype.match=function(t){return!0},t.prototype.generate=function(t){return u.normalizeString(t.get(this.name))},t.wildcardMatcher=/^\*([^\/]+)$/g,t}(),v=function(){function t(t){this.routePath=t,this.terminal=!0,this._assertValidPath(t),this._parsePathString(t),this.specificity=this._calculateSpecificity(),this.hash=this._calculateHash();var e=this._segments[this._segments.length-1];this.terminal=!(e instanceof l)}return t.prototype.matchUrl=function(t){for(var e,n=t,r={},s=[],u=0;u=r;r++){var i,a=e[r];if(o.isPresent(i=o.RegExpWrapper.firstMatch(f.paramMatcher,a)))this._segments.push(new f(i[1]));else if(o.isPresent(i=o.RegExpWrapper.firstMatch(d.wildcardMatcher,a)))this._segments.push(new d(i[1]));else if("..."==a){if(n>r)throw new s.BaseException('Unexpected "..." before the end of the path for "'+t+'".');this._segments.push(new l)}else this._segments.push(new h(a))}},t.prototype._calculateSpecificity=function(){var t,e,n=this._segments.length;if(0==n)e+="2";else for(e="",t=0;n>t;t++)e+=this._segments[t].specificity;return e},t.prototype._calculateHash=function(){var t,e=this._segments.length,n=[];for(t=0;e>t;t++)n.push(this._segments[t].hash);return n.join("/")},t.prototype._assertValidPath=function(e){if(o.StringWrapper.contains(e,"#"))throw new s.BaseException('Path "'+e+'" should not include "#". Use "HashLocationStrategy" instead.');var n=o.RegExpWrapper.firstMatch(t.RESERVED_CHARS,e);if(o.isPresent(n))throw new s.BaseException('Path "'+e+'" contains "'+n[0]+'" which is not allowed in a route config.')},t.RESERVED_CHARS=o.RegExpWrapper.create("//|\\(|\\)|;|\\?|="),t}();e.ParamRoutePath=v;var y=/%/g,m=/\//g,g=/\(/g,_=/\)/g,b=/;/g,P=/%3B/gi,E=/%29/gi,w=/%28/gi,C=/%2F/gi,R=/%25/gi},function(t,e,n){"use strict";function r(t){return i.isBlank(t)?null:t.toString()}var i=n(5),o=n(15),s=function(){function t(t){var e=this;this.map={},this.keys={},i.isPresent(t)&&o.StringMapWrapper.forEach(t,function(t,n){e.map[n]=i.isPresent(t)?t.toString():null,e.keys[n]=!0})}return t.prototype.get=function(t){return o.StringMapWrapper["delete"](this.keys,t),this.map[t]},t.prototype.getUnused=function(){var t=this,e={},n=o.StringMapWrapper.keys(this.keys);return n.forEach(function(n){return e[n]=o.StringMapWrapper.get(t.map,n)}),e},t}();e.TouchMap=s,e.normalizeString=r},function(t,e){"use strict";var n=function(){function t(t,e,n,r,i){this.urlPath=t,this.urlParams=e,this.allParams=n,this.auxiliary=r,this.rest=i}return t}();e.MatchedUrl=n;var r=function(){function t(t,e){this.urlPath=t,this.urlParams=e}return t}();e.GeneratedUrl=r},function(t,e,n){"use strict";var r=n(5),i=n(266),o=function(){function t(t,e){this._reString=t,this._serializer=e,this.terminal=!0,this.specificity="2",this.hash=this._reString,this._regex=r.RegExpWrapper.create(this._reString)}return t.prototype.matchUrl=function(t){var e=t.toString(),n={},o=r.RegExpWrapper.matcher(this._regex,e),s=r.RegExpMatcherWrapper.next(o);if(r.isBlank(s))return null;for(var a=0;ao?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(5),s=function(){function t(t){this.name=t}return t=r([o.CONST(),i("design:paramtypes",[String])],t)}();e.RouteLifecycleHook=s;var a=function(){function t(t){this.fn=t}return t=r([o.CONST(),i("design:paramtypes",[Function])],t)}();e.CanActivate=a,e.routerCanReuse=o.CONST_EXPR(new s("routerCanReuse")),e.routerCanDeactivate=o.CONST_EXPR(new s("routerCanDeactivate")),e.routerOnActivate=o.CONST_EXPR(new s("routerOnActivate")),e.routerOnReuse=o.CONST_EXPR(new s("routerOnReuse")),e.routerOnDeactivate=o.CONST_EXPR(new s("routerOnDeactivate"))},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=this&&this.__param||function(t,e){return function(n,r){e(n,r,t)}},s=n(40),a=n(15),u=n(5),c=n(2),p=n(248),l=n(260),h=n(273),f=n(270),d=s.PromiseWrapper.resolve(!0),v=function(){function t(t,e,n,r){this._viewContainerRef=t,this._loader=e,this._parentRouter=n,this.name=null,this._componentRef=null,this._currentInstruction=null,this.activateEvents=new s.EventEmitter,u.isPresent(r)?(this.name=r,this._parentRouter.registerAuxOutlet(this)):this._parentRouter.registerPrimaryOutlet(this)}return t.prototype.activate=function(t){var e=this,n=this._currentInstruction;this._currentInstruction=t;var r=t.componentType,i=this._parentRouter.childRouter(r),o=c.ReflectiveInjector.resolve([c.provide(l.RouteData,{useValue:t.routeData}),c.provide(l.RouteParams,{useValue:new l.RouteParams(t.params)}),c.provide(p.Router,{useValue:i})]);return this._componentRef=this._loader.loadNextToLocation(r,this._viewContainerRef,o),this._componentRef.then(function(i){return e.activateEvents.emit(i.instance),f.hasLifecycleHook(h.routerOnActivate,r)?e._componentRef.then(function(e){return e.instance.routerOnActivate(t,n)}):i})},t.prototype.reuse=function(t){var e=this._currentInstruction;return this._currentInstruction=t,u.isBlank(this._componentRef)?this.activate(t):s.PromiseWrapper.resolve(f.hasLifecycleHook(h.routerOnReuse,this._currentInstruction.componentType)?this._componentRef.then(function(n){return n.instance.routerOnReuse(t,e)}):!0)},t.prototype.deactivate=function(t){var e=this,n=d;return u.isPresent(this._componentRef)&&u.isPresent(this._currentInstruction)&&f.hasLifecycleHook(h.routerOnDeactivate,this._currentInstruction.componentType)&&(n=this._componentRef.then(function(n){return n.instance.routerOnDeactivate(t,e._currentInstruction)})),n.then(function(t){if(u.isPresent(e._componentRef)){var n=e._componentRef.then(function(t){return t.destroy()});return e._componentRef=null,n}})},t.prototype.routerCanDeactivate=function(t){var e=this;return u.isBlank(this._currentInstruction)?d:f.hasLifecycleHook(h.routerCanDeactivate,this._currentInstruction.componentType)?this._componentRef.then(function(n){return n.instance.routerCanDeactivate(t,e._currentInstruction)}):d},t.prototype.routerCanReuse=function(t){var e,n=this;return e=u.isBlank(this._currentInstruction)||this._currentInstruction.componentType!=t.componentType?!1:f.hasLifecycleHook(h.routerCanReuse,this._currentInstruction.componentType)?this._componentRef.then(function(e){return e.instance.routerCanReuse(t,n._currentInstruction)}):t==this._currentInstruction||u.isPresent(t.params)&&u.isPresent(this._currentInstruction.params)&&a.StringMapWrapper.equals(t.params,this._currentInstruction.params),s.PromiseWrapper.resolve(e)},t.prototype.ngOnDestroy=function(){this._parentRouter.unregisterPrimaryOutlet(this)},r([c.Output("activate"),i("design:type",Object)],t.prototype,"activateEvents",void 0),t=r([c.Directive({selector:"router-outlet"}),o(3,c.Attribute("name")),i("design:paramtypes",[c.ViewContainerRef,c.DynamicComponentLoader,p.Router,String])],t)}();e.RouterOutlet=v},function(t,e,n){"use strict";var r=n(9),i=n(271),o=n(271);e.routerCanReuse=o.routerCanReuse,e.routerCanDeactivate=o.routerCanDeactivate,e.routerOnActivate=o.routerOnActivate,e.routerOnReuse=o.routerOnReuse,e.routerOnDeactivate=o.routerOnDeactivate,e.CanActivate=r.makeDecorator(i.CanActivate)},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},o=n(2),s=n(249),a=n(5),u=n(248),c=function(){function t(t,e){var n=this;this._router=t,this._location=e,this._router.subscribe(function(t){return n._updateLink()})}return t.prototype._updateLink=function(){this._navigationInstruction=this._router.generate(this._routeParams);var t=this._navigationInstruction.toLinkUrl();this.visibleHref=this._location.prepareExternalUrl(t)},Object.defineProperty(t.prototype,"isRouteActive",{get:function(){return this._router.isRouteActive(this._navigationInstruction)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"routeParams",{set:function(t){this._routeParams=t,this._updateLink()},enumerable:!0,configurable:!0}),t.prototype.onClick=function(){return a.isString(this.target)&&"_self"!=this.target?!0:(this._router.navigateByInstruction(this._navigationInstruction),!1)},t=r([o.Directive({selector:"[routerLink]",inputs:["routeParams: routerLink","target: target"],host:{"(click)":"onClick()","[attr.href]":"visibleHref","[class.router-link-active]":"isRouteActive"}}),i("design:paramtypes",[u.Router,s.Location])],t)}();e.RouterLink=c},function(t,e,n){"use strict";function r(t,e,n,r){var i=new s.RootRouter(t,e,n);return r.registerDisposeListener(function(){return i.dispose()}),i}function i(t){if(0==t.componentTypes.length)throw new p.BaseException("Bootstrap at least one component before injecting Router.");return t.componentTypes[0]}var o=n(249),s=n(248),a=n(256),u=n(5),c=n(2),p=n(12);e.ROUTER_PROVIDERS_COMMON=u.CONST_EXPR([a.RouteRegistry,u.CONST_EXPR(new c.Provider(o.LocationStrategy,{useClass:o.PathLocationStrategy})),o.Location,u.CONST_EXPR(new c.Provider(s.Router,{useFactory:r,deps:u.CONST_EXPR([a.RouteRegistry,o.Location,a.ROUTER_PRIMARY_COMPONENT,c.ApplicationRef])})),u.CONST_EXPR(new c.Provider(a.ROUTER_PRIMARY_COMPONENT,{useFactory:i,deps:u.CONST_EXPR([c.ApplicationRef])}))])},function(t,e,n){"use strict";var r=n(275),i=n(2),o=n(277),s=n(249),a=n(5);e.ROUTER_PROVIDERS=a.CONST_EXPR([r.ROUTER_PROVIDERS_COMMON,a.CONST_EXPR(new i.Provider(s.PlatformLocation,{useClass:o.BrowserPlatformLocation}))]),e.ROUTER_BINDINGS=e.ROUTER_PROVIDERS},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},o=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},s=n(8),a=n(251),u=n(200),c=function(t){function e(){t.call(this),this._init()}return r(e,t),e.prototype._init=function(){this._location=u.DOM.getLocation(),this._history=u.DOM.getHistory()},Object.defineProperty(e.prototype,"location",{get:function(){return this._location},enumerable:!0,configurable:!0}),e.prototype.getBaseHrefFromDOM=function(){return u.DOM.getBaseHref()},e.prototype.onPopState=function(t){u.DOM.getGlobalEventTarget("window").addEventListener("popstate",t,!1)},e.prototype.onHashChange=function(t){u.DOM.getGlobalEventTarget("window").addEventListener("hashchange",t,!1)},Object.defineProperty(e.prototype,"pathname",{get:function(){return this._location.pathname},set:function(t){this._location.pathname=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"search",{get:function(){return this._location.search},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hash",{get:function(){return this._location.hash},enumerable:!0,configurable:!0}),e.prototype.pushState=function(t,e,n){this._history.pushState(t,e,n)},e.prototype.replaceState=function(t,e,n){this._history.replaceState(t,e,n)},e.prototype.forward=function(){this._history.forward()},e.prototype.back=function(){this._history.back()},e=i([s.Injectable(),o("design:paramtypes",[])],e)}(a.PlatformLocation);e.BrowserPlatformLocation=c},function(t,e,n){"use strict";var r=n(137),i=n(2),o=n(279),s=n(5),a=n(279);e.RouterLinkTransform=a.RouterLinkTransform,e.ROUTER_LINK_DSL_PROVIDER=s.CONST_EXPR(new i.Provider(r.TEMPLATE_TRANSFORMS,{useClass:o.RouterLinkTransform,multi:!0}))},function(t,e,n){"use strict";function r(t,e){var n=new y(t,e.trim()).tokenize();return new m(n).generate()}var i=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},o=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,s=3>o?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(3>o?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},s=this&&this.__metadata||function(t,e){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(t,e):void 0},a=n(137),u=n(141),c=n(12),p=n(2),l=n(142),h=function(){function t(t){this.value=t}return t}(),f=function(){function t(){}return t}(),d=function(){function t(){}return t}(),v=function(){function t(t){this.ast=t}return t}(),y=function(){function t(t,e){this.parser=t,this.exp=e,this.index=0}return t.prototype.tokenize=function(){for(var t=[];this.indexn;n++)e.insertBefore(t[n],this.contentInsertionPoint)},t.prototype.setupOutputs=function(){for(var t=this,e=this.attrs,n=this.info.outputs,r=0;r1)throw new Error("Only support single directive definition for: "+this.name);var n=e[0];n.replace&&this.notSupported("replace"),n.terminal&&this.notSupported("terminal");var r=n.link;return"object"==typeof r&&r.post&&this.notSupported("link.post"),n},t.prototype.notSupported=function(t){throw new Error("Upgraded directive '"+this.name+"' does not support '"+t+"'.")},t.prototype.extractBindings=function(){var t="object"==typeof this.directive.bindToController;if(t&&Object.keys(this.directive.scope).length)throw new Error("Binding definitions on scope and controller at the same time are not supported.");var e=t?this.directive.bindToController:this.directive.scope;if("object"==typeof e)for(var n in e)if(e.hasOwnProperty(n)){var r=e[n],i=r.charAt(0);r=r.substr(1)||n;var o="output_"+n,s=o+": "+n,a=o+": "+n+"Change",u="input_"+n,c=u+": "+n;switch(i){case"=":this.propertyOutputs.push(o),this.checkProperties.push(r),this.outputs.push(o),this.outputsRename.push(a),this.propertyMap[o]=r;case"@":case"<":this.inputs.push(u),this.inputsRename.push(c),this.propertyMap[u]=r;break;case"&":this.outputs.push(o),this.outputsRename.push(s),this.propertyMap[o]=r;break;default:var p=JSON.stringify(e);throw new Error("Unexpected mapping '"+i+"' in '"+p+"' in '"+this.name+"' directive.")}}},t.prototype.compileTemplate=function(t,e,n){function r(e){var n=document.createElement("div");return n.innerHTML=e,t(n.childNodes)}var i=this;if(void 0!==this.directive.template)this.linkFn=r(this.directive.template);else{if(!this.directive.templateUrl)throw new Error("Directive '"+this.name+"' is not a component, it is missing template.");var o=this.directive.templateUrl,s=e.get(o);if(void 0===s)return new Promise(function(t,s){n("GET",o,null,function(n,a){200==n?t(i.linkFn=r(e.put(o,a))):s("GET "+o+" returned "+n+": "+a)})});this.linkFn=r(s)}return null},t.resolve=function(t,e){var n=[],r=e.get(i.NG1_COMPILE),o=e.get(i.NG1_TEMPLATE_CACHE),s=e.get(i.NG1_HTTP_BACKEND),a=e.get(i.NG1_CONTROLLER);for(var u in t)if(t.hasOwnProperty(u)){var c=t[u];c.directive=c.extractDirective(e),c.$controller=a,c.extractBindings();var p=c.compileTemplate(r,o,s);p&&n.push(p)}return Promise.all(n)},t}();e.UpgradeNg1ComponentAdapterBuilder=p;var l=function(){function t(t,e,n,i,a,p,l,h,f,d){this.linkFn=t,this.directive=n,this.inputs=p,this.outputs=l,this.propOuts=h,this.checkProperties=f,this.propertyMap=d,this.destinationObj=null,this.checkLastValues=[],this.element=i.nativeElement,this.componentScope=e.$new(!!n.scope);var v=s.element(this.element),y=n.controller,m=null;if(y){var g={$scope:this.componentScope,$element:v};m=a(y,g,null,n.controllerAs),v.data(o.controllerKey(n.name),m)}var _=n.link;if("object"==typeof _&&(_=_.pre),_){var b=c,P=c,E=this.resolveRequired(v,n.require);n.link(this.componentScope,v,b,E,P)}this.destinationObj=n.bindToController&&m?m:this.componentScope;for(var w=0;wr;r++)e.element.appendChild(t[r])},{parentBoundTranscludeFn:function(t,e){e(n)}}),this.destinationObj.$onInit&&this.destinationObj.$onInit()},t.prototype.ngOnChanges=function(t){for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];this.setComponentProperty(e,n.currentValue)}},t.prototype.ngDoCheck=function(){for(var t=0,e=this.destinationObj,n=this.checkLastValues,r=this.checkProperties,i=0;i",this._properties=t&&t.properties||{},this._zoneDelegate=new d(this,this._parent&&this._parent._zoneDelegate,t)}return Object.defineProperty(e,"current",{get:function(){return m},enumerable:!0,configurable:!0}),Object.defineProperty(e,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),e.prototype.get=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t._properties[e];t=t._parent}},e.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},e.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}},e.prototype.run=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{m=o}},e.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o}},e.prototype.runTask=function(e,t,n){if(e.runCount++,e.zone!=this)throw new Error("A task can only be run in the zone which created it! (Creation: "+e.zone.name+"; Execution: "+this.name+")");var r=T;T=e;var o=m;m=this;try{"macroTask"==e.type&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o,T=r}},e.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new v("microTask",this,e,t,n,r,null))},e.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("macroTask",this,e,t,n,r,o))},e.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("eventTask",this,e,t,n,r,o))},e.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.runCount=-1,e.cancelFn=null,t},e.__symbol__=t,e}(),d=function(){function e(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._hasTaskZS=n&&(n.onHasTask?n:t._hasTaskZS),this._hasTaskDlgt=n&&(n.onHasTask?t:t._hasTaskDlgt)}return e.prototype.fork=function(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new h(e,t)},e.prototype.intercept=function(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this.zone,e,t,n):t},e.prototype.invoke=function(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this.zone,e,t,n,r,o):t.apply(n,r)},e.prototype.handleError=function(e,t){return this._handleErrorZS?this._handleErrorZS.onHandleError(this._handleErrorDlgt,this.zone,e,t):!0},e.prototype.scheduleTask=function(e,t){try{if(this._scheduleTaskZS)return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this.zone,e,t);if(t.scheduleFn)t.scheduleFn(t);else{if("microTask"!=t.type)throw new Error("Task is missing scheduleFn.");r(t)}return t}finally{e==this.zone&&this._updateTaskCount(t.type,1)}},e.prototype.invokeTask=function(e,t,n,r){try{return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this.zone,e,t,n,r):t.callback.apply(n,r)}finally{e!=this.zone||"eventTask"==t.type||t.data&&t.data.isPeriodic||this._updateTaskCount(t.type,-1)}},e.prototype.cancelTask=function(e,t){var n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this.zone,e,t);else{if(!t.cancelFn)throw new Error("Task does not support cancellation, or is already canceled.");n=t.cancelFn(t)}return e==this.zone&&this._updateTaskCount(t.type,-1),n},e.prototype.hasTask=function(e,t){return this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this.zone,e,t)},e.prototype._updateTaskCount=function(e,t){var n=this._taskCounts,r=n[e],o=n[e]=r+t;if(0>o)throw new Error("More tasks executed then were scheduled.");if(0==r||0==o){var a={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};try{this.hasTask(this.zone,a)}finally{this._parentDelegate&&this._parentDelegate._updateTaskCount(e,t)}}},e}(),v=function(){function e(e,t,n,r,o,i,u){this.runCount=0,this.type=e,this.zone=t,this.source=n,this.data=o,this.scheduleFn=i,this.cancelFn=u,this.callback=r;var c=this;this.invoke=function(){try{return t.runTask(c,this,arguments)}finally{a()}}}return e}(),y=t("setTimeout"),g=t("Promise"),k=t("then"),m=new h(null,null),T=null,w=[],_=!1,b=[],E=!1,S=t("state"),O=t("value"),D="Promise.then",P=null,M=!0,z=!1,j=0,C=function(){function e(e){var t=this;t[S]=P,t[O]=[];try{e&&e(s(t,M),s(t,z))}catch(n){l(t,!1,n)}}return e.resolve=function(e){return l(new this(null),M,e)},e.reject=function(e){return l(new this(null),z,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){r=e,o=t}),u=0,c=e;u=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function r(e,t){for(var r=e.constructor.name,o=function(o){var a=t[o],i=e[a];i&&(e[a]=function(e){return function(){return e.apply(this,n(arguments,r+"."+a))}}(i))},a=0;a1?new t(e,n):new t(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(r=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){r[e]=function(){return a[e].apply(a,arguments)}})):r=a,o.patchOnProperties(r,["close","error","message","open"]),r};for(var n in t)e.WebSocket[n]=t[n]}var o=n(3);t.apply=r},function(e,t,n){"use strict";function r(e,t,n,r){function a(t){var n=t.data;return n.args[0]=t.invoke,n.handleId=u.apply(e,n.args),t}function i(e){return c(e.data.handleId)}var u=null,c=null;t+=r,n+=r,u=o.patchMethod(e,t,function(n){return function(o,u){if("function"==typeof u[0]){var c=Zone.current,s={handleId:null,isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?u[1]||0:null,args:u};return c.scheduleMacroTask(t,u[0],s,a,i)}return n.apply(e,u)}}),c=o.patchMethod(e,n,function(t){return function(n,r){var o=r[0];o&&"string"==typeof o.type?(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&o.zone.cancelTask(o):t.apply(e,r)}})}var o=n(3);t.patchTimer=r}]),function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";!function(){function e(){return new Error("STACKTRACE TRACKING")}function t(){try{throw e()}catch(t){return t}}function n(e){return e.stack?e.stack.split(u):[]}function r(e,t){for(var r=n(t),o=0;o0&&(e.push(n((new f).error)),a(e,t-1))}function i(){var e=[];a(e,2);for(var t=e[0],n=e[1],r=0;rthis.longStackTraceLimit&&(a.length=this.longStackTraceLimit),r.data||(r.data={}),r.data[l]=a,e.scheduleTask(n,r)},onHandleError:function(e,t,n,r){var a=Zone.currentTask;if(r instanceof Error&&a){var i=Object.getOwnPropertyDescriptor(r,"stack");if(i){var u=i.get,c=i.value;i={get:function(){return o(a.data&&a.data[l],u?u.apply(this):c)}},Object.defineProperty(r,"stack",i)}else r.stack=o(a.data&&a.data[l],r.stack)}return e.handleError(n,r)}},i()}()}]);var Reflect;!function(e){function t(e,t,n,r){if(_(r)){if(_(n)){if(!b(e))throw new TypeError;if(!S(t))throw new TypeError;return f(e,t)}if(!b(e))throw new TypeError;if(!E(t))throw new TypeError;return n=D(n),h(e,t,n)}if(!b(e))throw new TypeError;if(!E(t))throw new TypeError;if(_(n))throw new TypeError;if(!E(r))throw new TypeError;return n=D(n),p(e,t,n,r)}function n(e,t){function n(n,r){if(_(r)){if(!S(n))throw new TypeError;m(e,t,n,void 0)}else{if(!E(n))throw new TypeError;r=D(r),m(e,t,n,r)}}return n}function r(e,t,n,r){if(!E(n))throw new TypeError;return _(r)||(r=D(r)),m(e,t,n,r)}function o(e,t,n){if(!E(t))throw new TypeError;return _(n)||(n=D(n)),v(e,t,n)}function a(e,t,n){if(!E(t))throw new TypeError;return _(n)||(n=D(n)),y(e,t,n)}function i(e,t,n){if(!E(t))throw new TypeError;return _(n)||(n=D(n)),g(e,t,n)}function u(e,t,n){if(!E(t))throw new TypeError;return _(n)||(n=D(n)),k(e,t,n)}function c(e,t){if(!E(e))throw new TypeError;return _(t)||(t=D(t)),T(e,t)}function s(e,t){if(!E(e))throw new TypeError;return _(t)||(t=D(t)),w(e,t)}function l(e,t,n){if(!E(t))throw new TypeError;_(n)||(n=D(n));var r=d(t,n,!1);if(_(r))return!1;if(!r["delete"](e))return!1;if(r.size>0)return!0;var o=R.get(t);return o["delete"](n),o.size>0?!0:(R["delete"](t),!0)}function f(e,t){for(var n=e.length-1;n>=0;--n){var r=e[n],o=r(t);if(!_(o)){if(!S(o))throw new TypeError;t=o}}return t}function p(e,t,n,r){for(var o=e.length-1;o>=0;--o){var a=e[o],i=a(t,n,r);if(!_(i)){if(!E(i))throw new TypeError;r=i}}return r}function h(e,t,n){for(var r=e.length-1;r>=0;--r){var o=e[r];o(t,n)}}function d(e,t,n){var r=R.get(e);if(!r){if(!n)return;r=new Z,R.set(e,r)}var o=r.get(t);if(!o){if(!n)return;o=new Z,r.set(t,o)}return o}function v(e,t,n){var r=y(e,t,n);if(r)return!0;var o=P(t);return null!==o?v(e,o,n):!1}function y(e,t,n){var r=d(t,n,!1);return void 0===r?!1:Boolean(r.has(e))}function g(e,t,n){var r=y(e,t,n);if(r)return k(e,t,n);var o=P(t);return null!==o?g(e,o,n):void 0}function k(e,t,n){var r=d(t,n,!1);if(void 0!==r)return r.get(e)}function m(e,t,n,r){var o=d(n,r,!0);o.set(e,t)}function T(e,t){var n=w(e,t),r=P(e);if(null===r)return n;var o=T(r,t);if(o.length<=0)return n;if(n.length<=0)return o;for(var a=new I,i=[],u=0;u=0?(this._cache=e,!0):!1},get:function(e){var t=this._find(e);return t>=0?(this._cache=e,this._values[t]):void 0},set:function(e,t){return this["delete"](e),this._keys.push(e),this._values.push(t),this._cache=e,this},"delete":function(e){var n=this._find(e);return n>=0?(this._keys.splice(n,1),this._values.splice(n,1),this._cache=t,!0):!1},clear:function(){this._keys.length=0,this._values.length=0,this._cache=t},forEach:function(e,t){for(var n=this.size,r=0;n>r;++r){var o=this._keys[r],a=this._values[r];this._cache=o,e.call(this,a,o,this)}},_find:function(e){for(var t=this._keys,n=t.length,r=0;n>r;++r)if(t[r]===e)return r;return-1}},e}function z(){function e(){this._map=new Z}return e.prototype={get size(){return this._map.length},has:function(e){return this._map.has(e)},add:function(e){return this._map.set(e,e),this},"delete":function(e){return this._map["delete"](e)},clear:function(){this._map.clear()},forEach:function(e,t){this._map.forEach(e,t)}},e}function j(){function e(){this._key=o()}function t(e,t){for(var n=0;t>n;++n)e[n]=255*Math.random()|0}function n(e){if(c){var n=c.randomBytes(e);return n}if("function"==typeof Uint8Array){var n=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(n):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(n):t(n,e),n}var n=new Array(e);return t(n,e),n}function r(){var e=n(i);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var t="",r=0;i>r;++r){var o=e[r];(4===r||6===r||8===r)&&(t+="-"),16>o&&(t+="0"),t+=o.toString(16).toLowerCase()}return t}function o(){var e;do e="@@WeakMap@@"+r();while(s.call(l,e));return l[e]=!0,e}function a(e,t){if(!s.call(e,f)){if(!t)return;Object.defineProperty(e,f,{value:Object.create(null)})}return e[f]}var i=16,u="undefined"!=typeof global&&"[object process]"===Object.prototype.toString.call(global.process),c=u&&require("crypto"),s=Object.prototype.hasOwnProperty,l={},f=o();return e.prototype={has:function(e){var t=a(e,!1);return t?this._key in t:!1},get:function(e){var t=a(e,!1);return t?t[this._key]:void 0},set:function(e,t){var n=a(e,!0);return n[this._key]=t,this},"delete":function(e){var t=a(e,!1);return t&&this._key in t?delete t[this._key]:!1},clear:function(){this._key=o()}},e}var C=Object.getPrototypeOf(Function),Z="function"==typeof Map?Map:M(),I="function"==typeof Set?Set:z(),L="function"==typeof WeakMap?WeakMap:j(),R=new L;e.decorate=t,e.metadata=n,e.defineMetadata=r,e.hasMetadata=o,e.hasOwnMetadata=a,e.getMetadata=i,e.getOwnMetadata=u,e.getMetadataKeys=c,e.getOwnMetadataKeys=s,e.deleteMetadata=l,function(t){if("undefined"!=typeof t.Reflect){if(t.Reflect!==e)for(var n in e)t.Reflect[n]=e[n]}else t.Reflect=e}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof global?global:Function("return this;")())}(Reflect||(Reflect={})); \ No newline at end of file diff --git a/accessible/libs/es6-shim.min.js b/accessible/libs/es6-shim.min.js deleted file mode 100644 index 9a11646fc88..00000000000 --- a/accessible/libs/es6-shim.min.js +++ /dev/null @@ -1,12 +0,0 @@ -/*! - * https://github.com/paulmillr/es6-shim - * @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com) - * and contributors, MIT License - * es6-shim: v0.35.1 - * see https://github.com/paulmillr/es6-shim/blob/0.35.1/LICENSE - * Details and documentation: - * https://github.com/paulmillr/es6-shim/ - */ -(function(e,t){if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){"use strict";var e=Function.call.bind(Function.apply);var t=Function.call.bind(Function.call);var r=Array.isArray;var n=Object.keys;var o=function notThunker(t){return function notThunk(){return!e(t,this,arguments)}};var i=function(e){try{e();return false}catch(t){return true}};var a=function valueOrFalseIfThrows(e){try{return e()}catch(t){return false}};var u=o(i);var f=function(){return!i(function(){Object.defineProperty({},"x",{get:function(){}})})};var s=!!Object.defineProperty&&f();var c=function foo(){}.name==="foo";var l=Function.call.bind(Array.prototype.forEach);var p=Function.call.bind(Array.prototype.reduce);var v=Function.call.bind(Array.prototype.filter);var y=Function.call.bind(Array.prototype.some);var h=function(e,t,r,n){if(!n&&t in e){return}if(s){Object.defineProperty(e,t,{configurable:true,enumerable:false,writable:true,value:r})}else{e[t]=r}};var b=function(e,t,r){l(n(t),function(n){var o=t[n];h(e,n,o,!!r)})};var g=Function.call.bind(Object.prototype.toString);var d=typeof/abc/==="function"?function IsCallableSlow(e){return typeof e==="function"&&g(e)==="[object Function]"}:function IsCallableFast(e){return typeof e==="function"};var O={getter:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}Object.defineProperty(e,t,{configurable:true,enumerable:false,get:r})},proxy:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,{configurable:n.configurable,enumerable:n.enumerable,get:function getKey(){return e[t]},set:function setKey(r){e[t]=r}})},redefine:function(e,t,r){if(s){var n=Object.getOwnPropertyDescriptor(e,t);n.value=r;Object.defineProperty(e,t,n)}else{e[t]=r}},defineByDescriptor:function(e,t,r){if(s){Object.defineProperty(e,t,r)}else if("value"in r){e[t]=r.value}},preserveToString:function(e,t){if(t&&d(t.toString)){h(e,"toString",t.toString.bind(t),true)}}};var m=Object.create||function(e,t){var r=function Prototype(){};r.prototype=e;var o=new r;if(typeof t!=="undefined"){n(t).forEach(function(e){O.defineByDescriptor(o,e,t[e])})}return o};var w=function(e,t){if(!Object.setPrototypeOf){return false}return a(function(){var r=function Subclass(t){var r=new e(t);Object.setPrototypeOf(r,Subclass.prototype);return r};Object.setPrototypeOf(r,e);r.prototype=m(e.prototype,{constructor:{value:r}});return t(r)})};var j=function(){if(typeof self!=="undefined"){return self}if(typeof window!=="undefined"){return window}if(typeof global!=="undefined"){return global}throw new Error("unable to locate global object")};var S=j();var T=S.isFinite;var I=Function.call.bind(String.prototype.indexOf);var E=Function.apply.bind(Array.prototype.indexOf);var P=Function.call.bind(Array.prototype.concat);var C=Function.call.bind(String.prototype.slice);var M=Function.call.bind(Array.prototype.push);var x=Function.apply.bind(Array.prototype.push);var N=Function.call.bind(Array.prototype.shift);var A=Math.max;var R=Math.min;var _=Math.floor;var k=Math.abs;var F=Math.exp;var L=Math.log;var D=Math.sqrt;var z=Function.call.bind(Object.prototype.hasOwnProperty);var q;var W=function(){};var G=S.Symbol||{};var H=G.species||"@@species";var V=Number.isNaN||function isNaN(e){return e!==e};var B=Number.isFinite||function isFinite(e){return typeof e==="number"&&T(e)};var $=d(Math.sign)?Math.sign:function sign(e){var t=Number(e);if(t===0){return t}if(V(t)){return t}return t<0?-1:1};var U=function isArguments(e){return g(e)==="[object Arguments]"};var J=function isArguments(e){return e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&g(e)!=="[object Array]"&&g(e.callee)==="[object Function]"};var X=U(arguments)?U:J;var K={primitive:function(e){return e===null||typeof e!=="function"&&typeof e!=="object"},string:function(e){return g(e)==="[object String]"},regex:function(e){return g(e)==="[object RegExp]"},symbol:function(e){return typeof S.Symbol==="function"&&typeof e==="symbol"}};var Z=function overrideNative(e,t,r){var n=e[t];h(e,t,r,true);O.preserveToString(e[t],n)};var Y=typeof G==="function"&&typeof G["for"]==="function"&&K.symbol(G());var Q=K.symbol(G.iterator)?G.iterator:"_es6-shim iterator_";if(S.Set&&typeof(new S.Set)["@@iterator"]==="function"){Q="@@iterator"}if(!S.Reflect){h(S,"Reflect",{},true)}var ee=S.Reflect;var te=String;var re={Call:function Call(t,r){var n=arguments.length>2?arguments[2]:[];if(!re.IsCallable(t)){throw new TypeError(t+" is not a function")}return e(t,r,n)},RequireObjectCoercible:function(e,t){if(e==null){throw new TypeError(t||"Cannot call method on "+e)}return e},TypeIsObject:function(e){if(e===void 0||e===null||e===true||e===false){return false}return typeof e==="function"||typeof e==="object"},ToObject:function(e,t){return Object(re.RequireObjectCoercible(e,t))},IsCallable:d,IsConstructor:function(e){return re.IsCallable(e)},ToInt32:function(e){return re.ToNumber(e)>>0},ToUint32:function(e){return re.ToNumber(e)>>>0},ToNumber:function(e){if(g(e)==="[object Symbol]"){throw new TypeError("Cannot convert a Symbol value to a number")}return+e},ToInteger:function(e){var t=re.ToNumber(e);if(V(t)){return 0}if(t===0||!B(t)){return t}return(t>0?1:-1)*_(k(t))},ToLength:function(e){var t=re.ToInteger(e);if(t<=0){return 0}if(t>Number.MAX_SAFE_INTEGER){return Number.MAX_SAFE_INTEGER}return t},SameValue:function(e,t){if(e===t){if(e===0){return 1/e===1/t}return true}return V(e)&&V(t)},SameValueZero:function(e,t){return e===t||V(e)&&V(t)},IsIterable:function(e){return re.TypeIsObject(e)&&(typeof e[Q]!=="undefined"||X(e))},GetIterator:function(e){if(X(e)){return new q(e,"value")}var t=re.GetMethod(e,Q);if(!re.IsCallable(t)){throw new TypeError("value is not an iterable")}var r=re.Call(t,e);if(!re.TypeIsObject(r)){throw new TypeError("bad iterator")}return r},GetMethod:function(e,t){var r=re.ToObject(e)[t];if(r===void 0||r===null){return void 0}if(!re.IsCallable(r)){throw new TypeError("Method not callable: "+t)}return r},IteratorComplete:function(e){return!!e.done},IteratorClose:function(e,t){var r=re.GetMethod(e,"return");if(r===void 0){return}var n,o;try{n=re.Call(r,e)}catch(i){o=i}if(t){return}if(o){throw o}if(!re.TypeIsObject(n)){throw new TypeError("Iterator's return method returned a non-object.")}},IteratorNext:function(e){var t=arguments.length>1?e.next(arguments[1]):e.next();if(!re.TypeIsObject(t)){throw new TypeError("bad iterator")}return t},IteratorStep:function(e){var t=re.IteratorNext(e);var r=re.IteratorComplete(t);return r?false:t},Construct:function(e,t,r,n){var o=typeof r==="undefined"?e:r;if(!n&&ee.construct){return ee.construct(e,t,o)}var i=o.prototype;if(!re.TypeIsObject(i)){i=Object.prototype}var a=m(i);var u=re.Call(e,a,t);return re.TypeIsObject(u)?u:a},SpeciesConstructor:function(e,t){var r=e.constructor;if(r===void 0){return t}if(!re.TypeIsObject(r)){throw new TypeError("Bad constructor")}var n=r[H];if(n===void 0||n===null){return t}if(!re.IsConstructor(n)){throw new TypeError("Bad @@species")}return n},CreateHTML:function(e,t,r,n){var o=re.ToString(e);var i="<"+t;if(r!==""){var a=re.ToString(n);var u=a.replace(/"/g,""");i+=" "+r+'="'+u+'"'}var f=i+">";var s=f+o;return s+""},IsRegExp:function IsRegExp(e){if(!re.TypeIsObject(e)){return false}var t=e[G.match];if(typeof t!=="undefined"){return!!t}return K.regex(e)},ToString:function ToString(e){return te(e)}};if(s&&Y){var ne=function defineWellKnownSymbol(e){if(K.symbol(G[e])){return G[e]}var t=G["for"]("Symbol."+e);Object.defineProperty(G,e,{configurable:false,enumerable:false,writable:false,value:t});return t};if(!K.symbol(G.search)){var oe=ne("search");var ie=String.prototype.search;h(RegExp.prototype,oe,function search(e){return re.Call(ie,e,[this])});var ae=function search(e){var t=re.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var r=re.GetMethod(e,oe);if(typeof r!=="undefined"){return re.Call(r,e,[t])}}return re.Call(ie,t,[re.ToString(e)])};Z(String.prototype,"search",ae)}if(!K.symbol(G.replace)){var ue=ne("replace");var fe=String.prototype.replace;h(RegExp.prototype,ue,function replace(e,t){return re.Call(fe,e,[this,t])});var se=function replace(e,t){var r=re.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var n=re.GetMethod(e,ue);if(typeof n!=="undefined"){return re.Call(n,e,[r,t])}}return re.Call(fe,r,[re.ToString(e),t])};Z(String.prototype,"replace",se)}if(!K.symbol(G.split)){var ce=ne("split");var le=String.prototype.split;h(RegExp.prototype,ce,function split(e,t){return re.Call(le,e,[this,t])});var pe=function split(e,t){var r=re.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var n=re.GetMethod(e,ce);if(typeof n!=="undefined"){return re.Call(n,e,[r,t])}}return re.Call(le,r,[re.ToString(e),t])};Z(String.prototype,"split",pe)}var ve=K.symbol(G.match);var ye=ve&&function(){var e={};e[G.match]=function(){return 42};return"a".match(e)!==42}();if(!ve||ye){var he=ne("match");var be=String.prototype.match;h(RegExp.prototype,he,function match(e){return re.Call(be,e,[this])});var ge=function match(e){var t=re.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var r=re.GetMethod(e,he);if(typeof r!=="undefined"){return re.Call(r,e,[t])}}return re.Call(be,t,[re.ToString(e)])};Z(String.prototype,"match",ge)}}var de=function wrapConstructor(e,t,r){O.preserveToString(t,e);if(Object.setPrototypeOf){Object.setPrototypeOf(e,t)}if(s){l(Object.getOwnPropertyNames(e),function(n){if(n in W||r[n]){return}O.proxy(e,n,t)})}else{l(Object.keys(e),function(n){if(n in W||r[n]){return}t[n]=e[n]})}t.prototype=e.prototype;O.redefine(e.prototype,"constructor",t)};var Oe=function(){return this};var me=function(e){if(s&&!z(e,H)){O.getter(e,H,Oe)}};var we=function(e,t){var r=t||function iterator(){return this};h(e,Q,r);if(!e[Q]&&K.symbol(Q)){e[Q]=r}};var je=function createDataProperty(e,t,r){if(s){Object.defineProperty(e,t,{configurable:true,enumerable:true,writable:true,value:r})}else{e[t]=r}};var Se=function createDataPropertyOrThrow(e,t,r){je(e,t,r);if(!re.SameValue(e[t],r)){throw new TypeError("property is nonconfigurable")}};var Te=function(e,t,r,n){if(!re.TypeIsObject(e)){throw new TypeError("Constructor requires `new`: "+t.name)}var o=t.prototype;if(!re.TypeIsObject(o)){o=r}var i=m(o);for(var a in n){if(z(n,a)){var u=n[a];h(i,a,u,true)}}return i};if(String.fromCodePoint&&String.fromCodePoint.length!==1){var Ie=String.fromCodePoint;Z(String,"fromCodePoint",function fromCodePoint(e){return re.Call(Ie,this,arguments)})}var Ee={fromCodePoint:function fromCodePoint(e){var t=[];var r;for(var n=0,o=arguments.length;n1114111){throw new RangeError("Invalid code point "+r)}if(r<65536){M(t,String.fromCharCode(r))}else{r-=65536;M(t,String.fromCharCode((r>>10)+55296));M(t,String.fromCharCode(r%1024+56320))}}return t.join("")},raw:function raw(e){var t=re.ToObject(e,"bad callSite");var r=re.ToObject(t.raw,"bad raw value");var n=r.length;var o=re.ToLength(n);if(o<=0){return""}var i=[];var a=0;var u,f,s,c;while(a=o){break}f=a+1=Ce){throw new RangeError("repeat count must be less than infinity and not overflow maximum string size")}return Pe(t,r)},startsWith:function startsWith(e){var t=re.ToString(re.RequireObjectCoercible(this));if(re.IsRegExp(e)){throw new TypeError('Cannot call method "startsWith" with a regex')}var r=re.ToString(e);var n;if(arguments.length>1){n=arguments[1]}var o=A(re.ToInteger(n),0);return C(t,o,o+r.length)===r},endsWith:function endsWith(e){var t=re.ToString(re.RequireObjectCoercible(this));if(re.IsRegExp(e)){throw new TypeError('Cannot call method "endsWith" with a regex')}var r=re.ToString(e);var n=t.length;var o;if(arguments.length>1){o=arguments[1]}var i=typeof o==="undefined"?n:re.ToInteger(o);var a=R(A(i,0),n);return C(t,a-r.length,a)===r},includes:function includes(e){if(re.IsRegExp(e)){throw new TypeError('"includes" does not accept a RegExp')}var t=re.ToString(e);var r;if(arguments.length>1){r=arguments[1]}return I(this,t,r)!==-1},codePointAt:function codePointAt(e){var t=re.ToString(re.RequireObjectCoercible(this));var r=re.ToInteger(e);var n=t.length;if(r>=0&&r56319||i){return o}var a=t.charCodeAt(r+1);if(a<56320||a>57343){return o}return(o-55296)*1024+(a-56320)+65536}}};if(String.prototype.includes&&"a".includes("a",Infinity)!==false){Z(String.prototype,"includes",Me.includes)}if(String.prototype.startsWith&&String.prototype.endsWith){var xe=i(function(){"/a/".startsWith(/a/)});var Ne=a(function(){return"abc".startsWith("a",Infinity)===false});if(!xe||!Ne){Z(String.prototype,"startsWith",Me.startsWith);Z(String.prototype,"endsWith",Me.endsWith)}}if(Y){var Ae=a(function(){var e=/a/;e[G.match]=false;return"/a/".startsWith(e)});if(!Ae){Z(String.prototype,"startsWith",Me.startsWith)}var Re=a(function(){var e=/a/;e[G.match]=false;return"/a/".endsWith(e)});if(!Re){Z(String.prototype,"endsWith",Me.endsWith)}var _e=a(function(){var e=/a/;e[G.match]=false;return"/a/".includes(e)});if(!_e){Z(String.prototype,"includes",Me.includes)}}b(String.prototype,Me);var ke=[" \n\x0B\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003","\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028","\u2029\ufeff"].join("");var Fe=new RegExp("(^["+ke+"]+)|(["+ke+"]+$)","g");var Le=function trim(){return re.ToString(re.RequireObjectCoercible(this)).replace(Fe,"")};var De=["\x85","\u200b","\ufffe"].join("");var ze=new RegExp("["+De+"]","g");var qe=/^[\-+]0x[0-9a-f]+$/i;var We=De.trim().length!==De.length;h(String.prototype,"trim",Le,We);var Ge=function(e){return{value:e,done:arguments.length===0}};var He=function(e){re.RequireObjectCoercible(e);this._s=re.ToString(e);this._i=0};He.prototype.next=function(){var e=this._s;var t=this._i;if(typeof e==="undefined"||t>=e.length){this._s=void 0;return Ge()}var r=e.charCodeAt(t);var n,o;if(r<55296||r>56319||t+1===e.length){o=1}else{n=e.charCodeAt(t+1);o=n<56320||n>57343?1:2}this._i=t+o;return Ge(e.substr(t,o))};we(He.prototype);we(String.prototype,function(){return new He(this)});var Ve={from:function from(e){var r=this;var n;if(arguments.length>1){n=arguments[1]}var o,i;if(typeof n==="undefined"){o=false}else{if(!re.IsCallable(n)){throw new TypeError("Array.from: when provided, the second argument must be a function")}if(arguments.length>2){i=arguments[2]}o=true}var a=typeof(X(e)||re.GetMethod(e,Q))!=="undefined";var u,f,s;if(a){f=re.IsConstructor(r)?Object(new r):[];var c=re.GetIterator(e);var l,p;s=0;while(true){l=re.IteratorStep(c);if(l===false){break}p=l.value;try{if(o){p=typeof i==="undefined"?n(p,s):t(n,i,p,s)}f[s]=p}catch(v){re.IteratorClose(c,true);throw v}s+=1}u=s}else{var y=re.ToObject(e);u=re.ToLength(y.length);f=re.IsConstructor(r)?Object(new r(u)):new Array(u);var h;for(s=0;s2){f=arguments[2]}var s=typeof f==="undefined"?n:re.ToInteger(f);var c=s<0?A(n+s,0):R(s,n);var l=R(c-u,n-a);var p=1;if(u0){if(u in r){r[a]=r[u]}else{delete r[a]}u+=p;a+=p;l-=1}return r},fill:function fill(e){var t;if(arguments.length>1){t=arguments[1]}var r;if(arguments.length>2){r=arguments[2]}var n=re.ToObject(this);var o=re.ToLength(n.length);t=re.ToInteger(typeof t==="undefined"?0:t);r=re.ToInteger(typeof r==="undefined"?o:r);var i=t<0?A(o+t,0):R(t,o);var a=r<0?o+r:r;for(var u=i;u1?arguments[1]:null;for(var i=0,a;i1?arguments[1]:null;for(var i=0;i1&&typeof arguments[1]!=="undefined"){return re.Call(Ze,this,arguments)}else{return t(Ze,this,e)}})}var Ye=-(Math.pow(2,32)-1);var Qe=function(e,r){var n={length:Ye};n[r?(n.length>>>0)-1:0]=true;return a(function(){t(e,n,function(){throw new RangeError("should not reach here")},[]);return true})};if(!Qe(Array.prototype.forEach)){var et=Array.prototype.forEach;Z(Array.prototype,"forEach",function forEach(e){return re.Call(et,this.length>=0?this:[],arguments)},true)}if(!Qe(Array.prototype.map)){var tt=Array.prototype.map;Z(Array.prototype,"map",function map(e){return re.Call(tt,this.length>=0?this:[],arguments)},true)}if(!Qe(Array.prototype.filter)){var rt=Array.prototype.filter;Z(Array.prototype,"filter",function filter(e){return re.Call(rt,this.length>=0?this:[],arguments)},true)}if(!Qe(Array.prototype.some)){var nt=Array.prototype.some;Z(Array.prototype,"some",function some(e){return re.Call(nt,this.length>=0?this:[],arguments)},true)}if(!Qe(Array.prototype.every)){var ot=Array.prototype.every;Z(Array.prototype,"every",function every(e){return re.Call(ot,this.length>=0?this:[],arguments)},true)}if(!Qe(Array.prototype.reduce)){var it=Array.prototype.reduce;Z(Array.prototype,"reduce",function reduce(e){return re.Call(it,this.length>=0?this:[],arguments)},true)}if(!Qe(Array.prototype.reduceRight,true)){var at=Array.prototype.reduceRight;Z(Array.prototype,"reduceRight",function reduceRight(e){return re.Call(at,this.length>=0?this:[],arguments)},true)}var ut=Number("0o10")!==8;var ft=Number("0b10")!==2;var st=y(De,function(e){return Number(e+0+e)===0});if(ut||ft||st){var ct=Number;var lt=/^0b[01]+$/i;var pt=/^0o[0-7]+$/i;var vt=lt.test.bind(lt);var yt=pt.test.bind(pt);var ht=function(e){var t;if(typeof e.valueOf==="function"){t=e.valueOf();if(K.primitive(t)){return t}}if(typeof e.toString==="function"){t=e.toString();if(K.primitive(t)){return t}}throw new TypeError("No default value")};var bt=ze.test.bind(ze);var gt=qe.test.bind(qe);var dt=function(){var e=function Number(t){var r;if(arguments.length>0){r=K.primitive(t)?t:ht(t,"number")}else{r=0}if(typeof r==="string"){r=re.Call(Le,r);if(vt(r)){r=parseInt(C(r,2),2)}else if(yt(r)){r=parseInt(C(r,2),8)}else if(bt(r)||gt(r)){r=NaN}}var n=this;var o=a(function(){ct.prototype.valueOf.call(n);return true});if(n instanceof e&&!o){return new ct(r)}return ct(r)};return e}();de(ct,dt,{});b(dt,{NaN:ct.NaN,MAX_VALUE:ct.MAX_VALUE,MIN_VALUE:ct.MIN_VALUE,NEGATIVE_INFINITY:ct.NEGATIVE_INFINITY,POSITIVE_INFINITY:ct.POSITIVE_INFINITY});Number=dt;O.redefine(S,"Number",dt)}var Ot=Math.pow(2,53)-1;b(Number,{MAX_SAFE_INTEGER:Ot,MIN_SAFE_INTEGER:-Ot,EPSILON:2.220446049250313e-16,parseInt:S.parseInt,parseFloat:S.parseFloat,isFinite:B,isInteger:function isInteger(e){return B(e)&&re.ToInteger(e)===e},isSafeInteger:function isSafeInteger(e){return Number.isInteger(e)&&k(e)<=Number.MAX_SAFE_INTEGER},isNaN:V});h(Number,"parseInt",S.parseInt,Number.parseInt!==S.parseInt);if(![,1].find(function(e,t){return t===0})){Z(Array.prototype,"find",$e.find)}if([,1].findIndex(function(e,t){return t===0})!==0){Z(Array.prototype,"findIndex",$e.findIndex)}var mt=Function.bind.call(Function.bind,Object.prototype.propertyIsEnumerable);var wt=function ensureEnumerable(e,t){if(s&&mt(e,t)){Object.defineProperty(e,t,{enumerable:false})}};var jt=function sliceArgs(){var e=Number(this);var t=arguments.length;var r=t-e;var n=new Array(r<0?0:r);for(var o=e;o1){return NaN}if(t===-1){return-Infinity}if(t===1){return Infinity}if(t===0){return t}return.5*L((1+t)/(1-t))},cbrt:function cbrt(e){var t=Number(e);if(t===0){return t}var r=t<0;var n;if(r){t=-t}if(t===Infinity){n=Infinity}else{n=F(L(t)/3);n=(t/(n*n)+2*n)/3}return r?-n:n},clz32:function clz32(e){var t=Number(e);var r=re.ToUint32(t);if(r===0){return 32}return Or?re.Call(Or,r):31-_(L(r+.5)*gr)},cosh:function cosh(e){var t=Number(e);if(t===0){return 1}if(V(t)){return NaN}if(!T(t)){return Infinity}if(t<0){t=-t}if(t>21){return F(t)/2}return(F(t)+F(-t))/2},expm1:function expm1(e){var t=Number(e);if(t===-Infinity){return-1}if(!T(t)||t===0){return t}if(k(t)>.5){return F(t)-1}var r=t;var n=0;var o=1;while(n+r!==n){n+=r;o+=1;r*=t/o}return n},hypot:function hypot(e,t){var r=0;var n=0;for(var o=0;o0?i/n*(i/n):i}}return n===Infinity?Infinity:n*D(r)},log2:function log2(e){return L(e)*gr},log10:function log10(e){return L(e)*dr},log1p:function log1p(e){var t=Number(e);if(t<-1||V(t)){return NaN}if(t===0||t===Infinity){return t}if(t===-1){return-Infinity}return 1+t-1===0?t:t*(L(1+t)/(1+t-1))},sign:$,sinh:function sinh(e){var t=Number(e);if(!T(t)||t===0){return t}if(k(t)<1){return(Math.expm1(t)-Math.expm1(-t))/2}return(F(t-1)-F(-t-1))*br/2},tanh:function tanh(e){var t=Number(e);if(V(t)||t===0){return t}if(t>=20){return 1}if(t<=-20){return-1}return(Math.expm1(t)-Math.expm1(-t))/(F(t)+F(-t))},trunc:function trunc(e){var t=Number(e);return t<0?-_(-t):_(t)},imul:function imul(e,t){var r=re.ToUint32(e);var n=re.ToUint32(t);var o=r>>>16&65535;var i=r&65535;var a=n>>>16&65535;var u=n&65535;return i*u+(o*u+i*a<<16>>>0)|0},fround:function fround(e){var t=Number(e);if(t===0||t===Infinity||t===-Infinity||V(t)){return t}var r=$(t);var n=k(t);if(nyr||V(i)){return r*Infinity}return r*i}};b(Math,mr);h(Math,"log1p",mr.log1p,Math.log1p(-1e-17)!==-1e-17);h(Math,"asinh",mr.asinh,Math.asinh(-1e7)!==-Math.asinh(1e7));h(Math,"tanh",mr.tanh,Math.tanh(-2e-17)!==-2e-17);h(Math,"acosh",mr.acosh,Math.acosh(Number.MAX_VALUE)===Infinity);h(Math,"cbrt",mr.cbrt,Math.abs(1-Math.cbrt(1e-300)/1e-100)/Number.EPSILON>8);h(Math,"sinh",mr.sinh,Math.sinh(-2e-17)!==-2e-17);var wr=Math.expm1(10);h(Math,"expm1",mr.expm1,wr>22025.465794806718||wr<22025.465794806718);var jr=Math.round;var Sr=Math.round(.5-Number.EPSILON/4)===0&&Math.round(-.5+Number.EPSILON/3.99)===1;var Tr=lr+1;var Ir=2*lr-1;var Er=[Tr,Ir].every(function(e){return Math.round(e)===e});h(Math,"round",function round(e){var t=_(e);var r=t===-1?-0:t+1;return e-t<.5?t:r},!Sr||!Er);O.preserveToString(Math.round,jr);var Pr=Math.imul;if(Math.imul(4294967295,5)!==-5){Math.imul=mr.imul;O.preserveToString(Math.imul,Pr)}if(Math.imul.length!==2){Z(Math,"imul",function imul(e,t){return re.Call(Pr,Math,arguments); -})}var Cr=function(){var e=S.setTimeout;if(typeof e!=="function"&&typeof e!=="object"){return}re.IsPromise=function(e){if(!re.TypeIsObject(e)){return false}if(typeof e._promise==="undefined"){return false}return true};var r=function(e){if(!re.IsConstructor(e)){throw new TypeError("Bad promise constructor")}var t=this;var r=function(e,r){if(t.resolve!==void 0||t.reject!==void 0){throw new TypeError("Bad Promise implementation!")}t.resolve=e;t.reject=r};t.resolve=void 0;t.reject=void 0;t.promise=new e(r);if(!(re.IsCallable(t.resolve)&&re.IsCallable(t.reject))){throw new TypeError("Bad promise constructor")}};var n;if(typeof window!=="undefined"&&re.IsCallable(window.postMessage)){n=function(){var e=[];var t="zero-timeout-message";var r=function(r){M(e,r);window.postMessage(t,"*")};var n=function(r){if(r.source===window&&r.data===t){r.stopPropagation();if(e.length===0){return}var n=N(e);n()}};window.addEventListener("message",n,true);return r}}var o=function(){var e=S.Promise;var t=e&&e.resolve&&e.resolve();return t&&function(e){return t.then(e)}};var i=re.IsCallable(S.setImmediate)?S.setImmediate:typeof process==="object"&&process.nextTick?process.nextTick:o()||(re.IsCallable(n)?n():function(t){e(t,0)});var a=function(e){return e};var u=function(e){throw e};var f=0;var s=1;var c=2;var l=0;var p=1;var v=2;var y={};var h=function(e,t,r){i(function(){g(e,t,r)})};var g=function(e,t,r){var n,o;if(t===y){return e(r)}try{n=e(r);o=t.resolve}catch(i){n=i;o=t.reject}o(n)};var d=function(e,t){var r=e._promise;var n=r.reactionLength;if(n>0){h(r.fulfillReactionHandler0,r.reactionCapability0,t);r.fulfillReactionHandler0=void 0;r.rejectReactions0=void 0;r.reactionCapability0=void 0;if(n>1){for(var o=1,i=0;o0){h(r.rejectReactionHandler0,r.reactionCapability0,t);r.fulfillReactionHandler0=void 0;r.rejectReactions0=void 0;r.reactionCapability0=void 0;if(n>1){for(var o=1,i=0;o2&&arguments[2]===y;if(b&&o===E){i=y}else{i=new r(o)}var g=re.IsCallable(e)?e:a;var d=re.IsCallable(t)?t:u;var O=n._promise;var m;if(O.state===f){if(O.reactionLength===0){O.fulfillReactionHandler0=g;O.rejectReactionHandler0=d;O.reactionCapability0=i}else{var w=3*(O.reactionLength-1);O[w+l]=g;O[w+p]=d;O[w+v]=i}O.reactionLength+=1}else if(O.state===s){m=O.result;h(g,i,m)}else if(O.state===c){m=O.result;h(d,i,m)}else{throw new TypeError("unexpected Promise state")}return i.promise}});y=new r(E);I=T.then;return E}();if(S.Promise){delete S.Promise.accept;delete S.Promise.defer;delete S.Promise.prototype.chain}if(typeof Cr==="function"){b(S,{Promise:Cr});var Mr=w(S.Promise,function(e){return e.resolve(42).then(function(){})instanceof e});var xr=!i(function(){S.Promise.reject(42).then(null,5).then(null,W)});var Nr=i(function(){S.Promise.call(3,W)});var Ar=function(e){var t=e.resolve(5);t.constructor={};var r=e.resolve(t);try{r.then(null,W).then(null,W)}catch(n){return true}return t===r}(S.Promise);var Rr=s&&function(){var e=0;var t=Object.defineProperty({},"then",{get:function(){e+=1}});Promise.resolve(t);return e===1}();var _r=function BadResolverPromise(e){var t=new Promise(e);e(3,function(){});this.then=t.then;this.constructor=BadResolverPromise};_r.prototype=Promise.prototype;_r.all=Promise.all;var kr=a(function(){return!!_r.all([1,2])});if(!Mr||!xr||!Nr||Ar||!Rr||kr){Promise=Cr;Z(S,"Promise",Cr)}if(Promise.all.length!==1){var Fr=Promise.all;Z(Promise,"all",function all(e){return re.Call(Fr,this,arguments)})}if(Promise.race.length!==1){var Lr=Promise.race;Z(Promise,"race",function race(e){return re.Call(Lr,this,arguments)})}if(Promise.resolve.length!==1){var Dr=Promise.resolve;Z(Promise,"resolve",function resolve(e){return re.Call(Dr,this,arguments)})}if(Promise.reject.length!==1){var zr=Promise.reject;Z(Promise,"reject",function reject(e){return re.Call(zr,this,arguments)})}wt(Promise,"all");wt(Promise,"race");wt(Promise,"resolve");wt(Promise,"reject");me(Promise)}var qr=function(e){var t=n(p(e,function(e,t){e[t]=true;return e},{}));return e.join(":")===t.join(":")};var Wr=qr(["z","a","bb"]);var Gr=qr(["z",1,"a","3",2]);if(s){var Hr=function fastkey(e){if(!Wr){return null}if(typeof e==="undefined"||e===null){return"^"+re.ToString(e)}else if(typeof e==="string"){return"$"+e}else if(typeof e==="number"){if(!Gr){return"n"+e}return e}else if(typeof e==="boolean"){return"b"+e}return null};var Vr=function emptyObject(){return Object.create?Object.create(null):{}};var Br=function addIterableToMap(e,n,o){if(r(o)||K.string(o)){l(o,function(e){if(!re.TypeIsObject(e)){throw new TypeError("Iterator value "+e+" is not an entry object")}n.set(e[0],e[1])})}else if(o instanceof e){t(e.prototype.forEach,o,function(e,t){n.set(t,e)})}else{var i,a;if(o!==null&&typeof o!=="undefined"){a=n.set;if(!re.IsCallable(a)){throw new TypeError("bad map")}i=re.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=re.IteratorStep(i);if(u===false){break}var f=u.value;try{if(!re.TypeIsObject(f)){throw new TypeError("Iterator value "+f+" is not an entry object")}t(a,n,f[0],f[1])}catch(s){re.IteratorClose(i,true);throw s}}}}};var $r=function addIterableToSet(e,n,o){if(r(o)||K.string(o)){l(o,function(e){n.add(e)})}else if(o instanceof e){t(e.prototype.forEach,o,function(e){n.add(e)})}else{var i,a;if(o!==null&&typeof o!=="undefined"){a=n.add;if(!re.IsCallable(a)){throw new TypeError("bad set")}i=re.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=re.IteratorStep(i);if(u===false){break}var f=u.value;try{t(a,n,f)}catch(s){re.IteratorClose(i,true);throw s}}}}};var Ur={Map:function(){var e={};var r=function MapEntry(e,t){this.key=e;this.value=t;this.next=null;this.prev=null};r.prototype.isRemoved=function isRemoved(){return this.key===e};var n=function isMap(e){return!!e._es6map};var o=function requireMapSlot(e,t){if(!re.TypeIsObject(e)||!n(e)){throw new TypeError("Method Map.prototype."+t+" called on incompatible receiver "+re.ToString(e))}};var i=function MapIterator(e,t){o(e,"[[MapIterator]]");this.head=e._head;this.i=this.head;this.kind=t};i.prototype={next:function next(){var e=this.i;var t=this.kind;var r=this.head;if(typeof this.i==="undefined"){return Ge()}while(e.isRemoved()&&e!==r){e=e.prev}var n;while(e.next!==r){e=e.next;if(!e.isRemoved()){if(t==="key"){n=e.key}else if(t==="value"){n=e.value}else{n=[e.key,e.value]}this.i=e;return Ge(n)}}this.i=void 0;return Ge()}};we(i.prototype);var a;var u=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}if(this&&this._es6map){throw new TypeError("Bad construction")}var e=Te(this,Map,a,{_es6map:true,_head:null,_storage:Vr(),_size:0});var t=new r(null,null);t.next=t.prev=t;e._head=t;if(arguments.length>0){Br(Map,e,arguments[0])}return e};a=u.prototype;O.getter(a,"size",function(){if(typeof this._size==="undefined"){throw new TypeError("size method called on incompatible Map")}return this._size});b(a,{get:function get(e){o(this,"get");var t=Hr(e);if(t!==null){var r=this._storage[t];if(r){return r.value}else{return}}var n=this._head;var i=n;while((i=i.next)!==n){if(re.SameValueZero(i.key,e)){return i.value}}},has:function has(e){o(this,"has");var t=Hr(e);if(t!==null){return typeof this._storage[t]!=="undefined"}var r=this._head;var n=r;while((n=n.next)!==r){if(re.SameValueZero(n.key,e)){return true}}return false},set:function set(e,t){o(this,"set");var n=this._head;var i=n;var a;var u=Hr(e);if(u!==null){if(typeof this._storage[u]!=="undefined"){this._storage[u].value=t;return this}else{a=this._storage[u]=new r(e,t);i=n.prev}}while((i=i.next)!==n){if(re.SameValueZero(i.key,e)){i.value=t;return this}}a=a||new r(e,t);if(re.SameValue(-0,e)){a.key=+0}a.next=this._head;a.prev=this._head.prev;a.prev.next=a;a.next.prev=a;this._size+=1;return this},"delete":function(t){o(this,"delete");var r=this._head;var n=r;var i=Hr(t);if(i!==null){if(typeof this._storage[i]==="undefined"){return false}n=this._storage[i].prev;delete this._storage[i]}while((n=n.next)!==r){if(re.SameValueZero(n.key,t)){n.key=n.value=e;n.prev.next=n.next;n.next.prev=n.prev;this._size-=1;return true}}return false},clear:function clear(){o(this,"clear");this._size=0;this._storage=Vr();var t=this._head;var r=t;var n=r.next;while((r=n)!==t){r.key=r.value=e;n=r.next;r.next=r.prev=t}t.next=t.prev=t},keys:function keys(){o(this,"keys");return new i(this,"key")},values:function values(){o(this,"values");return new i(this,"value")},entries:function entries(){o(this,"entries");return new i(this,"key+value")},forEach:function forEach(e){o(this,"forEach");var r=arguments.length>1?arguments[1]:null;var n=this.entries();for(var i=n.next();!i.done;i=n.next()){if(r){t(e,r,i.value[1],i.value[0],this)}else{e(i.value[1],i.value[0],this)}}}});we(a,a.entries);return u}(),Set:function(){var e=function isSet(e){return e._es6set&&typeof e._storage!=="undefined"};var r=function requireSetSlot(t,r){if(!re.TypeIsObject(t)||!e(t)){throw new TypeError("Set.prototype."+r+" called on incompatible receiver "+re.ToString(t))}};var o;var i=function Set(){if(!(this instanceof Set)){throw new TypeError('Constructor Set requires "new"')}if(this&&this._es6set){throw new TypeError("Bad construction")}var e=Te(this,Set,o,{_es6set:true,"[[SetData]]":null,_storage:Vr()});if(!e._es6set){throw new TypeError("bad set")}if(arguments.length>0){$r(Set,e,arguments[0])}return e};o=i.prototype;var a=function(e){var t=e;if(t==="^null"){return null}else if(t==="^undefined"){return void 0}else{var r=t.charAt(0);if(r==="$"){return C(t,1)}else if(r==="n"){return+C(t,1)}else if(r==="b"){return t==="btrue"}}return+t};var u=function ensureMap(e){if(!e["[[SetData]]"]){var t=e["[[SetData]]"]=new Ur.Map;l(n(e._storage),function(e){var r=a(e);t.set(r,r)});e["[[SetData]]"]=t}e._storage=null};O.getter(i.prototype,"size",function(){r(this,"size");if(this._storage){return n(this._storage).length}u(this);return this["[[SetData]]"].size});b(i.prototype,{has:function has(e){r(this,"has");var t;if(this._storage&&(t=Hr(e))!==null){return!!this._storage[t]}u(this);return this["[[SetData]]"].has(e)},add:function add(e){r(this,"add");var t;if(this._storage&&(t=Hr(e))!==null){this._storage[t]=true;return this}u(this);this["[[SetData]]"].set(e,e);return this},"delete":function(e){r(this,"delete");var t;if(this._storage&&(t=Hr(e))!==null){var n=z(this._storage,t);return delete this._storage[t]&&n}u(this);return this["[[SetData]]"]["delete"](e)},clear:function clear(){r(this,"clear");if(this._storage){this._storage=Vr()}if(this["[[SetData]]"]){this["[[SetData]]"].clear()}},values:function values(){r(this,"values");u(this);return this["[[SetData]]"].values()},entries:function entries(){r(this,"entries");u(this);return this["[[SetData]]"].entries()},forEach:function forEach(e){r(this,"forEach");var n=arguments.length>1?arguments[1]:null;var o=this;u(o);this["[[SetData]]"].forEach(function(r,i){if(n){t(e,n,i,i,o)}else{e(i,i,o)}})}});h(i.prototype,"keys",i.prototype.values,true);we(i.prototype,i.prototype.values);return i}()};if(S.Map||S.Set){var Jr=a(function(){return new Map([[1,2]]).get(1)===2});if(!Jr){var Xr=S.Map;S.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new Xr;if(arguments.length>0){Br(Map,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,S.Map.prototype);return e};S.Map.prototype=m(Xr.prototype);h(S.Map.prototype,"constructor",S.Map,true);O.preserveToString(S.Map,Xr)}var Kr=new Map;var Zr=function(){var e=new Map([[1,0],[2,0],[3,0],[4,0]]);e.set(-0,e);return e.get(0)===e&&e.get(-0)===e&&e.has(0)&&e.has(-0)}();var Yr=Kr.set(1,2)===Kr;if(!Zr||!Yr){var Qr=Map.prototype.set;Z(Map.prototype,"set",function set(e,r){t(Qr,this,e===0?0:e,r);return this})}if(!Zr){var en=Map.prototype.get;var tn=Map.prototype.has;b(Map.prototype,{get:function get(e){return t(en,this,e===0?0:e)},has:function has(e){return t(tn,this,e===0?0:e)}},true);O.preserveToString(Map.prototype.get,en);O.preserveToString(Map.prototype.has,tn)}var rn=new Set;var nn=function(e){e["delete"](0);e.add(-0);return!e.has(0)}(rn);var on=rn.add(1)===rn;if(!nn||!on){var an=Set.prototype.add;Set.prototype.add=function add(e){t(an,this,e===0?0:e);return this};O.preserveToString(Set.prototype.add,an)}if(!nn){var un=Set.prototype.has;Set.prototype.has=function has(e){return t(un,this,e===0?0:e)};O.preserveToString(Set.prototype.has,un);var fn=Set.prototype["delete"];Set.prototype["delete"]=function SetDelete(e){return t(fn,this,e===0?0:e)};O.preserveToString(Set.prototype["delete"],fn)}var sn=w(S.Map,function(e){var t=new e([]);t.set(42,42);return t instanceof e});var cn=Object.setPrototypeOf&&!sn;var ln=function(){try{return!(S.Map()instanceof S.Map)}catch(e){return e instanceof TypeError}}();if(S.Map.length!==0||cn||!ln){var pn=S.Map;S.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new pn;if(arguments.length>0){Br(Map,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,Map.prototype);return e};S.Map.prototype=pn.prototype;h(S.Map.prototype,"constructor",S.Map,true);O.preserveToString(S.Map,pn)}var vn=w(S.Set,function(e){var t=new e([]);t.add(42,42);return t instanceof e});var yn=Object.setPrototypeOf&&!vn;var hn=function(){try{return!(S.Set()instanceof S.Set)}catch(e){return e instanceof TypeError}}();if(S.Set.length!==0||yn||!hn){var bn=S.Set;S.Set=function Set(){if(!(this instanceof Set)){throw new TypeError('Constructor Set requires "new"')}var e=new bn;if(arguments.length>0){$r(Set,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,Set.prototype);return e};S.Set.prototype=bn.prototype;h(S.Set.prototype,"constructor",S.Set,true);O.preserveToString(S.Set,bn)}var gn=new S.Map;var dn=!a(function(){return gn.keys().next().done});if(typeof S.Map.prototype.clear!=="function"||(new S.Set).size!==0||gn.size!==0||typeof S.Map.prototype.keys!=="function"||typeof S.Set.prototype.keys!=="function"||typeof S.Map.prototype.forEach!=="function"||typeof S.Set.prototype.forEach!=="function"||u(S.Map)||u(S.Set)||typeof gn.keys().next!=="function"||dn||!sn){b(S,{Map:Ur.Map,Set:Ur.Set},true)}if(S.Set.prototype.keys!==S.Set.prototype.values){h(S.Set.prototype,"keys",S.Set.prototype.values,true)}we(Object.getPrototypeOf((new S.Map).keys()));we(Object.getPrototypeOf((new S.Set).keys()));if(c&&S.Set.prototype.has.name!=="has"){var On=S.Set.prototype.has;Z(S.Set.prototype,"has",function has(e){return t(On,this,e)})}}b(S,Ur);me(S.Map);me(S.Set)}var mn=function throwUnlessTargetIsObject(e){if(!re.TypeIsObject(e)){throw new TypeError("target must be an object")}};var wn={apply:function apply(){return re.Call(re.Call,null,arguments)},construct:function construct(e,t){if(!re.IsConstructor(e)){throw new TypeError("First argument must be a constructor.")}var r=arguments.length>2?arguments[2]:e;if(!re.IsConstructor(r)){throw new TypeError("new.target must be a constructor.")}return re.Construct(e,t,r,"internal")},deleteProperty:function deleteProperty(e,t){mn(e);if(s){var r=Object.getOwnPropertyDescriptor(e,t);if(r&&!r.configurable){return false}}return delete e[t]},has:function has(e,t){mn(e);return t in e}};if(Object.getOwnPropertyNames){Object.assign(wn,{ownKeys:function ownKeys(e){mn(e);var t=Object.getOwnPropertyNames(e);if(re.IsCallable(Object.getOwnPropertySymbols)){x(t,Object.getOwnPropertySymbols(e))}return t}})}var jn=function ConvertExceptionToBoolean(e){return!i(e)};if(Object.preventExtensions){Object.assign(wn,{isExtensible:function isExtensible(e){mn(e);return Object.isExtensible(e)},preventExtensions:function preventExtensions(e){mn(e);return jn(function(){Object.preventExtensions(e)})}})}if(s){var Sn=function get(e,t,r){var n=Object.getOwnPropertyDescriptor(e,t);if(!n){var o=Object.getPrototypeOf(e);if(o===null){return void 0}return Sn(o,t,r)}if("value"in n){return n.value}if(n.get){return re.Call(n.get,r)}return void 0};var Tn=function set(e,r,n,o){var i=Object.getOwnPropertyDescriptor(e,r);if(!i){var a=Object.getPrototypeOf(e);if(a!==null){return Tn(a,r,n,o)}i={value:void 0,writable:true,enumerable:true,configurable:true}}if("value"in i){if(!i.writable){return false}if(!re.TypeIsObject(o)){return false}var u=Object.getOwnPropertyDescriptor(o,r);if(u){return ee.defineProperty(o,r,{value:n})}else{return ee.defineProperty(o,r,{value:n,writable:true,enumerable:true,configurable:true})}}if(i.set){t(i.set,o,n);return true}return false};Object.assign(wn,{defineProperty:function defineProperty(e,t,r){mn(e);return jn(function(){Object.defineProperty(e,t,r)})},getOwnPropertyDescriptor:function getOwnPropertyDescriptor(e,t){mn(e);return Object.getOwnPropertyDescriptor(e,t)},get:function get(e,t){mn(e);var r=arguments.length>2?arguments[2]:e;return Sn(e,t,r)},set:function set(e,t,r){mn(e);var n=arguments.length>3?arguments[3]:e;return Tn(e,t,r,n)}})}if(Object.getPrototypeOf){var In=Object.getPrototypeOf;wn.getPrototypeOf=function getPrototypeOf(e){mn(e);return In(e)}}if(Object.setPrototypeOf&&wn.getPrototypeOf){var En=function(e,t){var r=t;while(r){if(e===r){return true}r=wn.getPrototypeOf(r)}return false};Object.assign(wn,{setPrototypeOf:function setPrototypeOf(e,t){mn(e);if(t!==null&&!re.TypeIsObject(t)){throw new TypeError("proto must be an object or null")}if(t===ee.getPrototypeOf(e)){return true}if(ee.isExtensible&&!ee.isExtensible(e)){return false}if(En(e,t)){return false}Object.setPrototypeOf(e,t);return true}})}var Pn=function(e,t){if(!re.IsCallable(S.Reflect[e])){h(S.Reflect,e,t)}else{var r=a(function(){S.Reflect[e](1);S.Reflect[e](NaN);S.Reflect[e](true);return true});if(r){Z(S.Reflect,e,t)}}};Object.keys(wn).forEach(function(e){Pn(e,wn[e])});var Cn=S.Reflect.getPrototypeOf;if(c&&Cn&&Cn.name!=="getPrototypeOf"){Z(S.Reflect,"getPrototypeOf",function getPrototypeOf(e){return t(Cn,S.Reflect,e)})}if(S.Reflect.setPrototypeOf){if(a(function(){S.Reflect.setPrototypeOf(1,{});return true})){Z(S.Reflect,"setPrototypeOf",wn.setPrototypeOf)}}if(S.Reflect.defineProperty){if(!a(function(){var e=!S.Reflect.defineProperty(1,"test",{value:1});var t=typeof Object.preventExtensions!=="function"||!S.Reflect.defineProperty(Object.preventExtensions({}),"test",{});return e&&t})){Z(S.Reflect,"defineProperty",wn.defineProperty)}}if(S.Reflect.construct){if(!a(function(){var e=function F(){};return S.Reflect.construct(function(){},[],e)instanceof e})){Z(S.Reflect,"construct",wn.construct)}}if(String(new Date(NaN))!=="Invalid Date"){var Mn=Date.prototype.toString;var xn=function toString(){var e=+this;if(e!==e){return"Invalid Date"}return re.Call(Mn,this)};Z(Date.prototype,"toString",xn)}var Nn={anchor:function anchor(e){return re.CreateHTML(this,"a","name",e)},big:function big(){return re.CreateHTML(this,"big","","")},blink:function blink(){return re.CreateHTML(this,"blink","","")},bold:function bold(){return re.CreateHTML(this,"b","","")},fixed:function fixed(){return re.CreateHTML(this,"tt","","")},fontcolor:function fontcolor(e){return re.CreateHTML(this,"font","color",e)},fontsize:function fontsize(e){return re.CreateHTML(this,"font","size",e)},italics:function italics(){return re.CreateHTML(this,"i","","")},link:function link(e){return re.CreateHTML(this,"a","href",e)},small:function small(){return re.CreateHTML(this,"small","","")},strike:function strike(){return re.CreateHTML(this,"strike","","")},sub:function sub(){return re.CreateHTML(this,"sub","","")},sup:function sub(){return re.CreateHTML(this,"sup","","")}};l(Object.keys(Nn),function(e){var r=String.prototype[e];var n=false;if(re.IsCallable(r)){var o=t(r,"",' " ');var i=P([],o.match(/"/g)).length;n=o!==o.toLowerCase()||i>2}else{n=true}if(n){Z(String.prototype,e,Nn[e])}});var An=function(){if(!Y){return false}var e=typeof JSON==="object"&&typeof JSON.stringify==="function"?JSON.stringify:null;if(!e){return false}if(typeof e(G())!=="undefined"){return true}if(e([G()])!=="[null]"){return true}var t={a:G()};t[G()]=true;if(e(t)!=="{}"){return true}return false}();var Rn=a(function(){if(!Y){return true}return JSON.stringify(Object(G()))==="{}"&&JSON.stringify([Object(G())])==="[{}]"});if(An||!Rn){var _n=JSON.stringify;Z(JSON,"stringify",function stringify(e){if(typeof e==="symbol"){return}var n;if(arguments.length>1){n=arguments[1]}var o=[e];if(!r(n)){var i=re.IsCallable(n)?n:null;var a=function(e,r){var n=i?t(i,this,e,r):r;if(typeof n!=="symbol"){if(K.symbol(n)){return St({})(n)}else{return n}}};o.push(a)}else{o.push(n)}if(arguments.length>2){o.push(arguments[2])}return _n.apply(this,o)})}return S}); -//# sourceMappingURL=es6-shim.map diff --git a/accessible/media/accessible.css b/accessible/media/accessible.css deleted file mode 100644 index 285fe8a9509..00000000000 --- a/accessible/media/accessible.css +++ /dev/null @@ -1,80 +0,0 @@ -.blocklyWorkspaceColumn { - float: left; - margin-right: 20px; - width: 800px; -} -.blocklySidebarColumn { - border-left: 1px solid #888; - float: left; - padding-left: 20px; - margin-top: 20px; - min-height: 700px; - width: 200px; -} - -.blocklySidebarButton { - background-color: #fff; - border: 1px solid #333; - border-radius: 4px; - color: #000; - font-size: 1em; - margin: 10px 0 10px 30px; - padding: 10px; - text-align: center; - vertical-align: middle; - white-space: nowrap; -} -.blocklySidebarButton[disabled] { - border: 1px solid #ccc; - opacity: .5; -} - -.blocklyAriaLiveStatus { - background: #c8f7be; - border-radius: 10px; - bottom: 80px; - left: 20px; - max-width: 275px; - padding: 10px; - position: fixed; -} - -.blocklyTree .blocklyActiveDescendant > label, -.blocklyTree .blocklyActiveDescendant > div > label, -.blocklyActiveDescendant > button, -.blocklyActiveDescendant > input, -.blocklyActiveDescendant > select, -.blocklyActiveDescendant > blockly-field-segment > label, -.blocklyActiveDescendant > blockly-field-segment > input, -.blocklyActiveDescendant > blockly-field-segment > select { - outline: 2px dotted #00f; -} - -.blocklyDropdownListItem[aria-selected="true"] button { - font-weight: bold; -} - -.blocklyModalCurtain { - background-color: rgba(0,0,0,0.4); - height: 100%; - left: 0; - overflow: auto; - position: fixed; - top: 0; - width: 100%; - z-index: 1; -} -.blocklyModal { - background-color: #fefefe; - border: 1px solid #888; - margin: 10% auto; - max-width: 600px; - padding: 20px; - width: 60%; -} -.blocklyModalButtonContainer { - margin: 10px 0; -} -.blocklyModal .activeButton { - border: 1px solid blue; -} diff --git a/accessible/media/click.mp3 b/accessible/media/click.mp3 deleted file mode 100644 index 4534b0ddca7..00000000000 Binary files a/accessible/media/click.mp3 and /dev/null differ diff --git a/accessible/media/click.ogg b/accessible/media/click.ogg deleted file mode 100644 index e8ae42a6106..00000000000 Binary files a/accessible/media/click.ogg and /dev/null differ diff --git a/accessible/media/click.wav b/accessible/media/click.wav deleted file mode 100644 index 41a50cd76f5..00000000000 Binary files a/accessible/media/click.wav and /dev/null differ diff --git a/accessible/media/delete.mp3 b/accessible/media/delete.mp3 deleted file mode 100644 index 1e71bdcf498..00000000000 Binary files a/accessible/media/delete.mp3 and /dev/null differ diff --git a/accessible/media/delete.ogg b/accessible/media/delete.ogg deleted file mode 100644 index a65b1122839..00000000000 Binary files a/accessible/media/delete.ogg and /dev/null differ diff --git a/accessible/media/delete.wav b/accessible/media/delete.wav deleted file mode 100644 index 455bcd3bb11..00000000000 Binary files a/accessible/media/delete.wav and /dev/null differ diff --git a/accessible/media/oops.mp3 b/accessible/media/oops.mp3 deleted file mode 100644 index 0c9507140b5..00000000000 Binary files a/accessible/media/oops.mp3 and /dev/null differ diff --git a/accessible/media/oops.ogg b/accessible/media/oops.ogg deleted file mode 100644 index 7bac05d97ed..00000000000 Binary files a/accessible/media/oops.ogg and /dev/null differ diff --git a/accessible/media/oops.wav b/accessible/media/oops.wav deleted file mode 100644 index 163df4f1cf7..00000000000 Binary files a/accessible/media/oops.wav and /dev/null differ diff --git a/accessible/messages.js b/accessible/messages.js deleted file mode 100644 index 60c51d34415..00000000000 --- a/accessible/messages.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Visual Blocks Language - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Translatable string constants for Accessible Blockly. - * @author madeeha@google.com (Madeeha Ghori) - */ -'use strict'; - -Blockly.Msg.WORKSPACE = 'Workspace'; -Blockly.Msg.WORKSPACE_BLOCK = - 'workspace block. Move right to edit. Press Enter for more options.'; - -Blockly.Msg.ATTACH_NEW_BLOCK_TO_LINK = 'Attach new block to link...'; -Blockly.Msg.CREATE_NEW_BLOCK_GROUP = 'Create new block group...'; -Blockly.Msg.ERASE_WORKSPACE = 'Erase Workspace'; -Blockly.Msg.NO_BLOCKS_IN_WORKSPACE = 'There are no blocks in the workspace.'; - -Blockly.Msg.COPY_BLOCK = 'Copy block'; -Blockly.Msg.DELETE = 'Delete block'; -Blockly.Msg.MARK_SPOT_BEFORE = 'Add link before'; -Blockly.Msg.MARK_SPOT_AFTER = 'Add link after'; -Blockly.Msg.MARK_THIS_SPOT = 'Add link inside'; -Blockly.Msg.MOVE_TO_MARKED_SPOT = 'Move to existing link'; -Blockly.Msg.PASTE_AFTER = 'Paste after'; -Blockly.Msg.PASTE_BEFORE = 'Paste before'; -Blockly.Msg.PASTE_INSIDE = 'Paste inside'; - -Blockly.Msg.BLOCK_OPTIONS = 'Block Options'; -Blockly.Msg.SELECT_A_BLOCK = 'Select a block...'; -Blockly.Msg.CANCEL = 'Cancel'; - -Blockly.Msg.ANY = 'any'; -Blockly.Msg.BLOCK = 'block'; -Blockly.Msg.BUTTON = 'Button.'; -Blockly.Msg.FOR = 'for'; -Blockly.Msg.VALUE = 'value'; - -Blockly.Msg.ADDED_LINK_MSG = 'Added link.'; -Blockly.Msg.ATTACHED_BLOCK_TO_LINK_MSG = 'attached to link. '; -Blockly.Msg.COPIED_BLOCK_MSG = 'copied. '; -Blockly.Msg.PASTED_BLOCK_FROM_CLIPBOARD_MSG = 'pasted. '; - -Blockly.Msg.PRESS_ENTER_TO_EDIT_NUMBER = 'Press Enter to edit number. '; -Blockly.Msg.PRESS_ENTER_TO_EDIT_TEXT = 'Press Enter to edit text. '; diff --git a/accessible/notifications.service.js b/accessible/notifications.service.js deleted file mode 100644 index b1ce22b27e6..00000000000 --- a/accessible/notifications.service.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service for updating the ARIA live region that - * allows screenreaders to notify the user about actions that they have taken. - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.NotificationsService'); - - -blocklyApp.NotificationsService = ng.core.Class({ - constructor: [function() { - this.currentMessage = ''; - this.timeouts = []; - }], - setDisplayedMessage_: function(newMessage) { - this.currentMessage = newMessage; - }, - getDisplayedMessage: function() { - return this.currentMessage; - }, - speak: function(newMessage) { - // Clear and reset any existing timeouts. - this.timeouts.forEach(function(timeout) { - clearTimeout(timeout); - }); - this.timeouts.length = 0; - - // Clear the current message, so that if, e.g., two operations of the same - // type are performed, both messages will be read in succession. - this.setDisplayedMessage_(''); - - // We need a non-zero timeout here, otherwise NVDA does not read the - // notification messages properly. - var that = this; - this.timeouts.push(setTimeout(function() { - that.setDisplayedMessage_(newMessage); - }, 20)); - this.timeouts.push(setTimeout(function() { - that.setDisplayedMessage_(''); - }, 5000)); - } -}); diff --git a/accessible/sidebar.component.js b/accessible/sidebar.component.js deleted file mode 100644 index 66f735eda26..00000000000 --- a/accessible/sidebar.component.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Component representing the sidebar that is shown next - * to the workspace. - * - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.SidebarComponent'); - -goog.require('blocklyApp.UtilsService'); - -goog.require('blocklyApp.BlockConnectionService'); -goog.require('blocklyApp.ToolboxModalService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.TreeService'); -goog.require('blocklyApp.VariableModalService'); - - -blocklyApp.SidebarComponent = ng.core.Component({ - selector: 'blockly-sidebar', - template: ` -
- - - - - -
- `, - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.BlockConnectionService, - blocklyApp.ToolboxModalService, - blocklyApp.TreeService, - blocklyApp.UtilsService, - blocklyApp.VariableModalService, - function( - blockConnectionService, toolboxModalService, treeService, - utilsService, variableService) { - // ACCESSIBLE_GLOBALS is a global variable defined by the containing - // page. It should contain a key, customSidebarButtons, describing - // additional buttons that should be displayed after the default ones. - // See README.md for details. - this.customSidebarButtons = - ACCESSIBLE_GLOBALS && ACCESSIBLE_GLOBALS.customSidebarButtons ? - ACCESSIBLE_GLOBALS.customSidebarButtons : []; - - this.blockConnectionService = blockConnectionService; - this.toolboxModalService = toolboxModalService; - this.treeService = treeService; - this.utilsService = utilsService; - this.variableModalService = variableService; - - this.ID_FOR_ATTACH_TO_LINK_BUTTON = 'blocklyAttachToLinkBtn'; - this.ID_FOR_CREATE_NEW_GROUP_BUTTON = 'blocklyCreateNewGroupBtn'; - } - ], - isAnyConnectionMarked: function() { - return this.blockConnectionService.isAnyConnectionMarked(); - }, - isWorkspaceEmpty: function() { - return this.utilsService.isWorkspaceEmpty(); - }, - hasVariableCategory: function() { - return this.toolboxModalService.toolboxHasVariableCategory(); - }, - clearWorkspace: function() { - blocklyApp.workspace.clear(); - this.treeService.clearAllActiveDescs(); - // The timeout is needed in order to give the blocks time to be cleared - // from the workspace, and for the 'workspace is empty' button to show up. - setTimeout(function() { - document.getElementById(blocklyApp.ID_FOR_EMPTY_WORKSPACE_BTN).focus(); - }, 50); - }, - showToolboxModalForAttachToMarkedConnection: function() { - this.toolboxModalService.showToolboxModalForAttachToMarkedConnection( - this.ID_FOR_ATTACH_TO_LINK_BUTTON); - }, - showToolboxModalForCreateNewGroup: function() { - this.toolboxModalService.showToolboxModalForCreateNewGroup( - this.ID_FOR_CREATE_NEW_GROUP_BUTTON); - }, - showAddVariableModal: function() { - this.variableModalService.showAddModal_("item"); - } -}); diff --git a/accessible/toolbox-modal.component.js b/accessible/toolbox-modal.component.js deleted file mode 100644 index 25358e82eef..00000000000 --- a/accessible/toolbox-modal.component.js +++ /dev/null @@ -1,188 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Component representing the toolbox modal. - * - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.ToolboxModalComponent'); - -goog.require('Blockly.CommonModal'); -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.KeyboardInputService'); -goog.require('blocklyApp.ToolboxModalService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.TreeService'); -goog.require('blocklyApp.UtilsService'); - - -blocklyApp.ToolboxModalComponent = ng.core.Component({ - selector: 'blockly-toolbox-modal', - template: ` -
- -
-

{{'SELECT_A_BLOCK'|translate}}

- -
-

{{toolboxCategory.categoryName}}

-
- -
-
-
-
- -
-
-
- `, - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.ToolboxModalService, blocklyApp.KeyboardInputService, - blocklyApp.AudioService, blocklyApp.UtilsService, blocklyApp.TreeService, - function( - toolboxModalService_, keyboardInputService_, audioService_, - utilsService_, treeService_) { - this.toolboxModalService = toolboxModalService_; - this.keyboardInputService = keyboardInputService_; - this.audioService = audioService_; - this.utilsService = utilsService_; - this.treeService = treeService_; - - this.modalIsVisible = false; - this.toolboxCategories = []; - this.onSelectBlockCallback = null; - this.onDismissCallback = null; - - this.firstBlockIndexes = []; - this.activeButtonIndex = -1; - this.totalNumBlocks = 0; - - var that = this; - this.toolboxModalService.registerPreShowHook( - function( - toolboxCategories, onSelectBlockCallback, onDismissCallback) { - that.modalIsVisible = true; - that.toolboxCategories = toolboxCategories; - that.onSelectBlockCallback = onSelectBlockCallback; - that.onDismissCallback = onDismissCallback; - - // The indexes of the buttons corresponding to the first block in - // each category, as well as the 'cancel' button at the end. - that.firstBlockIndexes = []; - that.activeButtonIndex = -1; - that.totalNumBlocks = 0; - - var cumulativeIndex = 0; - that.toolboxCategories.forEach(function(category) { - that.firstBlockIndexes.push(cumulativeIndex); - cumulativeIndex += category.blocks.length; - }); - that.firstBlockIndexes.push(cumulativeIndex); - that.totalNumBlocks = cumulativeIndex; - - Blockly.CommonModal.setupKeyboardOverrides(that); - that.keyboardInputService.addOverride('13', function(evt) { - evt.preventDefault(); - evt.stopPropagation(); - - if (that.activeButtonIndex == -1) { - return; - } - - var button = document.getElementById( - that.getOptionId(that.activeButtonIndex)); - - for (var i = 0; i < that.toolboxCategories.length; i++) { - if (that.firstBlockIndexes[i + 1] > that.activeButtonIndex) { - var categoryIndex = i; - var blockIndex = - that.activeButtonIndex - that.firstBlockIndexes[i]; - var block = that.getBlock(categoryIndex, blockIndex); - that.selectBlock(block); - return; - } - } - - // The 'Cancel' button has been pressed. - that.dismissModal(); - }); - - setTimeout(function() { - document.getElementById('toolboxModal').focus(); - }, 150); - } - ); - } - ], - // Closes the modal (on both success and failure). - hideModal_: Blockly.CommonModal.hideModal, - // Focuses on the button represented by the given index. - focusOnOption: function(index) { - var button = document.getElementById(this.getOptionId(index)); - button.focus(); - }, - // Counts the number of interactive elements for the modal. - numInteractiveElements: function() { - return this.totalNumBlocks + 1; - }, - getOverallIndex: function(categoryIndex, blockIndex) { - return this.firstBlockIndexes[categoryIndex] + blockIndex; - }, - getBlock: function(categoryIndex, blockIndex) { - return this.toolboxCategories[categoryIndex].blocks[blockIndex]; - }, - getBlockDescription: function(block) { - return this.utilsService.getBlockDescription(block); - }, - // Returns the ID for the corresponding option button. - getOptionId: function(index) { - return 'toolbox-modal-option-' + index; - }, - // Returns the ID for the "cancel" option button. - getCancelOptionId: function() { - return 'toolbox-modal-option-' + this.totalNumBlocks; - }, - selectBlock: function(block) { - this.onSelectBlockCallback(block); - this.hideModal_(); - }, - // Dismisses and closes the modal. - dismissModal: function() { - this.hideModal_(); - this.onDismissCallback(); - } -}); diff --git a/accessible/toolbox-modal.service.js b/accessible/toolbox-modal.service.js deleted file mode 100644 index 70c665c4d5c..00000000000 --- a/accessible/toolbox-modal.service.js +++ /dev/null @@ -1,230 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service for the toolbox modal. - * - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.ToolboxModalService'); - -goog.require('blocklyApp.UtilsService'); - -goog.require('blocklyApp.BlockConnectionService'); -goog.require('blocklyApp.NotificationsService'); -goog.require('blocklyApp.TreeService'); - - -blocklyApp.ToolboxModalService = ng.core.Class({ - constructor: [ - blocklyApp.BlockConnectionService, - blocklyApp.NotificationsService, - blocklyApp.TreeService, - blocklyApp.UtilsService, - function( - blockConnectionService, notificationsService, treeService, - utilsService) { - this.blockConnectionService = blockConnectionService; - this.notificationsService = notificationsService; - this.treeService = treeService; - this.utilsService = utilsService; - - this.modalIsShown = false; - - this.selectedToolboxCategories = null; - this.onSelectBlockCallback = null; - this.onDismissCallback = null; - this.hasVariableCategory = null; - // The aim of the pre-show hook is to populate the modal component with - // the information it needs to display the modal (e.g., which categories - // and blocks to display). - this.preShowHook = function() { - throw Error( - 'A pre-show hook must be defined for the toolbox modal before it ' + - 'can be shown.'); - }; - } - ], - populateToolbox_: function() { - // Populate the toolbox categories. - this.allToolboxCategories = []; - var toolboxXmlElt = document.getElementById('blockly-toolbox-xml'); - var toolboxCategoryElts = toolboxXmlElt.getElementsByTagName('category'); - if (toolboxCategoryElts.length) { - this.allToolboxCategories = Array.from(toolboxCategoryElts).map( - function(categoryElt) { - var tmpWorkspace = new Blockly.Workspace(); - var custom = categoryElt.attributes.custom; - // TODO (corydiers): Implement custom flyouts once #1153 is solved. - if (custom && custom.value == Blockly.VARIABLE_CATEGORY_NAME) { - var varBlocks = - Blockly.Variables.flyoutCategoryBlocks(blocklyApp.workspace); - varBlocks.forEach(function(block) { - Blockly.Xml.domToBlock(block, tmpWorkspace); - }); - } else { - Blockly.Xml.domToWorkspace(categoryElt, tmpWorkspace); - } - return { - categoryName: categoryElt.attributes.name.value, - blocks: tmpWorkspace.topBlocks_ - }; - } - ); - this.computeCategoriesForCreateNewGroupModal_(); - } else { - var that = this; - // If there are no top-level categories, we create a single category - // containing all the top-level blocks. - var tmpWorkspace = new Blockly.Workspace(); - Array.from(toolboxXmlElt.children).forEach(function(topLevelNode) { - Blockly.Xml.domToBlock(topLevelNode, tmpWorkspace); - }); - - that.allToolboxCategories = [{ - categoryName: '', - blocks: tmpWorkspace.topBlocks_ - }]; - - that.computeCategoriesForCreateNewGroupModal_(); - } - }, - computeCategoriesForCreateNewGroupModal_: function() { - // Precompute toolbox categories for blocks that have no output - // connection (and that can therefore be used as the base block of a - // "create new block group" action). - this.toolboxCategoriesForNewGroup = []; - var that = this; - this.allToolboxCategories.forEach(function(toolboxCategory) { - var baseBlocks = toolboxCategory.blocks.filter(function(block) { - return !block.outputConnection; - }); - - if (baseBlocks.length > 0) { - that.toolboxCategoriesForNewGroup.push({ - categoryName: toolboxCategory.categoryName, - blocks: baseBlocks - }); - } - }); - }, - registerPreShowHook: function(preShowHook) { - var that = this; - this.preShowHook = function() { - preShowHook( - that.selectedToolboxCategories, that.onSelectBlockCallback, - that.onDismissCallback); - }; - }, - isModalShown: function() { - return this.modalIsShown; - }, - toolboxHasVariableCategory: function() { - if (this.hasVariableCategory === null) { - var toolboxXmlElt = document.getElementById('blockly-toolbox-xml'); - var toolboxCategoryElts = toolboxXmlElt.getElementsByTagName('category'); - var that = this; - Array.from(toolboxCategoryElts).forEach( - function(categoryElt) { - var custom = categoryElt.attributes.custom; - if (custom && custom.value == Blockly.VARIABLE_CATEGORY_NAME) { - that.hasVariableCategory = true; - } - }); - - if (this.hasVariableCategory === null) { - this.hasVariableCategory = false; - } - } - - return this.hasVariableCategory; - }, - showModal_: function( - selectedToolboxCategories, onSelectBlockCallback, onDismissCallback) { - this.selectedToolboxCategories = selectedToolboxCategories; - this.onSelectBlockCallback = onSelectBlockCallback; - this.onDismissCallback = onDismissCallback; - - this.preShowHook(); - this.modalIsShown = true; - }, - hideModal: function() { - this.modalIsShown = false; - }, - showToolboxModalForAttachToMarkedConnection: function(sourceButtonId) { - var that = this; - - var selectedToolboxCategories = []; - this.populateToolbox_(); - this.allToolboxCategories.forEach(function(toolboxCategory) { - var selectedBlocks = toolboxCategory.blocks.filter(function(block) { - return that.blockConnectionService.canBeAttachedToMarkedConnection( - block); - }); - - if (selectedBlocks.length > 0) { - selectedToolboxCategories.push({ - categoryName: toolboxCategory.categoryName, - blocks: selectedBlocks - }); - } - }); - - this.showModal_(selectedToolboxCategories, function(block) { - var blockDescription = that.utilsService.getBlockDescription(block); - - // Clear the active desc for the destination tree, so that it can be - // cleanly reinstated after the new block is attached. - var destinationTreeId = that.treeService.getTreeIdForBlock( - that.blockConnectionService.getMarkedConnectionSourceBlock().id); - that.treeService.clearActiveDesc(destinationTreeId); - var newBlockId = that.blockConnectionService.attachToMarkedConnection( - block); - - // Invoke a digest cycle, so that the DOM settles. - setTimeout(function() { - that.treeService.focusOnBlock(newBlockId); - that.notificationsService.speak( - 'Attached. Now on, ' + blockDescription + ', block in workspace.'); - }); - }, function() { - document.getElementById(sourceButtonId).focus(); - }); - }, - showToolboxModalForCreateNewGroup: function(sourceButtonId) { - var that = this; - this.populateToolbox_(); - this.showModal_(this.toolboxCategoriesForNewGroup, function(block) { - var blockDescription = that.utilsService.getBlockDescription(block); - var xml = Blockly.Xml.blockToDom(block); - var newBlockId = Blockly.Xml.domToBlock(xml, blocklyApp.workspace).id; - - // Invoke a digest cycle, so that the DOM settles. - setTimeout(function() { - that.treeService.focusOnBlock(newBlockId); - that.notificationsService.speak( - 'Created new group in workspace. Now on, ' + blockDescription + - ', block in workspace.'); - }); - }, function() { - document.getElementById(sourceButtonId).focus(); - }); - } -}); diff --git a/accessible/translate.pipe.js b/accessible/translate.pipe.js deleted file mode 100644 index fef1940cd1f..00000000000 --- a/accessible/translate.pipe.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Pipe for internationalizing Blockly message strings. - * @author sll@google.com (Sean Lip) - */ - -goog.provide('blocklyApp.TranslatePipe'); - - -blocklyApp.TranslatePipe = ng.core.Pipe({ - name: 'translate' -}) -.Class({ - constructor: function() {}, - transform: function(messageId) { - return Blockly.Msg[messageId]; - } -}); diff --git a/accessible/tree.service.js b/accessible/tree.service.js deleted file mode 100644 index c5a73ac4c4a..00000000000 --- a/accessible/tree.service.js +++ /dev/null @@ -1,609 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service that handles keyboard navigation on workspace - * block groups (internally represented as trees). This is a singleton service - * for the entire application. - * - * @author madeeha@google.com (Madeeha Ghori) - */ - -goog.provide('blocklyApp.TreeService'); - -goog.require('blocklyApp.UtilsService'); - -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.BlockConnectionService'); -goog.require('blocklyApp.BlockOptionsModalService'); -goog.require('blocklyApp.NotificationsService'); -goog.require('blocklyApp.VariableModalService'); - - -blocklyApp.TreeService = ng.core.Class({ - constructor: [ - blocklyApp.AudioService, - blocklyApp.BlockConnectionService, - blocklyApp.BlockOptionsModalService, - blocklyApp.NotificationsService, - blocklyApp.UtilsService, - blocklyApp.VariableModalService, - function( - audioService, blockConnectionService, blockOptionsModalService, - notificationsService, utilsService, variableModalService) { - this.audioService = audioService; - this.blockConnectionService = blockConnectionService; - this.blockOptionsModalService = blockOptionsModalService; - this.notificationsService = notificationsService; - this.utilsService = utilsService; - this.variableModalService = variableModalService; - - // The suffix used for all IDs of block root elements. - this.BLOCK_ROOT_ID_SUFFIX_ = blocklyApp.BLOCK_ROOT_ID_SUFFIX; - // Maps tree IDs to the IDs of their active descendants. - this.activeDescendantIds_ = {}; - // Array containing all the sidebar button elements. - this.sidebarButtonElements_ = Array.from( - document.querySelectorAll('button.blocklySidebarButton')); - } - ], - scrollToElement_: function(elementId) { - var element = document.getElementById(elementId); - var documentElement = document.body || document.documentElement; - if (element.offsetTop < documentElement.scrollTop || - element.offsetTop > documentElement.scrollTop + window.innerHeight) { - window.scrollTo(0, element.offsetTop - 10); - } - }, - - isLi_: function(node) { - return node.tagName == 'LI'; - }, - getParentLi_: function(element) { - var nextNode = element.parentNode; - while (nextNode && !this.isLi_(nextNode)) { - nextNode = nextNode.parentNode; - } - return nextNode; - }, - getFirstChildLi_: function(element) { - var childList = element.children; - for (var i = 0; i < childList.length; i++) { - if (this.isLi_(childList[i])) { - return childList[i]; - } else { - var potentialElement = this.getFirstChildLi_(childList[i]); - if (potentialElement) { - return potentialElement; - } - } - } - return null; - }, - getLastChildLi_: function(element) { - var childList = element.children; - for (var i = childList.length - 1; i >= 0; i--) { - if (this.isLi_(childList[i])) { - return childList[i]; - } else { - var potentialElement = this.getLastChildLi_(childList[i]); - if (potentialElement) { - return potentialElement; - } - } - } - return null; - }, - getInitialSiblingLi_: function(element) { - while (true) { - var previousSibling = this.getPreviousSiblingLi_(element); - if (previousSibling && previousSibling.id != element.id) { - element = previousSibling; - } else { - return element; - } - } - }, - getPreviousSiblingLi_: function(element) { - if (element.previousElementSibling) { - var sibling = element.previousElementSibling; - return this.isLi_(sibling) ? sibling : this.getLastChildLi_(sibling); - } else { - var parent = element.parentNode; - while (parent && parent.tagName != 'OL') { - if (parent.previousElementSibling) { - var node = parent.previousElementSibling; - return this.isLi_(node) ? node : this.getLastChildLi_(node); - } else { - parent = parent.parentNode; - } - } - return null; - } - }, - getNextSiblingLi_: function(element) { - if (element.nextElementSibling) { - var sibling = element.nextElementSibling; - return this.isLi_(sibling) ? sibling : this.getFirstChildLi_(sibling); - } else { - var parent = element.parentNode; - while (parent && parent.tagName != 'OL') { - if (parent.nextElementSibling) { - var node = parent.nextElementSibling; - return this.isLi_(node) ? node : this.getFirstChildLi_(node); - } else { - parent = parent.parentNode; - } - } - return null; - } - }, - getFinalSiblingLi_: function(element) { - while (true) { - var nextSibling = this.getNextSiblingLi_(element); - if (nextSibling && nextSibling.id != element.id) { - element = nextSibling; - } else { - return element; - } - } - }, - - // Returns a list of all focus targets in the workspace, including the - // "Create new group" button that appears when no blocks are present. - getWorkspaceFocusTargets_: function() { - return Array.from( - document.querySelectorAll('.blocklyWorkspaceFocusTarget')); - }, - getAllFocusTargets_: function() { - return this.getWorkspaceFocusTargets_().concat(this.sidebarButtonElements_); - }, - getNextFocusTargetId_: function(treeId) { - var trees = this.getAllFocusTargets_(); - for (var i = 0; i < trees.length - 1; i++) { - if (trees[i].id == treeId) { - return trees[i + 1].id; - } - } - return null; - }, - getPreviousFocusTargetId_: function(treeId) { - var trees = this.getAllFocusTargets_(); - for (var i = trees.length - 1; i > 0; i--) { - if (trees[i].id == treeId) { - return trees[i - 1].id; - } - } - return null; - }, - - getActiveDescId: function(treeId) { - return this.activeDescendantIds_[treeId] || ''; - }, - // Set the active desc for this tree to its first child. - initActiveDesc: function(treeId) { - var tree = document.getElementById(treeId); - this.setActiveDesc(this.getFirstChildLi_(tree).id, treeId); - }, - // Make a given element the active descendant of a given tree. - setActiveDesc: function(newActiveDescId, treeId) { - if (this.getActiveDescId(treeId)) { - this.clearActiveDesc(treeId); - } - document.getElementById(newActiveDescId).classList.add( - 'blocklyActiveDescendant'); - this.activeDescendantIds_[treeId] = newActiveDescId; - - // Scroll the new active desc into view, if needed. This has no effect - // for blind users, but is helpful for sighted onlookers. - this.scrollToElement_(newActiveDescId); - }, - // This clears the active descendant of the given tree. It is used just - // before the tree is deleted. - clearActiveDesc: function(treeId) { - var activeDesc = document.getElementById(this.getActiveDescId(treeId)); - if (activeDesc) { - activeDesc.classList.remove('blocklyActiveDescendant'); - } - - if (this.activeDescendantIds_[treeId]) { - delete this.activeDescendantIds_[treeId]; - } - }, - clearAllActiveDescs: function() { - for (var treeId in this.activeDescendantIds_) { - var activeDesc = document.getElementById(this.getActiveDescId(treeId)); - if (activeDesc) { - activeDesc.classList.remove('blocklyActiveDescendant'); - } - } - - this.activeDescendantIds_ = {}; - }, - - isTreeRoot_: function(element) { - return element.classList.contains('blocklyTree'); - }, - getBlockRootId_: function(blockId) { - return blockId + this.BLOCK_ROOT_ID_SUFFIX_; - }, - // Return the 'lowest' Blockly block in the DOM tree that contains the given - // DOM element. - getContainingBlock_: function(domElement) { - var potentialBlockRoot = domElement; - while (potentialBlockRoot.id.indexOf(this.BLOCK_ROOT_ID_SUFFIX_) === -1) { - potentialBlockRoot = potentialBlockRoot.parentNode; - } - - var blockRootId = potentialBlockRoot.id; - var blockId = blockRootId.substring( - 0, blockRootId.length - this.BLOCK_ROOT_ID_SUFFIX_.length); - return blocklyApp.workspace.getBlockById(blockId); - }, - isTopLevelBlock_: function(block) { - return !block.getParent(); - }, - // Returns whether the given block is at the top level, and has no siblings. - isIsolatedTopLevelBlock_: function(block) { - var blockHasNoSiblings = ( - (!block.nextConnection || - !block.nextConnection.targetConnection) && - (!block.previousConnection || - !block.previousConnection.targetConnection)); - return this.isTopLevelBlock_(block) && blockHasNoSiblings; - }, - safelyRemoveBlock_: function(block, deleteBlockFunc, areNextBlocksRemoved) { - // Runs the given deleteBlockFunc (which should have the effect of deleting - // the given block, and possibly others after it if `areNextBlocksRemoved` - // is true) and then does one of two things: - // - If the deleted block was an isolated top-level block, or it is a top- - // level block and the next blocks are going to be removed, this means - // the current tree has no more blocks after the deletion. So, pick a new - // tree to focus on. - // - Otherwise, set the correct new active desc for the current tree. - var treeId = this.getTreeIdForBlock(block.id); - - var treeCeasesToExist = areNextBlocksRemoved ? - this.isTopLevelBlock_(block) : this.isIsolatedTopLevelBlock_(block); - - if (treeCeasesToExist) { - // Find the node to focus on after the deletion happens. - var nextElementToFocusOn = null; - var focusTargets = this.getWorkspaceFocusTargets_(); - for (var i = 0; i < focusTargets.length; i++) { - if (focusTargets[i].id == treeId) { - if (i + 1 < focusTargets.length) { - nextElementToFocusOn = focusTargets[i + 1]; - } else if (i > 0) { - nextElementToFocusOn = focusTargets[i - 1]; - } - break; - } - } - - this.clearActiveDesc(treeId); - deleteBlockFunc(); - // Invoke a digest cycle, so that the DOM settles (and the "Create new - // group" button in the workspace shows up, if applicable). - setTimeout(function() { - if (nextElementToFocusOn) { - nextElementToFocusOn.focus(); - } else { - document.getElementById( - blocklyApp.ID_FOR_EMPTY_WORKSPACE_BTN).focus(); - } - }); - } else { - var blockRootId = this.getBlockRootId_(block.id); - var blockRootElement = document.getElementById(blockRootId); - - // Find the new active desc for the current tree by trying the following - // possibilities in order: the parent, the next sibling, and the previous - // sibling. (If `areNextBlocksRemoved` is true, the next sibling would be - // moved together with the moved block, so we don't check it.) - if (areNextBlocksRemoved) { - var newActiveDesc = - this.getParentLi_(blockRootElement) || - this.getPreviousSiblingLi_(blockRootElement); - } else { - var newActiveDesc = - this.getParentLi_(blockRootElement) || - this.getNextSiblingLi_(blockRootElement) || - this.getPreviousSiblingLi_(blockRootElement); - } - - this.clearActiveDesc(treeId); - deleteBlockFunc(); - // Invoke a digest cycle, so that the DOM settles. - var that = this; - setTimeout(function() { - that.setActiveDesc(newActiveDesc.id, treeId); - document.getElementById(treeId).focus(); - }); - } - }, - getTreeIdForBlock: function(blockId) { - // Walk up the DOM until we get to the root element of the tree. - var potentialRoot = document.getElementById(this.getBlockRootId_(blockId)); - while (!this.isTreeRoot_(potentialRoot)) { - potentialRoot = potentialRoot.parentNode; - } - return potentialRoot.id; - }, - // Set focus to the tree containing the given block, and set the tree's - // active desc to the root element of the given block. - focusOnBlock: function(blockId) { - // Invoke a digest cycle, in order to allow the ID of the newly-created - // tree to be set in the DOM. - var that = this; - setTimeout(function() { - var treeId = that.getTreeIdForBlock(blockId); - document.getElementById(treeId).focus(); - that.setActiveDesc(that.getBlockRootId_(blockId), treeId); - }); - }, - showBlockOptionsModal: function(block) { - var that = this; - var actionButtonsInfo = []; - - if (block.previousConnection) { - actionButtonsInfo.push({ - action: function() { - that.blockConnectionService.markConnection(block.previousConnection); - that.focusOnBlock(block.id); - }, - translationIdForText: 'MARK_SPOT_BEFORE' - }); - } - - if (block.nextConnection) { - actionButtonsInfo.push({ - action: function() { - that.blockConnectionService.markConnection(block.nextConnection); - that.focusOnBlock(block.id); - }, - translationIdForText: 'MARK_SPOT_AFTER' - }); - } - - if (this.blockConnectionService.canBeMovedToMarkedConnection(block)) { - actionButtonsInfo.push({ - action: function() { - var blockDescription = that.utilsService.getBlockDescription(block); - var oldDestinationTreeId = that.getTreeIdForBlock( - that.blockConnectionService.getMarkedConnectionSourceBlock().id); - that.clearActiveDesc(oldDestinationTreeId); - - var newBlockId = that.blockConnectionService.attachToMarkedConnection( - block); - that.safelyRemoveBlock_(block, function() { - block.dispose(false); - }, true); - - // Invoke a digest cycle, so that the DOM settles. - setTimeout(function() { - that.focusOnBlock(newBlockId); - var newDestinationTreeId = that.getTreeIdForBlock(newBlockId); - - if (newDestinationTreeId != oldDestinationTreeId) { - // The tree ID for a moved block does not seem to behave - // predictably. E.g. start with two separate groups of one block - // each, add a link before the block in the second group, and - // move the block in the first group to that link. The tree ID of - // the resulting group ends up being the tree ID for the group - // that was originally first, not second as might be expected. - // Here, we double-check to ensure that all affected trees have - // an active desc set. - if (document.getElementById(oldDestinationTreeId)) { - var activeDescId = that.getActiveDescId(oldDestinationTreeId); - var activeDescTreeId = null; - if (activeDescId) { - var oldDestinationBlock = that.getContainingBlock_( - document.getElementById(activeDescId)); - activeDescTreeId = that.getTreeIdForBlock( - oldDestinationBlock); - if (activeDescTreeId != oldDestinationTreeId) { - that.clearActiveDesc(oldDestinationTreeId); - } - } - that.initActiveDesc(oldDestinationTreeId); - } - } - - that.notificationsService.speak( - blockDescription + ' ' + - Blockly.Msg.ATTACHED_BLOCK_TO_LINK_MSG + - '. Now on attached block in workspace.'); - }); - }, - translationIdForText: 'MOVE_TO_MARKED_SPOT' - }); - } - - actionButtonsInfo.push({ - action: function() { - var blockDescription = that.utilsService.getBlockDescription(block); - - that.safelyRemoveBlock_(block, function() { - block.dispose(true); - that.audioService.playDeleteSound(); - }, false); - - setTimeout(function() { - var message = blockDescription + ' deleted. ' + ( - that.utilsService.isWorkspaceEmpty() ? - 'Workspace is empty.' : 'Now on workspace.'); - that.notificationsService.speak(message); - }); - }, - translationIdForText: 'DELETE' - }); - - this.blockOptionsModalService.showModal(actionButtonsInfo, function() { - that.focusOnBlock(block.id); - }); - }, - - moveUpOneLevel_: function(treeId) { - var activeDesc = document.getElementById(this.getActiveDescId(treeId)); - var nextNode = this.getParentLi_(activeDesc); - if (nextNode) { - this.setActiveDesc(nextNode.id, treeId); - } else { - this.audioService.playOopsSound(); - } - }, - onKeypress: function(e, tree) { - // TODO(sll): Instead of this, have a common ActiveContextService which - // returns true if at least one modal is shown, and false otherwise. - if (this.blockOptionsModalService.isModalShown() || - this.variableModalService.isModalShown()) { - return; - } - - var treeId = tree.id; - var activeDesc = document.getElementById(this.getActiveDescId(treeId)); - if (!activeDesc) { - // The underlying Blockly instance may have decided blocks needed to - // be deleted. This is not necessarily an error, but needs to be repaired. - this.initActiveDesc(treeId); - activeDesc = document.getElementById(this.getActiveDescId(treeId)); - } - - if (e.altKey || e.ctrlKey) { - // Do not intercept combinations such as Alt+Home. - return; - } - - if (document.activeElement.tagName == 'INPUT' || - document.activeElement.tagName == 'SELECT') { - // For input fields, Esc, Enter, and Tab keystrokes are handled specially. - if (e.keyCode == 9 || e.keyCode == 13 || e.keyCode == 27) { - // Return the focus to the workspace tree containing the input field. - document.getElementById(treeId).focus(); - - // Note that Tab and Enter events stop propagating, this behavior is - // handled on other listeners. - if (e.keyCode == 27 || e.keyCode == 13) { - e.preventDefault(); - e.stopPropagation(); - } - } - } else { - // Outside an input field, Enter, Tab, Esc and navigation keys are all - // recognized. - if (e.keyCode == 13) { - // Enter key. The user wants to interact with a button, interact with - // an input field, or open the block options modal. - // Algorithm to find the field: do a DFS through the children until - // we find an INPUT, BUTTON or SELECT element (in which case we use it). - // Truncate the search at child LI elements. - e.stopPropagation(); - - var found = false; - var dfsStack = Array.from(activeDesc.children); - while (dfsStack.length) { - var currentNode = dfsStack.shift(); - if (currentNode.tagName == 'BUTTON') { - currentNode.click(); - found = true; - break; - } else if (currentNode.tagName == 'INPUT') { - currentNode.focus(); - currentNode.select(); - this.notificationsService.speak( - 'Type a value, then press Escape to exit'); - found = true; - break; - } else if (currentNode.tagName == 'SELECT') { - currentNode.focus(); - found = true; - return; - } else if (currentNode.tagName == 'LI') { - continue; - } - - if (currentNode.children) { - var reversedChildren = Array.from(currentNode.children).reverse(); - reversedChildren.forEach(function(childNode) { - dfsStack.unshift(childNode); - }); - } - } - - // If we cannot find a field to interact with, we open the modal for - // the current block instead. - if (!found) { - var block = this.getContainingBlock_(activeDesc); - this.showBlockOptionsModal(block); - } - } else if (e.keyCode == 9) { - // Tab key. The event is allowed to propagate through. - } else if ([27, 35, 36, 37, 38, 39, 40].indexOf(e.keyCode) !== -1) { - if (e.keyCode == 27 || e.keyCode == 37) { - // Esc or left arrow key. Go up a level, if possible. - this.moveUpOneLevel_(treeId); - } else if (e.keyCode == 35) { - // End key. Go to the last sibling in the subtree. - var potentialFinalSibling = this.getFinalSiblingLi_(activeDesc); - if (potentialFinalSibling) { - this.setActiveDesc(potentialFinalSibling.id, treeId); - } - } else if (e.keyCode == 36) { - // Home key. Go to the first sibling in the subtree. - var potentialInitialSibling = this.getInitialSiblingLi_(activeDesc); - if (potentialInitialSibling) { - this.setActiveDesc(potentialInitialSibling.id, treeId); - } - } else if (e.keyCode == 38) { - // Up arrow key. Go to the previous sibling, if possible. - var potentialPrevSibling = this.getPreviousSiblingLi_(activeDesc); - if (potentialPrevSibling) { - this.setActiveDesc(potentialPrevSibling.id, treeId); - } else { - var statusMessage = 'Reached top of list.'; - if (this.getParentLi_(activeDesc)) { - statusMessage += ' Press left to go to parent list.'; - } - this.audioService.playOopsSound(statusMessage); - } - } else if (e.keyCode == 39) { - // Right arrow key. Go down a level, if possible. - var potentialFirstChild = this.getFirstChildLi_(activeDesc); - if (potentialFirstChild) { - this.setActiveDesc(potentialFirstChild.id, treeId); - } else { - this.audioService.playOopsSound(); - } - } else if (e.keyCode == 40) { - // Down arrow key. Go to the next sibling, if possible. - var potentialNextSibling = this.getNextSiblingLi_(activeDesc); - if (potentialNextSibling) { - this.setActiveDesc(potentialNextSibling.id, treeId); - } else { - this.audioService.playOopsSound('Reached bottom of list.'); - } - } - - e.preventDefault(); - e.stopPropagation(); - } - } - } -}); diff --git a/accessible/utils.service.js b/accessible/utils.service.js deleted file mode 100644 index d78472dc8e1..00000000000 --- a/accessible/utils.service.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 utility service for multiple components. This is a - * singleton service that is used for the entire application. In general, it - * should only be used as a stateless adapter for native Blockly functions. - * - * @author madeeha@google.com (Madeeha Ghori) - */ - -goog.provide('blocklyApp.UtilsService'); - - -blocklyApp.ID_FOR_EMPTY_WORKSPACE_BTN = 'blocklyEmptyWorkspaceBtn'; -blocklyApp.BLOCK_ROOT_ID_SUFFIX = '-blockRoot'; - -blocklyApp.UtilsService = ng.core.Class({ - constructor: [function() {}], - getBlockDescription: function(block) { - // We use 'BLANK' instead of the default '?' so that the string is read - // out. (By default, screen readers tend to ignore punctuation.) - return block.toString(undefined, 'BLANK'); - }, - isWorkspaceEmpty: function() { - return !blocklyApp.workspace.topBlocks_.length; - } -}); diff --git a/accessible/variable-add-modal.component.js b/accessible/variable-add-modal.component.js deleted file mode 100644 index 2c3f77bbc1f..00000000000 --- a/accessible/variable-add-modal.component.js +++ /dev/null @@ -1,118 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2017 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Component representing the variable rename modal. - * - * @author corydiers@google.com (Cory Diers) - */ - -goog.provide('blocklyApp.VariableAddModalComponent'); - -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.KeyboardInputService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.VariableModalService'); - -goog.require('Blockly.CommonModal'); - - -blocklyApp.VariableAddModalComponent = ng.core.Component({ - selector: 'blockly-add-variable-modal', - template: ` -
- -
-

Add a variable...

- - -

New Variable Name: - -

-
- - - -
-
- `, - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.AudioService, blocklyApp.KeyboardInputService, blocklyApp.VariableModalService, - function(audioService, keyboardService, variableService) { - this.workspace = blocklyApp.workspace; - this.variableModalService = variableService; - this.audioService = audioService; - this.keyboardInputService = keyboardService; - this.modalIsVisible = false; - this.activeButtonIndex = -1; - - var that = this; - this.variableModalService.registerPreAddShowHook( - function() { - that.modalIsVisible = true; - - Blockly.CommonModal.setupKeyboardOverrides(that); - - setTimeout(function() { - document.getElementById('varModal').focus(); - }, 150); - } - ); - } - ], - // Caches the current text variable as the user types. - setTextValue: function(newValue) { - this.variableName = newValue; - }, - // Closes the modal (on both success and failure). - hideModal_: Blockly.CommonModal.hideModal, - // Focuses on the button represented by the given index. - focusOnOption: Blockly.CommonModal.focusOnOption, - // Counts the number of interactive elements for the modal. - numInteractiveElements: Blockly.CommonModal.numInteractiveElements, - // Gets all the interactive elements for the modal. - getInteractiveElements: Blockly.CommonModal.getInteractiveElements, - // Gets the container with interactive elements. - getInteractiveContainer: function() { - return document.getElementById('varForm'); - }, - // Submits the name change for the variable. - submit: function() { - this.workspace.createVariable(this.variableName); - this.dismissModal(); - }, - // Dismisses and closes the modal. - dismissModal: function() { - this.variableModalService.hideModal(); - this.hideModal_(); - } -}) diff --git a/accessible/variable-modal.service.js b/accessible/variable-modal.service.js deleted file mode 100644 index df5555fae4f..00000000000 --- a/accessible/variable-modal.service.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2017 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Service for the variable modal. - * - * @author corydiers@google.com (Cory Diers) - */ - -goog.provide('blocklyApp.VariableModalService'); - -blocklyApp.VariableModalService = ng.core.Class({ - constructor: [ - function() { - this.modalIsShown = false; - } - ], - // Registers a hook to be called before the add modal is shown. - registerPreAddShowHook: function(preShowHook) { - this.preAddShowHook = function() { - preShowHook(); - }; - }, - // Registers a hook to be called before the rename modal is shown. - registerPreRenameShowHook: function(preShowHook) { - this.preRenameShowHook = function(oldName) { - preShowHook(oldName); - }; - }, - // Registers a hook to be called before the remove modal is shown. - registerPreRemoveShowHook: function(preShowHook) { - this.preRemoveShowHook = function(oldName, count) { - preShowHook(oldName, count); - }; - }, - // Returns true if the variable modal is shown. - isModalShown: function() { - return this.modalIsShown; - }, - // Show the add variable modal. - showAddModal_: function() { - this.preAddShowHook(); - this.modalIsShown = true; - }, - // Show the rename variable modal. - showRenameModal_: function(oldName) { - this.preRenameShowHook(oldName); - this.modalIsShown = true; - }, - // Show the remove variable modal. - showRemoveModal_: function(oldName) { - var count = this.getNumVariables(oldName); - this.modalIsShown = true; - if (count > 1) { - this.preRemoveShowHook(oldName, count); - } else { - var variable = blocklyApp.workspace.getVariable(oldName); - blocklyApp.workspace.deleteVariableInternal_(variable); - // Allow the execution loop to finish before "closing" the modal. While - // the modal never opens, its being "open" should prevent other keypresses - // anyway. - var that = this; - setTimeout(function() { - that.modalIsShown = false; - }); - } - }, - getNumVariables: function(oldName) { - return blocklyApp.workspace.getVariableUses(oldName).length; - }, - // Hide the variable modal. - hideModal: function() { - this.modalIsShown = false; - } -}); diff --git a/accessible/variable-remove-modal.component.js b/accessible/variable-remove-modal.component.js deleted file mode 100644 index ce27f5c2565..00000000000 --- a/accessible/variable-remove-modal.component.js +++ /dev/null @@ -1,125 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2017 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Component representing the variable remove modal. - * - * @author corydiers@google.com (Cory Diers) - */ - -goog.provide('blocklyApp.VariableRemoveModalComponent'); - -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.KeyboardInputService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.TreeService'); -goog.require('blocklyApp.VariableModalService'); - -goog.require('Blockly.CommonModal'); - - -blocklyApp.VariableRemoveModalComponent = ng.core.Component({ - selector: 'blockly-remove-variable-modal', - template: ` -
- -
-

- Delete {{getNumVariables()}} uses of the "{{currentVariableName}}" - variable? -

- -
-
- - -
-
-
- `, - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.AudioService, - blocklyApp.KeyboardInputService, - blocklyApp.TreeService, - blocklyApp.VariableModalService, - function(audioService, keyboardService, treeService, variableService) { - this.workspace = blocklyApp.workspace; - this.treeService = treeService; - this.variableModalService = variableService; - this.audioService = audioService; - this.keyboardInputService = keyboardService; - this.modalIsVisible = false; - this.activeButtonIndex = -1; - this.currentVariableName = ''; - this.count = 0; - - var that = this; - this.variableModalService.registerPreRemoveShowHook( - function(name, count) { - that.currentVariableName = name; - that.count = count; - that.modalIsVisible = true; - - Blockly.CommonModal.setupKeyboardOverrides(that); - - setTimeout(function() { - document.getElementById('varModal').focus(); - }, 150); - } - ); - } - ], - // Closes the modal (on both success and failure). - hideModal_: Blockly.CommonModal.hideModal, - // Focuses on the button represented by the given index. - focusOnOption: Blockly.CommonModal.focusOnOption, - // Counts the number of interactive elements for the modal. - numInteractiveElements: Blockly.CommonModal.numInteractiveElements, - // Gets all the interactive elements for the modal. - getInteractiveElements: Blockly.CommonModal.getInteractiveElements, - // Gets the container with interactive elements. - getInteractiveContainer: function() { - return document.getElementById('varForm'); - }, - getNumVariables: function() { - return this.variableModalService.getNumVariables(this.currentVariableName); - }, - // Submits the name change for the variable. - submit: function() { - var variable = blocklyApp.workspace.getVariable(this.currentVariableName); - blocklyApp.workspace.deleteVariableInternal_(variable); - this.dismissModal(); - }, - // Dismisses and closes the modal. - dismissModal: function() { - this.variableModalService.hideModal(); - this.hideModal_(); - } -}) diff --git a/accessible/variable-rename-modal.component.js b/accessible/variable-rename-modal.component.js deleted file mode 100644 index 3bb92e75bb9..00000000000 --- a/accessible/variable-rename-modal.component.js +++ /dev/null @@ -1,121 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2017 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Component representing the variable rename modal. - * - * @author corydiers@google.com (Cory Diers) - */ - -goog.provide('blocklyApp.VariableRenameModalComponent'); - -goog.require('Blockly.CommonModal'); -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.KeyboardInputService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.VariableModalService'); - - -blocklyApp.VariableRenameModalComponent = ng.core.Component({ - selector: 'blockly-rename-variable-modal', - template: ` -
- -
-

- Rename the "{{currentVariableName}}" variable... -

- -
-

New Variable Name: - -

-
- - -
-
-
- `, - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.AudioService, blocklyApp.KeyboardInputService, blocklyApp.VariableModalService, - function(audioService, keyboardService, variableService) { - this.workspace = blocklyApp.workspace; - this.variableModalService = variableService; - this.audioService = audioService; - this.keyboardInputService = keyboardService; - this.modalIsVisible = false; - this.activeButtonIndex = -1; - this.currentVariableName = ''; - - var that = this; - this.variableModalService.registerPreRenameShowHook( - function(oldName) { - that.currentVariableName = oldName; - that.modalIsVisible = true; - - Blockly.CommonModal.setupKeyboardOverrides(that); - - setTimeout(function() { - document.getElementById('varModal').focus(); - }, 150); - } - ); - } - ], - // Caches the current text variable as the user types. - setTextValue: function(newValue) { - this.variableName = newValue; - }, - // Closes the modal (on both success and failure). - hideModal_: Blockly.CommonModal.hideModal, - // Focuses on the button represented by the given index. - focusOnOption: Blockly.CommonModal.focusOnOption, - // Counts the number of interactive elements for the modal. - numInteractiveElements: Blockly.CommonModal.numInteractiveElements, - // Gets all the interactive elements for the modal. - getInteractiveElements: Blockly.CommonModal.getInteractiveElements, - // Gets the container with interactive elements. - getInteractiveContainer: function() { - return document.getElementById('varForm'); - }, - // Submits the name change for the variable. - submit: function() { - this.workspace.renameVariable(this.currentVariableName, this.variableName); - this.dismissModal(); - }, - // Dismisses and closes the modal. - dismissModal: function() { - this.variableModalService.hideModal(); - this.hideModal_(); - } -}) diff --git a/accessible/workspace-block.component.js b/accessible/workspace-block.component.js deleted file mode 100644 index ca20b7fde33..00000000000 --- a/accessible/workspace-block.component.js +++ /dev/null @@ -1,216 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Component representing a Blockly.Block in the - * workspace. - * @author madeeha@google.com (Madeeha Ghori) - */ - -goog.provide('blocklyApp.WorkspaceBlockComponent'); - -goog.require('blocklyApp.UtilsService'); - -goog.require('blocklyApp.AudioService'); -goog.require('blocklyApp.BlockConnectionService'); -goog.require('blocklyApp.FieldSegmentComponent'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.TreeService'); - - -blocklyApp.WorkspaceBlockComponent = ng.core.Component({ - selector: 'blockly-workspace-block', - template: ` -
  • - - -
      - -
    -
  • - - - - `, - directives: [blocklyApp.FieldSegmentComponent, ng.core.forwardRef(function() { - return blocklyApp.WorkspaceBlockComponent; - })], - inputs: ['block', 'level', 'tree'], - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.AudioService, - blocklyApp.BlockConnectionService, - blocklyApp.TreeService, - blocklyApp.UtilsService, - function(audioService, blockConnectionService, treeService, utilsService) { - this.audioService = audioService; - this.blockConnectionService = blockConnectionService; - this.treeService = treeService; - this.utilsService = utilsService; - this.cachedBlockId = null; - } - ], - ngDoCheck: function() { - // The block ID can change if, for example, a block is spliced between two - // linked blocks. We need to refresh the fields and component IDs when this - // happens. - if (this.cachedBlockId != this.block.id) { - this.cachedBlockId = this.block.id; - - var SUPPORTED_FIELDS = [Blockly.FieldTextInput, Blockly.FieldDropdown]; - this.inputListAsFieldSegments = this.block.inputList.map(function(input) { - // Converts the input list to an array of field segments. Each field - // segment represents a user-editable field, prefixed by an arbitrary - // number of non-editable fields. - var fieldSegments = []; - - var bufferedFields = []; - input.fieldRow.forEach(function(field) { - var fieldIsSupported = SUPPORTED_FIELDS.some(function(fieldType) { - return (field instanceof fieldType); - }); - - if (fieldIsSupported) { - var fieldSegment = { - prefixFields: [], - mainField: field - }; - bufferedFields.forEach(function(bufferedField) { - fieldSegment.prefixFields.push(bufferedField); - }); - fieldSegments.push(fieldSegment); - bufferedFields = []; - } else { - bufferedFields.push(field); - } - }); - - // Handle leftover text at the end. - if (bufferedFields.length) { - fieldSegments.push({ - prefixFields: bufferedFields, - mainField: null - }); - } - - return fieldSegments; - }); - - // Generate unique IDs for elements in this component. - this.componentIds = {}; - this.componentIds.blockRoot = - this.block.id + blocklyApp.BLOCK_ROOT_ID_SUFFIX; - this.componentIds.blockSummary = this.block.id + '-blockSummary'; - - var that = this; - this.componentIds.inputs = this.block.inputList.map(function(input, i) { - var idsToGenerate = ['inputLi', 'fieldLabel']; - if (input.connection && !input.connection.targetBlock()) { - idsToGenerate.push('actionButtonLi', 'actionButton', 'buttonLabel'); - } - - var inputIds = {}; - idsToGenerate.forEach(function(idBaseString) { - inputIds[idBaseString] = [that.block.id, i, idBaseString].join('-'); - }); - - return inputIds; - }); - } - }, - ngAfterViewInit: function() { - // If this is a top-level tree in the workspace, ensure that it has an - // active descendant. (Note that a timeout is needed here in order to - // trigger Angular change detection.) - var that = this; - setTimeout(function() { - if (that.level === 0 && !that.treeService.getActiveDescId(that.tree.id)) { - that.treeService.setActiveDesc( - that.componentIds.blockRoot, that.tree.id); - } - }); - }, - addInteriorLink: function(connection) { - this.blockConnectionService.markConnection(connection); - }, - getBlockDescription: function() { - var blockDescription = this.utilsService.getBlockDescription(this.block); - - var parentBlock = this.block.getSurroundParent(); - if (parentBlock) { - var fullDescription = blockDescription + ' inside ' + - this.utilsService.getBlockDescription(parentBlock); - return fullDescription; - } else { - return blockDescription; - } - }, - getBlockNeededLabel: function(blockInput) { - // The input type name, or 'any' if any official input type qualifies. - var inputTypeLabel = ( - blockInput.connection.check_ ? - blockInput.connection.check_.join(', ') : Blockly.Msg.ANY); - var blockTypeLabel = ( - blockInput.type == Blockly.NEXT_STATEMENT ? - Blockly.Msg.BLOCK : Blockly.Msg.VALUE); - return inputTypeLabel + ' ' + blockTypeLabel + ' needed:'; - }, - generateAriaLabelledByAttr: function(mainLabel, secondLabel) { - return mainLabel + (secondLabel ? ' ' + secondLabel : ''); - } -}); diff --git a/accessible/workspace.component.js b/accessible/workspace.component.js deleted file mode 100644 index 08446011765..00000000000 --- a/accessible/workspace.component.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * AccessibleBlockly - * - * Copyright 2016 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Angular2 Component that details how a Blockly.Workspace is - * rendered in AccessibleBlockly. - * - * @author madeeha@google.com (Madeeha Ghori) - */ - -goog.provide('blocklyApp.WorkspaceComponent'); - -goog.require('blocklyApp.NotificationsService'); -goog.require('blocklyApp.ToolboxModalService'); -goog.require('blocklyApp.TranslatePipe'); -goog.require('blocklyApp.TreeService'); - -goog.require('blocklyApp.WorkspaceBlockComponent'); - - -blocklyApp.WorkspaceComponent = ng.core.Component({ - selector: 'blockly-workspace', - template: ` -
    -

    {{'WORKSPACE'|translate}}

    - -
    -
      - - -
    - - -

    - {{'NO_BLOCKS_IN_WORKSPACE'|translate}} - -

    -
    -
    -
    - `, - directives: [blocklyApp.WorkspaceBlockComponent], - pipes: [blocklyApp.TranslatePipe] -}) -.Class({ - constructor: [ - blocklyApp.NotificationsService, - blocklyApp.ToolboxModalService, - blocklyApp.TreeService, - function(notificationsService, toolboxModalService, treeService) { - this.notificationsService = notificationsService; - this.toolboxModalService = toolboxModalService; - this.treeService = treeService; - - this.ID_FOR_EMPTY_WORKSPACE_BTN = blocklyApp.ID_FOR_EMPTY_WORKSPACE_BTN; - this.workspace = blocklyApp.workspace; - this.currentTreeId = 0; - } - ], - getNewTreeId: function() { - this.currentTreeId++; - return 'blockly-tree-' + this.currentTreeId; - }, - getActiveDescId: function(treeId) { - return this.treeService.getActiveDescId(treeId); - }, - onKeypress: function(e, tree) { - this.treeService.onKeypress(e, tree); - }, - showToolboxModalForCreateNewGroup: function() { - this.toolboxModalService.showToolboxModalForCreateNewGroup( - this.ID_FOR_EMPTY_WORKSPACE_BTN); - }, - speakLocation: function(groupIndex, treeId) { - this.notificationsService.speak( - 'Now in workspace group ' + (groupIndex + 1) + ' of ' + - this.workspace.topBlocks_.length); - } -}); diff --git a/appengine/app.yaml b/appengine/app.yaml index 04f6faee2b4..887349dc1ea 100644 --- a/appengine/app.yaml +++ b/appengine/app.yaml @@ -1,5 +1,5 @@ application: blockly-demo -version: 20190419 +version: 20190722 runtime: python27 api_version: 1 threadsafe: no diff --git a/blockly_accessible_compressed.js b/blockly_accessible_compressed.js deleted file mode 100644 index 9b7d4bb7306..00000000000 --- a/blockly_accessible_compressed.js +++ /dev/null @@ -1,1907 +0,0 @@ -// Do not edit this file; automatically generated by build.py. -'use strict'; - -var $jscomp=$jscomp||{};$jscomp.scope={};var COMPILED=!0,goog=goog||{};goog.global=this||self;goog.isDef=function(a){return void 0!==a};goog.isString=function(a){return"string"==typeof a};goog.isBoolean=function(a){return"boolean"==typeof a};goog.isNumber=function(a){return"number"==typeof a}; -goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]&&c[d]!==Object.prototype[d]?c[d]:c[d]={}}; -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=!1;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.STRICT_MODE_COMPATIBLE=!1;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){if(!COMPILED){delete goog.implicitNamespaces_[a];for(var c=a;(c=c.substring(0,c.lastIndexOf(".")))&&!goog.getObjectByName(c);)goog.implicitNamespaces_[c]=!0}goog.exportPath_(a,b)}; -goog.getScriptNonce=function(a){if(a&&a!=goog.global)return goog.getScriptNonce_(a.document);null===goog.cspNonce_&&(goog.cspNonce_=goog.getScriptNonce_(goog.global.document));return goog.cspNonce_};goog.NONCE_PATTERN_=/^[\w+/_-]+[=]{0,2}$/;goog.cspNonce_=null;goog.getScriptNonce_=function(a){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(!goog.isString(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]&&goog.isDefAndNotNull(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>>0);goog.uidCounter_=0;goog.getHashCode=goog.getUid; -goog.removeHashCode=goog.removeUid;goog.cloneObject=function(a){var b=goog.typeOf(a);if("object"==b||"array"==b){if("function"===typeof a.clone)return a.clone();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{"use strict";class X{constructor(){if(new.target!=String)throw 1;this.x=42}}let q=Reflect.construct(X,[],String);if(q.x!=42||!(q instanceof String))throw 1;for(const a of[2,3]){if(a==2)continue;function f(z={a}){let a=0;return z.a}{function f(){return 0;}}return f()==3}})()')}); -a("es7",function(){return b("2 ** 2 == 4")});a("es8",function(){return b("async () => 1, true")});a("es9",function(){return b("({...rest} = {}), true")});a("es_next",function(){return!1});return{target:c,map:d}},goog.Transpiler.prototype.needsTranspile=function(a,b){if("always"==goog.TRANSPILE)return!0;if("never"==goog.TRANSPILE)return!1;if(!this.requiresTranspilation_){var c=this.createRequiresTranspilation_();this.requiresTranspilation_=c.map;this.transpilationTarget_=this.transpilationTarget_|| -c.target}if(a in this.requiresTranspilation_)return this.requiresTranspilation_[a]?!0:!goog.inHtmlDocument_()||"es6"!=b||"noModule"in goog.global.document.createElement("script")?!1:!0;throw Error("Unknown language mode: "+a);},goog.Transpiler.prototype.transpile=function(a,b){return goog.transpile_(a,b,this.transpilationTarget_)},goog.transpiler_=new goog.Transpiler,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(goog.transpiler_);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\x3c/script>";b.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(d):d)}else{var e=b.createElement("script");e.defer=goog.Dependency.defer_;e.async=!1;e.type="text/javascript";(d=goog.getScriptNonce())&&e.setAttribute("nonce",d);goog.DebugLoader_.IS_OLD_IE_? -(a.pause(),e.onreadystatechange=function(){if("loaded"==e.readyState||"complete"==e.readyState)a.loaded(),a.resume()}):e.onload=function(){e.onload=null;a.loaded()};e.src=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScriptURL(this.path):this.path;b.head.appendChild(e)}}else goog.logToConsole_("Cannot use default debug loader outside of HTML documents."),"deps.js"==this.relativePath?(goog.logToConsole_("Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, or setting CLOSURE_NO_DEPS to true."), -a.loaded()):a.pause()},goog.Es6ModuleDependency=function(a,b,c,d,e){goog.Dependency.call(this,a,b,c,d,e)},goog.inherits(goog.Es6ModuleDependency,goog.Dependency),goog.Es6ModuleDependency.prototype.load=function(a){function b(a,b){a=b?''); - // Load fresh Closure Library. - document.write(''); - document.write(''); -} diff --git a/blockly_compressed.js b/blockly_compressed.js index c86803434d6..a5f2b1aeccd 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -80,7 +80,9 @@ goog.asserts.assertString=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isS goog.asserts.assertObject=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isObject(a)&&goog.asserts.doAssertFailure_("Expected object but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertArray=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isArray(a)&&goog.asserts.doAssertFailure_("Expected array but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a}; goog.asserts.assertBoolean=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isBoolean(a)&&goog.asserts.doAssertFailure_("Expected boolean but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertElement=function(a,b,c){!goog.asserts.ENABLE_ASSERTS||goog.isObject(a)&&a.nodeType==goog.dom.NodeType.ELEMENT||goog.asserts.doAssertFailure_("Expected Element but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a}; goog.asserts.assertInstanceof=function(a,b,c,d){!goog.asserts.ENABLE_ASSERTS||a instanceof b||goog.asserts.doAssertFailure_("Expected instanceof %s but got %s.",[goog.asserts.getType_(b),goog.asserts.getType_(a)],c,Array.prototype.slice.call(arguments,3));return a};goog.asserts.assertFinite=function(a,b,c){!goog.asserts.ENABLE_ASSERTS||"number"==typeof a&&isFinite(a)||goog.asserts.doAssertFailure_("Expected %s to be a finite number but it is not.",[a],b,Array.prototype.slice.call(arguments,2));return a}; -goog.asserts.assertObjectPrototypeIsIntact=function(){for(var a in Object.prototype)goog.asserts.fail(a+" should not be enumerable in Object.prototype.")};goog.asserts.getType_=function(a){return a instanceof Function?a.displayName||a.name||"unknown type name":a instanceof Object?a.constructor.displayName||a.constructor.name||Object.prototype.toString.call(a):null===a?"null":typeof a};goog.array={};goog.NATIVE_ARRAY_PROTOTYPES=goog.TRUSTED_SITE;goog.array.ASSUME_NATIVE_FUNCTIONS=!1;goog.array.peek=function(a){return a[a.length-1]};goog.array.last=goog.array.peek; +goog.asserts.assertObjectPrototypeIsIntact=function(){for(var a in Object.prototype)goog.asserts.fail(a+" should not be enumerable in Object.prototype.")};goog.asserts.getType_=function(a){return a instanceof Function?a.displayName||a.name||"unknown type name":a instanceof Object?a.constructor.displayName||a.constructor.name||Object.prototype.toString.call(a):null===a?"null":typeof a};goog.debug.entryPointRegistry={};goog.debug.EntryPointMonitor=function(){};goog.debug.entryPointRegistry.refList_=[];goog.debug.entryPointRegistry.monitors_=[];goog.debug.entryPointRegistry.monitorsMayExist_=!1;goog.debug.entryPointRegistry.register=function(a){goog.debug.entryPointRegistry.refList_[goog.debug.entryPointRegistry.refList_.length]=a;if(goog.debug.entryPointRegistry.monitorsMayExist_)for(var b=goog.debug.entryPointRegistry.monitors_,c=0;cc?Math.max(0,a.length+c):c;if(goog.isString(a))return goog.isString(b)&&1==b.length?a.indexOf(b,c):-1;for(;cc&&(c=Math.max(0,a.length+c));if(goog.isString(a))return goog.isString(b)&&1==b.length?a.lastIndexOf(b,c):-1;for(;0<=c;c--)if(c in a&&a[c]===b)return c;return-1}; goog.array.forEach=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.forEach)?function(a,b,c){goog.asserts.assert(null!=a.length);Array.prototype.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=goog.isString(a)?a.split(""):a,f=0;fb&&Array.prototype.push.apply(a,a.splice(0,-b)));return a};goog.array.moveItem=function(a,b,c){goog.asserts.assert(0<=b&&bc*b?c+b:c};goog.math.lerp=function(a,b,c){return a+c*(b-a)};goog.math.nearlyEquals=function(a,b,c){return Math.abs(a-b)<=(c||1E-6)};goog.math.standardAngle=function(a){return goog.math.modulo(a,360)}; -goog.math.standardAngleInRadians=function(a){return goog.math.modulo(a,2*Math.PI)};goog.math.toRadians=function(a){return a*Math.PI/180};goog.math.toDegrees=function(a){return 180*a/Math.PI};goog.math.angleDx=function(a,b){return b*Math.cos(goog.math.toRadians(a))};goog.math.angleDy=function(a,b){return b*Math.sin(goog.math.toRadians(a))};goog.math.angle=function(a,b,c,d){return goog.math.standardAngle(goog.math.toDegrees(Math.atan2(d-b,c-a)))}; -goog.math.angleDifference=function(a,b){var c=goog.math.standardAngle(b)-goog.math.standardAngle(a);180=c&&(c=360+c);return c};goog.math.sign=function(a){return 0a?-1:a}; -goog.math.longestCommonSubsequence=function(a,b,c,d){c=c||function(a,b){return a==b};d=d||function(b,c){return a[b]};for(var e=a.length,f=b.length,g=[],h=0;hg[h][k-1]?h--:k--;return l}; -goog.math.sum=function(a){return goog.array.reduce(arguments,function(a,c){return a+c},0)};goog.math.average=function(a){return goog.math.sum.apply(null,arguments)/arguments.length};goog.math.sampleVariance=function(a){var b=arguments.length;if(2>b)return 0;var c=goog.math.average.apply(null,arguments);return goog.math.sum.apply(null,goog.array.map(arguments,function(a){return Math.pow(a-c,2)}))/(b-1)};goog.math.standardDeviation=function(a){return Math.sqrt(goog.math.sampleVariance.apply(null,arguments))}; -goog.math.isInt=function(a){return isFinite(a)&&0==a%1};goog.math.isFiniteNumber=function(a){return isFinite(a)};goog.math.isNegativeZero=function(a){return 0==a&&0>1/a};goog.math.log10Floor=function(a){if(0a?1:0)}return 0==a?-Infinity:NaN};goog.math.safeFloor=function(a,b){goog.asserts.assert(!goog.isDef(b)||0>16,a>>8&255,a&255]}; -goog.color.rgbToHex=function(a,b,c){a=Number(a);b=Number(b);c=Number(c);if(a!=(a&255)||b!=(b&255)||c!=(c&255))throw Error('"('+a+","+b+","+c+'") is not a valid RGB color');b=a<<16|b<<8|c;return 16>a?"#"+(16777216|b).toString(16).substr(1):"#"+b.toString(16)};goog.color.rgbArrayToHex=function(a){return goog.color.rgbToHex(a[0],a[1],a[2])}; -goog.color.rgbToHsl=function(a,b,c){a/=255;b/=255;c/=255;var d=Math.max(a,b,c),e=Math.min(a,b,c),f=0,g=0,h=.5*(d+e);d!=e&&(d==a?f=60*(b-c)/(d-e):d==b?f=60*(c-a)/(d-e)+120:d==c&&(f=60*(a-b)/(d-e)+240),g=0=h?(d-e)/(2*h):(d-e)/(2-2*h));return[Math.round(f+360)%360,g,h]};goog.color.rgbArrayToHsl=function(a){return goog.color.rgbToHsl(a[0],a[1],a[2])};goog.color.hueToRgb_=function(a,b,c){0>c?c+=1:16*c?a+6*(b-a)*c:1>2*c?b:2>3*c?a+(b-a)*(2/3-c)*6:a}; -goog.color.hslToRgb=function(a,b,c){a/=360;if(0==b)c=b=a=255*c;else{var d=.5>c?c*(1+b):c+b-b*c;var e=2*c-d;c=255*goog.color.hueToRgb_(e,d,a+1/3);b=255*goog.color.hueToRgb_(e,d,a);a=255*goog.color.hueToRgb_(e,d,a-1/3)}return[Math.round(c),Math.round(b),Math.round(a)]};goog.color.hslArrayToRgb=function(a){return goog.color.hslToRgb(a[0],a[1],a[2])};goog.color.validHexColorRe_=/^#(?:[0-9a-f]{3}){1,2}$/i;goog.color.isValidHexColor_=function(a){return goog.color.validHexColorRe_.test(a)}; -goog.color.rgbColorRe_=/^(?:rgb)?\((0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2})\)$/i;goog.color.isValidRgbColor_=function(a){var b=a.match(goog.color.rgbColorRe_);if(b){a=Number(b[1]);var c=Number(b[2]);b=Number(b[3]);if(0<=a&&255>=a&&0<=c&&255>=c&&0<=b&&255>=b)return[a,c,b]}return[]};goog.color.prependZeroIfNecessaryHelper=function(a){return 1==a.length?"0"+a:a};goog.color.prependHashIfNecessaryHelper=function(a){return"#"==a.charAt(0)?a:"#"+a}; -goog.color.rgbStyle_=function(a){return"rgb("+a.join(",")+")"};goog.color.hsvToRgb=function(a,b,c){var d=0,e=0,f=0;if(0==b)f=e=d=c;else{var g=Math.floor(a/60),h=a/60-g;a=c*(1-b);var k=c*(1-b*h);b=c*(1-b*(1-h));switch(g){case 1:d=k;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=k;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=k;break;case 6:case 0:d=c,e=b,f=a}}return[Math.floor(d),Math.floor(e),Math.floor(f)]}; -goog.color.rgbToHsv=function(a,b,c){var d=Math.max(Math.max(a,b),c),e=Math.min(Math.min(a,b),c);if(e==d)e=a=0;else{var f=d-e;e=f/d;a=60*(a==d?(b-c)/f:b==d?2+(c-a)/f:4+(a-b)/f);0>a&&(a+=360);360=a[2]?a[1]*a[2]:a[1]*(1-a[2]);var d=.5>=b[2]?b[1]*b[2]:b[1]*(1-b[2]);return(a[2]-b[2])*(a[2]-b[2])+c*c+d*d-2*c*d*Math.cos(2*(a[0]/360-b[0]/360)*Math.PI)};goog.color.blend=function(a,b,c){c=goog.math.clamp(c,0,1);return[Math.round(b[0]+c*(a[0]-b[0])),Math.round(b[1]+c*(a[1]-b[1])),Math.round(b[2]+c*(a[2]-b[2]))]};goog.color.darken=function(a,b){return goog.color.blend([0,0,0],a,b)}; -goog.color.lighten=function(a,b){return goog.color.blend([255,255,255],a,b)};goog.color.highContrast=function(a,b){for(var c=[],d=0;d":"
    ")}; goog.string.internal.htmlEscape=function(a,b){if(b)a=a.replace(goog.string.internal.AMP_RE_,"&").replace(goog.string.internal.LT_RE_,"<").replace(goog.string.internal.GT_RE_,">").replace(goog.string.internal.QUOT_RE_,""").replace(goog.string.internal.SINGLE_QUOTE_RE_,"'").replace(goog.string.internal.NULL_RE_,"�");else{if(!goog.string.internal.ALL_RE_.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(goog.string.internal.AMP_RE_,"&"));-1!=a.indexOf("<")&&(a=a.replace(goog.string.internal.LT_RE_, @@ -151,15 +125,15 @@ goog.object.unsafeClone=function(a){var b=goog.typeOf(a);if("object"==b||"array" goog.object.extend=function(a,b){for(var c,d,e=1;e";case "quot":return'"';default:if("#"==c.charAt(0)){var b=Number("0"+c.substr(1));if(!isNaN(b))return String.fromCharCode(b)}return a}})};goog.string.HTML_ENTITY_PATTERN_=/&([^;\s<&]+);?/g; goog.string.whitespaceEscape=function(a,b){return goog.string.newLineToBr(a.replace(/ /g,"  "),b)};goog.string.preserveSpaces=function(a){return a.replace(/(^|[\n ]) /g,"$1"+goog.string.Unicode.NBSP)};goog.string.stripQuotes=function(a,b){for(var c=b.length,d=0;db&&(a=a.substring(0,b-3)+"...");c&&(a=goog.string.htmlEscape(a));return a};goog.string.truncateMiddle=function(a,b,c,d){c&&(a=goog.string.unescapeEntities(a));if(d&&a.length>b){d>b&&(d=b);var e=a.length-d;a=a.substring(0,b-d)+"..."+a.substring(e)}else a.length>b&&(d=Math.floor(b/2),e=a.length-d,a=a.substring(0,d+b%2)+"..."+a.substring(e));c&&(a=goog.string.htmlEscape(a));return a}; -goog.string.specialEscapeChars_={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\","<":"<"};goog.string.jsEscapeCache_={"'":"\\'"};goog.string.quote=function(a){a=String(a);for(var b=['"'],c=0;ce?d:goog.string.escapeChar(d))}b.push('"');return b.join("")}; +goog.string.specialEscapeChars_={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\","<":"\\u003C"};goog.string.jsEscapeCache_={"'":"\\'"};goog.string.quote=function(a){a=String(a);for(var b=['"'],c=0;ce?d:goog.string.escapeChar(d))}b.push('"');return b.join("")}; goog.string.escapeString=function(a){for(var b=[],c=0;cb)var c=a;else{if(256>b){if(c="\\x",16>b||256b&&(c+="0");c+=b.toString(16).toUpperCase()}return goog.string.jsEscapeCache_[a]=c};goog.string.contains=goog.string.internal.contains;goog.string.caseInsensitiveContains=goog.string.internal.caseInsensitiveContains; goog.string.countOf=function(a,b){return a&&b?a.split(b).length-1:0};goog.string.removeAt=function(a,b,c){var d=a;0<=b&&bparseFloat(a))?String(b):a}; goog.userAgent.getVersionRegexResult_=function(){var a=goog.userAgent.getUserAgentString();if(goog.userAgent.GECKO)return/rv:([^\);]+)(\)|;)/.exec(a);if(goog.userAgent.EDGE)return/Edge\/([\d\.]+)/.exec(a);if(goog.userAgent.IE)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(goog.userAgent.WEBKIT)return/WebKit\/(\S+)/.exec(a);if(goog.userAgent.OPERA)return/(?:Version)[ \/]?(\S+)/.exec(a)};goog.userAgent.getDocumentMode_=function(){var a=goog.global.document;return a?a.documentMode:void 0}; goog.userAgent.VERSION=goog.userAgent.determineVersion_();goog.userAgent.compare=function(a,b){return goog.string.compareVersions(a,b)};goog.userAgent.isVersionOrHigherCache_={};goog.userAgent.isVersionOrHigher=function(a){return goog.userAgent.ASSUME_ANY_VERSION||goog.reflect.cache(goog.userAgent.isVersionOrHigherCache_,a,function(){return 0<=goog.string.compareVersions(goog.userAgent.VERSION,a)})};goog.userAgent.isVersion=goog.userAgent.isVersionOrHigher; -goog.userAgent.isDocumentModeOrHigher=function(a){return Number(goog.userAgent.DOCUMENT_MODE)>=a};goog.userAgent.isDocumentMode=goog.userAgent.isDocumentModeOrHigher;goog.userAgent.DOCUMENT_MODE=function(){var a=goog.global.document,b=goog.userAgent.getDocumentMode_();if(a&&goog.userAgent.IE)return b||("CSS1Compat"==a.compatMode?parseInt(goog.userAgent.VERSION,10):5)}();goog.debug.entryPointRegistry={};goog.debug.EntryPointMonitor=function(){};goog.debug.entryPointRegistry.refList_=[];goog.debug.entryPointRegistry.monitors_=[];goog.debug.entryPointRegistry.monitorsMayExist_=!1;goog.debug.entryPointRegistry.register=function(a){goog.debug.entryPointRegistry.refList_[goog.debug.entryPointRegistry.refList_.length]=a;if(goog.debug.entryPointRegistry.monitorsMayExist_)for(var b=goog.debug.entryPointRegistry.monitors_,c=0;c=a};goog.userAgent.isDocumentMode=goog.userAgent.isDocumentModeOrHigher;goog.userAgent.DOCUMENT_MODE=function(){if(goog.global.document&&goog.userAgent.IE)return goog.userAgent.getDocumentMode_()}();goog.debug.LOGGING_ENABLED=goog.DEBUG;goog.debug.FORCE_SLOPPY_STACKS=!1;goog.debug.catchErrors=function(a,b,c){c=c||goog.global;var d=c.onerror,e=!!b;goog.userAgent.WEBKIT&&!goog.userAgent.isVersionOrHigher("535.3")&&(e=!e);c.onerror=function(b,c,h,k,l){d&&d(b,c,h,k,l);a({message:b,fileName:c,line:h,lineNumber:h,col:k,error:l});return e}}; goog.debug.expose=function(a,b){if("undefined"==typeof a)return"undefined";if(null==a)return"NULL";var c=[],d;for(d in a)if(b||!goog.isFunction(a[d])){var e=d+" = ";try{e+=a[d]}catch(f){e+="*** "+f+" ***"}c.push(e)}return c.join("\n")}; goog.debug.deepExpose=function(a,b){var c=[],d=[],e={},f=function(a,g){var h=g+" ";try{if(goog.isDef(a))if(goog.isNull(a))c.push("NULL");else if(goog.isString(a))c.push('"'+a.replace(/\n/g,"\n"+g)+'"');else if(goog.isFunction(a))c.push(String(a).replace(/\n/g,"\n"+g));else if(goog.isObject(a)){goog.hasUid(a)||d.push(a);var k=goog.getUid(a);if(e[k])c.push("*** reference loop detected (id="+k+") ***");else{e[k]=!0;c.push("{");for(var m in a)if(b||!goog.isFunction(a[m]))c.push("\n"),c.push(h),c.push(m+ " = "),f(a[m],h);c.push("\n"+g+"}");delete e[k]}}else c.push(a);else c.push("undefined")}catch(p){c.push("*** "+p+" ***")}};f(a,"");for(var g=0;ga.keyCode||void 0!=a.returnValue}; goog.events.uniqueIdCounter_=0;goog.events.getUniqueId=function(a){return a+"_"+goog.events.uniqueIdCounter_++};goog.events.getListenerMap_=function(a){a=a[goog.events.LISTENER_MAP_PROP_];return a instanceof goog.events.ListenerMap?a:null};goog.events.LISTENER_WRAPPER_PROP_="__closure_events_fn_"+(1E9*Math.random()>>>0); -goog.events.wrapListener=function(a){goog.asserts.assert(a,"Listener can not be null.");if(goog.isFunction(a))return a;goog.asserts.assert(a.handleEvent,"An object listener must have handleEvent method.");a[goog.events.LISTENER_WRAPPER_PROP_]||(a[goog.events.LISTENER_WRAPPER_PROP_]=function(b){return a.handleEvent(b)});return a[goog.events.LISTENER_WRAPPER_PROP_]};goog.debug.entryPointRegistry.register(function(a){goog.events.handleBrowserEvent_=a(goog.events.handleBrowserEvent_)});goog.dom.BrowserFeature={CAN_ADD_NAME_OR_TYPE_ATTRIBUTES:!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9),CAN_USE_CHILDREN_ATTRIBUTE:!goog.userAgent.GECKO&&!goog.userAgent.IE||goog.userAgent.IE&&goog.userAgent.isDocumentModeOrHigher(9)||goog.userAgent.GECKO&&goog.userAgent.isVersionOrHigher("1.9.1"),CAN_USE_INNER_TEXT:goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("9"),CAN_USE_PARENT_ELEMENT_PROPERTY:goog.userAgent.IE||goog.userAgent.OPERA||goog.userAgent.WEBKIT,INNER_HTML_NEEDS_SCOPED_ELEMENT:goog.userAgent.IE, +goog.events.wrapListener=function(a){goog.asserts.assert(a,"Listener can not be null.");if(goog.isFunction(a))return a;goog.asserts.assert(a.handleEvent,"An object listener must have handleEvent method.");a[goog.events.LISTENER_WRAPPER_PROP_]||(a[goog.events.LISTENER_WRAPPER_PROP_]=function(b){return a.handleEvent(b)});return a[goog.events.LISTENER_WRAPPER_PROP_]};goog.debug.entryPointRegistry.register(function(a){goog.events.handleBrowserEvent_=a(goog.events.handleBrowserEvent_)});goog.math={};goog.math.randomInt=function(a){return Math.floor(Math.random()*a)};goog.math.uniformRandom=function(a,b){return a+Math.random()*(b-a)};goog.math.clamp=function(a,b,c){return Math.min(Math.max(a,b),c)};goog.math.modulo=function(a,b){var c=a%b;return 0>c*b?c+b:c};goog.math.lerp=function(a,b,c){return a+c*(b-a)};goog.math.nearlyEquals=function(a,b,c){return Math.abs(a-b)<=(c||1E-6)};goog.math.standardAngle=function(a){return goog.math.modulo(a,360)}; +goog.math.standardAngleInRadians=function(a){return goog.math.modulo(a,2*Math.PI)};goog.math.toRadians=function(a){return a*Math.PI/180};goog.math.toDegrees=function(a){return 180*a/Math.PI};goog.math.angleDx=function(a,b){return b*Math.cos(goog.math.toRadians(a))};goog.math.angleDy=function(a,b){return b*Math.sin(goog.math.toRadians(a))};goog.math.angle=function(a,b,c,d){return goog.math.standardAngle(goog.math.toDegrees(Math.atan2(d-b,c-a)))}; +goog.math.angleDifference=function(a,b){var c=goog.math.standardAngle(b)-goog.math.standardAngle(a);180=c&&(c=360+c);return c};goog.math.sign=function(a){return 0a?-1:a}; +goog.math.longestCommonSubsequence=function(a,b,c,d){c=c||function(a,b){return a==b};d=d||function(b,c){return a[b]};for(var e=a.length,f=b.length,g=[],h=0;hg[h][k-1]?h--:k--;return l}; +goog.math.sum=function(a){return goog.array.reduce(arguments,function(a,c){return a+c},0)};goog.math.average=function(a){return goog.math.sum.apply(null,arguments)/arguments.length};goog.math.sampleVariance=function(a){var b=arguments.length;if(2>b)return 0;var c=goog.math.average.apply(null,arguments);return goog.math.sum.apply(null,goog.array.map(arguments,function(a){return Math.pow(a-c,2)}))/(b-1)};goog.math.standardDeviation=function(a){return Math.sqrt(goog.math.sampleVariance.apply(null,arguments))}; +goog.math.isInt=function(a){return isFinite(a)&&0==a%1};goog.math.isFiniteNumber=function(a){return isFinite(a)};goog.math.isNegativeZero=function(a){return 0==a&&0>1/a};goog.math.log10Floor=function(a){if(0a?1:0)}return 0==a?-Infinity:NaN};goog.math.safeFloor=function(a,b){goog.asserts.assert(!goog.isDef(b)||0a?0:a,f=!1;do{++a;a==d&&(a=0,f=!0);var g=this.getChildAt(a).getCaption();if(g&&g.match(b))return a}while(!f||a!=c);return this.getHighlightedIndex()},this.getHighlightedIndex())}; goog.ui.Menu.prototype.canHighlightItem=function(a){return(this.allowHighlightDisabled_||a.isEnabled())&&a.isVisible()&&a.isSupportedState(goog.ui.Component.State.HOVER)};goog.ui.Menu.prototype.decorateInternal=function(a){this.decorateContent(a);goog.ui.Menu.superClass_.decorateInternal.call(this,a)}; goog.ui.Menu.prototype.handleKeyEventInternal=function(a){var b=goog.ui.Menu.superClass_.handleKeyEventInternal.call(this,a);b||this.forEachChild(function(c){!b&&c.getMnemonic&&c.getMnemonic()==a.keyCode&&(this.isEnabled()&&this.setHighlighted(c),b=c.handleKeyEvent(a))},this);return b};goog.ui.Menu.prototype.setHighlightedIndex=function(a){goog.ui.Menu.superClass_.setHighlightedIndex.call(this,a);(a=this.getChildAt(a))&&goog.style.scrollIntoContainerView(a.getElement(),this.getElement())}; -goog.ui.Menu.prototype.decorateContent=function(a){var b=this.getRenderer();a=this.getDomHelper().getElementsByTagNameAndClass("DIV",b.getCssClass()+"-content",a);for(var c=a.length,d=0;d=this.getEffectiveLevel().value}; -goog.debug.Logger.prototype.log=function(a,b,c){goog.debug.LOGGING_ENABLED&&this.isLoggable(a)&&(goog.isFunction(b)&&(b=b()),this.doLogRecord_(this.getLogRecord(a,b,c)))};goog.debug.Logger.prototype.getLogRecord=function(a,b,c){a=goog.debug.LogBuffer.isBufferingEnabled()?goog.debug.LogBuffer.getInstance().addRecord(a,b,this.name_):new goog.debug.LogRecord(a,String(b),this.name_);c&&a.setException(c);return a}; -goog.debug.Logger.prototype.shout=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SHOUT,a,b)};goog.debug.Logger.prototype.severe=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SEVERE,a,b)};goog.debug.Logger.prototype.warning=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.WARNING,a,b)};goog.debug.Logger.prototype.info=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.INFO,a,b)}; -goog.debug.Logger.prototype.config=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.CONFIG,a,b)};goog.debug.Logger.prototype.fine=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINE,a,b)};goog.debug.Logger.prototype.finer=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINER,a,b)};goog.debug.Logger.prototype.finest=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINEST,a,b)}; -goog.debug.Logger.prototype.logRecord=function(a){goog.debug.LOGGING_ENABLED&&this.isLoggable(a.getLevel())&&this.doLogRecord_(a)};goog.debug.Logger.prototype.doLogRecord_=function(a){goog.debug.Logger.ENABLE_PROFILER_LOGGING&&goog.debug.Logger.logToProfilers("log:"+a.getMessage());if(goog.debug.Logger.ENABLE_HIERARCHY)for(var b=this;b;)b.callPublish_(a),b=b.getParent();else{b=0;for(var c;c=goog.debug.Logger.rootHandlers_[b++];)c(a)}}; -goog.debug.Logger.prototype.callPublish_=function(a){if(this.handlers_)for(var b=0,c;c=this.handlers_[b];b++)c(a)};goog.debug.Logger.prototype.setParent_=function(a){this.parent_=a};goog.debug.Logger.prototype.addChild_=function(a,b){this.getChildren()[a]=b};goog.debug.LogManager={};goog.debug.LogManager.loggers_={};goog.debug.LogManager.rootLogger_=null; -goog.debug.LogManager.initialize=function(){goog.debug.LogManager.rootLogger_||(goog.debug.LogManager.rootLogger_=new goog.debug.Logger(goog.debug.Logger.ROOT_LOGGER_NAME),goog.debug.LogManager.loggers_[goog.debug.Logger.ROOT_LOGGER_NAME]=goog.debug.LogManager.rootLogger_,goog.debug.LogManager.rootLogger_.setLevel(goog.debug.Logger.Level.CONFIG))};goog.debug.LogManager.getLoggers=function(){return goog.debug.LogManager.loggers_}; -goog.debug.LogManager.getRoot=function(){goog.debug.LogManager.initialize();return goog.debug.LogManager.rootLogger_};goog.debug.LogManager.getLogger=function(a){goog.debug.LogManager.initialize();return goog.debug.LogManager.loggers_[a]||goog.debug.LogManager.createLogger_(a)};goog.debug.LogManager.createFunctionForCatchErrors=function(a){return function(b){(a||goog.debug.LogManager.getRoot()).severe("Error: "+b.message+" ("+b.fileName+" @ Line: "+b.line+")")}}; -goog.debug.LogManager.createLogger_=function(a){var b=new goog.debug.Logger(a);if(goog.debug.Logger.ENABLE_HIERARCHY){var c=a.lastIndexOf("."),d=a.substr(0,c);c=a.substr(c+1);d=goog.debug.LogManager.getLogger(d);d.addChild_(c,b);b.setParent_(d)}return goog.debug.LogManager.loggers_[a]=b};goog.log={};goog.log.ENABLED=goog.debug.LOGGING_ENABLED;goog.log.ROOT_LOGGER_NAME=goog.debug.Logger.ROOT_LOGGER_NAME;goog.log.Logger=goog.debug.Logger;goog.log.Level=goog.debug.Logger.Level;goog.log.LogRecord=goog.debug.LogRecord;goog.log.getLogger=function(a,b){if(goog.log.ENABLED){var c=goog.debug.LogManager.getLogger(a);b&&c&&c.setLevel(b);return c}return null};goog.log.addHandler=function(a,b){goog.log.ENABLED&&a&&a.addHandler(b)}; -goog.log.removeHandler=function(a,b){return goog.log.ENABLED&&a?a.removeHandler(b):!1};goog.log.log=function(a,b,c,d){goog.log.ENABLED&&a&&a.log(b,c,d)};goog.log.error=function(a,b,c){goog.log.ENABLED&&a&&a.severe(b,c)};goog.log.warning=function(a,b,c){goog.log.ENABLED&&a&&a.warning(b,c)};goog.log.info=function(a,b,c){goog.log.ENABLED&&a&&a.info(b,c)};goog.log.fine=function(a,b,c){goog.log.ENABLED&&a&&a.fine(b,c)};goog.Thenable=function(){};goog.Thenable.prototype.then=function(a,b,c){};goog.Thenable.IMPLEMENTED_BY_PROP="$goog_Thenable";goog.Thenable.addImplementation=function(a){COMPILED?a.prototype[goog.Thenable.IMPLEMENTED_BY_PROP]=!0:a.prototype.$goog_Thenable=!0};goog.Thenable.isImplementedBy=function(a){if(!a)return!1;try{return COMPILED?!!a[goog.Thenable.IMPLEMENTED_BY_PROP]:!!a.$goog_Thenable}catch(b){return!1}};goog.async={};goog.async.FreeList=function(a,b,c){this.limit_=c;this.create_=a;this.reset_=b;this.occupants_=0;this.head_=null};goog.async.FreeList.prototype.get=function(){if(0=this.getEffectiveLevel().value}; +goog.debug.Logger.prototype.log=function(a,b,c){goog.debug.LOGGING_ENABLED&&this.isLoggable(a)&&(goog.isFunction(b)&&(b=b()),this.doLogRecord_(this.getLogRecord(a,b,c)))};goog.debug.Logger.prototype.getLogRecord=function(a,b,c){a=goog.debug.LogBuffer.isBufferingEnabled()?goog.debug.LogBuffer.getInstance().addRecord(a,b,this.name_):new goog.debug.LogRecord(a,String(b),this.name_);c&&a.setException(c);return a}; +goog.debug.Logger.prototype.shout=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SHOUT,a,b)};goog.debug.Logger.prototype.severe=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SEVERE,a,b)};goog.debug.Logger.prototype.warning=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.WARNING,a,b)};goog.debug.Logger.prototype.info=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.INFO,a,b)}; +goog.debug.Logger.prototype.config=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.CONFIG,a,b)};goog.debug.Logger.prototype.fine=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINE,a,b)};goog.debug.Logger.prototype.finer=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINER,a,b)};goog.debug.Logger.prototype.finest=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINEST,a,b)}; +goog.debug.Logger.prototype.logRecord=function(a){goog.debug.LOGGING_ENABLED&&this.isLoggable(a.getLevel())&&this.doLogRecord_(a)};goog.debug.Logger.prototype.doLogRecord_=function(a){goog.debug.Logger.ENABLE_PROFILER_LOGGING&&goog.debug.Logger.logToProfilers("log:"+a.getMessage());if(goog.debug.Logger.ENABLE_HIERARCHY)for(var b=this;b;)b.callPublish_(a),b=b.getParent();else{b=0;for(var c;c=goog.debug.Logger.rootHandlers_[b++];)c(a)}}; +goog.debug.Logger.prototype.callPublish_=function(a){if(this.handlers_)for(var b=0,c;c=this.handlers_[b];b++)c(a)};goog.debug.Logger.prototype.setParent_=function(a){this.parent_=a};goog.debug.Logger.prototype.addChild_=function(a,b){this.getChildren()[a]=b};goog.debug.LogManager={};goog.debug.LogManager.loggers_={};goog.debug.LogManager.rootLogger_=null; +goog.debug.LogManager.initialize=function(){goog.debug.LogManager.rootLogger_||(goog.debug.LogManager.rootLogger_=new goog.debug.Logger(goog.debug.Logger.ROOT_LOGGER_NAME),goog.debug.LogManager.loggers_[goog.debug.Logger.ROOT_LOGGER_NAME]=goog.debug.LogManager.rootLogger_,goog.debug.LogManager.rootLogger_.setLevel(goog.debug.Logger.Level.CONFIG))};goog.debug.LogManager.getLoggers=function(){return goog.debug.LogManager.loggers_}; +goog.debug.LogManager.getRoot=function(){goog.debug.LogManager.initialize();return goog.debug.LogManager.rootLogger_};goog.debug.LogManager.getLogger=function(a){goog.debug.LogManager.initialize();return goog.debug.LogManager.loggers_[a]||goog.debug.LogManager.createLogger_(a)};goog.debug.LogManager.createFunctionForCatchErrors=function(a){return function(b){(a||goog.debug.LogManager.getRoot()).severe("Error: "+b.message+" ("+b.fileName+" @ Line: "+b.line+")")}}; +goog.debug.LogManager.createLogger_=function(a){var b=new goog.debug.Logger(a);if(goog.debug.Logger.ENABLE_HIERARCHY){var c=a.lastIndexOf("."),d=a.substr(0,c);c=a.substr(c+1);d=goog.debug.LogManager.getLogger(d);d.addChild_(c,b);b.setParent_(d)}return goog.debug.LogManager.loggers_[a]=b};goog.log={};goog.log.ENABLED=goog.debug.LOGGING_ENABLED;goog.log.ROOT_LOGGER_NAME=goog.debug.Logger.ROOT_LOGGER_NAME;goog.log.Logger=goog.debug.Logger;goog.log.Level=goog.debug.Logger.Level;goog.log.LogRecord=goog.debug.LogRecord;goog.log.getLogger=function(a,b){if(goog.log.ENABLED){var c=goog.debug.LogManager.getLogger(a);b&&c&&c.setLevel(b);return c}return null};goog.log.addHandler=function(a,b){goog.log.ENABLED&&a&&a.addHandler(b)}; +goog.log.removeHandler=function(a,b){return goog.log.ENABLED&&a?a.removeHandler(b):!1};goog.log.log=function(a,b,c,d){goog.log.ENABLED&&a&&a.log(b,c,d)};goog.log.error=function(a,b,c){goog.log.ENABLED&&a&&a.severe(b,c)};goog.log.warning=function(a,b,c){goog.log.ENABLED&&a&&a.warning(b,c)};goog.log.info=function(a,b,c){goog.log.ENABLED&&a&&a.info(b,c)};goog.log.fine=function(a,b,c){goog.log.ENABLED&&a&&a.fine(b,c)};goog.ui.tree.TreeNode=function(a,b,c){goog.ui.tree.BaseNode.call(this,a,b,c)};goog.inherits(goog.ui.tree.TreeNode,goog.ui.tree.BaseNode);goog.ui.tree.TreeNode.prototype.getTree=function(){if(this.tree)return this.tree;var a=this.getParent();return a&&(a=a.getTree())?(this.setTreeInternal(a),a):null}; goog.ui.tree.TreeNode.prototype.getCalculatedIconClass=function(){var a=this.getExpanded(),b=this.getExpandedIconClass();if(a&&b)return b;b=this.getIconClass();if(!a&&b)return b;b=this.getConfig();if(this.hasChildren()){if(a&&b.cssExpandedFolderIcon)return b.cssTreeIcon+" "+b.cssExpandedFolderIcon;if(!a&&b.cssCollapsedFolderIcon)return b.cssTreeIcon+" "+b.cssCollapsedFolderIcon}else if(b.cssFileIcon)return b.cssTreeIcon+" "+b.cssFileIcon;return""};goog.structs={};goog.structs.getCount=function(a){return a.getCount&&"function"==typeof a.getCount?a.getCount():goog.isArrayLike(a)||goog.isString(a)?a.length:goog.object.getCount(a)};goog.structs.getValues=function(a){if(a.getValues&&"function"==typeof a.getValues)return a.getValues();if(goog.isString(a))return a.split("");if(goog.isArrayLike(a)){for(var b=[],c=a.length,d=0;db&&(b=c[d].length);d=-Infinity;var e=1;do{var f=d;var g=a;var h=[],k=c.length/e,l=1;for(d=0;df);return g}; +Blockly.utils.string.wrapScore_=function(a,b,c){for(var d=[0],e=[],f=0;fd&&(d=h,e=g)}return e?Blockly.utils.string.wrapMutate_(a,e,c):b};Blockly.utils.string.wrapToText_=function(a,b){for(var c=[],d=0;d=k?(e=2,g=k,(k=f.join(""))&&c.push(k),f.length=0):"{"==k?e=3:(f.push("%",k),e=0):2==e?"0"<=k&&"9">=k?g+=k:(c.push(parseInt(g,10)),h--,e=0):3==e&&(""==k?(f.splice(0,0,"%{"),h--,e=0):"}"!=k?f.push(k):(e=f.join(""),/[a-zA-Z][a-zA-Z0-9_]*/.test(e)?(k=e.toUpperCase(), -(k=Blockly.utils.startsWith(k,"BKY_")?k.substring(4):null)&&k in Blockly.Msg?(e=Blockly.Msg[k],"string"==typeof e?Array.prototype.push.apply(c,Blockly.utils.tokenizeInterpolation_(e,b)):b?c.push(String(e)):c.push(e)):c.push("%{"+e+"}")):c.push("%{"+e+"}"),e=f.length=0))}(k=f.join(""))&&c.push(k);d=[];for(h=f.length=0;hc;c++)b[c]=Blockly.utils.genUid.soup_.charAt(Math.random()*a);return b.join("")};Blockly.utils.genUid.soup_="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";Blockly.utils.wrap=function(a,b){for(var c=a.split("\n"),d=0;db&&(b=c[d].length);d=-Infinity;var e=1;do{var f=d;var g=a;var h=[],k=c.length/e,l=1;for(d=0;df);return g}; -Blockly.utils.wrapScore_=function(a,b,c){for(var d=[0],e=[],f=0;fd&&(d=h,e=g)}return e?Blockly.utils.wrapMutate_(a,e,c):b};Blockly.utils.wrapToText_=function(a,b){for(var c=[],d=0;d=k?(e=2,g=k,(k=f.join(""))&&c.push(k),f.length=0):"{"==k?e=3:(f.push("%",k),e=0):2==e?"0"<=k&&"9">=k?g+=k:(c.push(parseInt(g,10)),h--,e=0):3==e&&(""==k?(f.splice(0,0,"%{"),h--,e=0):"}"!=k?f.push(k):(e=f.join(""),/[A-Z]\w*/i.test(e)?(k=e.toUpperCase(),(k= +Blockly.utils.string.startsWith(k,"BKY_")?k.substring(4):null)&&k in Blockly.Msg?(e=Blockly.Msg[k],"string"==typeof e?Array.prototype.push.apply(c,Blockly.utils.tokenizeInterpolation_(e,b)):b?c.push(String(e)):c.push(e)):c.push("%{"+e+"}")):c.push("%{"+e+"}"),e=f.length=0))}(k=f.join(""))&&c.push(k);d=[];for(h=f.length=0;hc;c++)b[c]=Blockly.utils.genUid.soup_.charAt(Math.random()*a);return b.join("")};Blockly.utils.genUid.soup_="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; +Blockly.utils.is3dSupported=function(){if(void 0!==Blockly.utils.is3dSupported.cached_)return Blockly.utils.is3dSupported.cached_;if(!Blockly.utils.global.getComputedStyle)return!1;var a=document.createElement("p"),b="none",c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(a,null);for(var d in c)if(void 0!==a.style[d]){a.style[d]="translate3d(1px,1px,1px)";b=Blockly.utils.global.getComputedStyle(a); +if(!b)return document.body.removeChild(a),!1;b=b.getPropertyValue(c[d])}document.body.removeChild(a);Blockly.utils.is3dSupported.cached_="none"!==b;return Blockly.utils.is3dSupported.cached_};Blockly.utils.runAfterPageLoad=function(a){if("object"!=typeof document)throw Error("Blockly.utils.runAfterPageLoad() requires browser document.");if("complete"==document.readyState)a();else var b=setInterval(function(){"complete"==document.readyState&&(clearInterval(b),a())},10)}; +Blockly.utils.getViewportBBox=function(){var a=goog.style.getViewportPageOffset(document);return{right:document.documentElement.clientWidth+a.x,bottom:document.documentElement.clientHeight+a.y,top:a.y,left:a.x}};Blockly.utils.arrayRemove=function(a,b){var c=a.indexOf(b);if(-1==c)return!1;a.splice(c,1);return!0}; +Blockly.utils.getDocumentScroll=function(){var a=document.documentElement,b=window;return Blockly.utils.userAgent.IE&&b.pageYOffset!=a.scrollTop?new Blockly.utils.Coordinate(a.scrollLeft,a.scrollTop):new Blockly.utils.Coordinate(b.pageXOffset||a.scrollLeft,b.pageYOffset||a.scrollTop)}; +Blockly.utils.getBlockTypeCounts=function(a,b){var c=Object.create(null),d=a.getDescendants(!0);if(b){var e=a.getNextBlock();e&&(e=d.indexOf(e),d.splice(e,d.length-e))}e=0;for(var f;f=d[e];e++)c[f.type]?c[f.type]++:c[f.type]=1;return c};Blockly.utils.global=this||self; +Blockly.Touch={};Blockly.Touch.TOUCH_ENABLED="ontouchstart"in Blockly.utils.global||!!(Blockly.utils.global.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!Blockly.utils.global.navigator||!Blockly.utils.global.navigator.maxTouchPoints&&!Blockly.utils.global.navigator.msMaxTouchPoints);Blockly.Touch.touchIdentifier_=null;Blockly.Touch.TOUCH_MAP={}; +Blockly.utils.global.PointerEvent?Blockly.Touch.TOUCH_MAP={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]}:Blockly.Touch.TOUCH_ENABLED&&(Blockly.Touch.TOUCH_MAP={mousedown:["touchstart"],mousemove:["touchmove"],mouseup:["touchend","touchcancel"]});Blockly.longPid_=0; Blockly.longStart_=function(a,b){Blockly.longStop_();a.changedTouches&&1!=a.changedTouches.length||(Blockly.longPid_=setTimeout(function(){a.changedTouches&&(a.button=2,a.clientX=a.changedTouches[0].clientX,a.clientY=a.changedTouches[0].clientY);b&&b.handleRightClick(a)},Blockly.LONGPRESS))};Blockly.longStop_=function(){Blockly.longPid_&&(clearTimeout(Blockly.longPid_),Blockly.longPid_=0)};Blockly.Touch.clearTouchIdentifier=function(){Blockly.Touch.touchIdentifier_=null}; Blockly.Touch.shouldHandleEvent=function(a){return!Blockly.Touch.isMouseOrTouchEvent(a)||Blockly.Touch.checkTouchIdentifier(a)};Blockly.Touch.getTouchIdentifierFromEvent=function(a){return void 0!=a.pointerId?a.pointerId:a.changedTouches&&a.changedTouches[0]&&void 0!==a.changedTouches[0].identifier&&null!==a.changedTouches[0].identifier?a.changedTouches[0].identifier:"mouse"}; -Blockly.Touch.checkTouchIdentifier=function(a){var b=Blockly.Touch.getTouchIdentifierFromEvent(a);return void 0!==Blockly.Touch.touchIdentifier_&&null!==Blockly.Touch.touchIdentifier_?Blockly.Touch.touchIdentifier_==b:"mousedown"==a.type||"touchstart"==a.type||"pointerdown"==a.type?(Blockly.Touch.touchIdentifier_=b,!0):!1};Blockly.Touch.setClientFromTouch=function(a){if(Blockly.utils.startsWith(a.type,"touch")){var b=a.changedTouches[0];a.clientX=b.clientX;a.clientY=b.clientY}}; -Blockly.Touch.isMouseOrTouchEvent=function(a){return Blockly.utils.startsWith(a.type,"touch")||Blockly.utils.startsWith(a.type,"mouse")||Blockly.utils.startsWith(a.type,"pointer")};Blockly.Touch.isTouchEvent=function(a){return Blockly.utils.startsWith(a.type,"touch")||Blockly.utils.startsWith(a.type,"pointer")}; -Blockly.Touch.splitEventByTouches=function(a){var b=[];if(a.changedTouches)for(var c=0;c";var d=Blockly.Xml.textToDom(""+a+"");b.domToMutation(d.firstChild)}Blockly.Events.fire(new Blockly.Events.Change(b,"mutation",null,c,a));break;default:console.warn("Unknown change type: "+this.element)}else console.warn("Can't change non-existent block: "+this.blockId)}; +Blockly.Events.Change.prototype.run=function(a){var b=this.getEventWorkspace_().getBlockById(this.blockId);if(b)switch(b.mutator&&b.mutator.setVisible(!1),a=a?this.newValue:this.oldValue,this.element){case "field":(b=b.getField(this.name))?(b.callValidator(a),b.setValue(a)):console.warn("Can't set non-existent field: "+this.name);break;case "comment":b.setCommentText(a||null);break;case "collapsed":b.setCollapsed(a);break;case "disabled":b.setEnabled(!a);break;case "inline":b.setInputsInline(a);break; +case "mutation":var c="";b.mutationToDom&&(c=(c=b.mutationToDom())&&Blockly.Xml.domToText(c));if(b.domToMutation){var d=Blockly.Xml.textToDom(a||"");b.domToMutation(d)}Blockly.Events.fire(new Blockly.Events.Change(b,"mutation",null,c,a));break;default:console.warn("Unknown change type: "+this.element)}else console.warn("Can't change non-existent block: "+this.blockId)}; Blockly.Events.Create=function(a){a&&(Blockly.Events.Create.superClass_.constructor.call(this,a),this.xml=a.workspace.rendered?Blockly.Xml.blockToDomWithXY(a):Blockly.Xml.blockToDom(a),this.ids=Blockly.Events.getDescendantIds_(a))};goog.inherits(Blockly.Events.Create,Blockly.Events.BlockBase);Blockly.Events.BlockCreate=Blockly.Events.Create;Blockly.Events.Create.prototype.type=Blockly.Events.CREATE; -Blockly.Events.Create.prototype.toJson=function(){var a=Blockly.Events.Create.superClass_.toJson.call(this);a.xml=Blockly.Xml.domToText(this.xml);a.ids=this.ids;return a};Blockly.Events.Create.prototype.fromJson=function(a){Blockly.Events.Create.superClass_.fromJson.call(this,a);this.xml=Blockly.Xml.textToDom(""+a.xml+"").firstChild;this.ids=a.ids}; -Blockly.Events.Create.prototype.run=function(a){var b=this.getEventWorkspace_();if(a)a=Blockly.Xml.utils.createElement("xml"),a.appendChild(this.xml),Blockly.Xml.domToWorkspace(a,b);else{a=0;for(var c;c=this.ids[a];a++){var d=b.getBlockById(c);d?d.dispose(!1,!1):c==this.blockId&&console.warn("Can't uncreate non-existent block: "+c)}}}; +Blockly.Events.Create.prototype.toJson=function(){var a=Blockly.Events.Create.superClass_.toJson.call(this);a.xml=Blockly.Xml.domToText(this.xml);a.ids=this.ids;return a};Blockly.Events.Create.prototype.fromJson=function(a){Blockly.Events.Create.superClass_.fromJson.call(this,a);this.xml=Blockly.Xml.textToDom(a.xml);this.ids=a.ids}; +Blockly.Events.Create.prototype.run=function(a){var b=this.getEventWorkspace_();if(a)a=Blockly.utils.xml.createElement("xml"),a.appendChild(this.xml),Blockly.Xml.domToWorkspace(a,b);else{a=0;for(var c;c=this.ids[a];a++){var d=b.getBlockById(c);d?d.dispose(!1,!1):c==this.blockId&&console.warn("Can't uncreate non-existent block: "+c)}}}; Blockly.Events.Delete=function(a){if(a){if(a.getParent())throw Error("Connected blocks cannot be deleted.");Blockly.Events.Delete.superClass_.constructor.call(this,a);this.oldXml=a.workspace.rendered?Blockly.Xml.blockToDomWithXY(a):Blockly.Xml.blockToDom(a);this.ids=Blockly.Events.getDescendantIds_(a)}};goog.inherits(Blockly.Events.Delete,Blockly.Events.BlockBase);Blockly.Events.BlockDelete=Blockly.Events.Delete;Blockly.Events.Delete.prototype.type=Blockly.Events.DELETE; Blockly.Events.Delete.prototype.toJson=function(){var a=Blockly.Events.Delete.superClass_.toJson.call(this);a.ids=this.ids;return a};Blockly.Events.Delete.prototype.fromJson=function(a){Blockly.Events.Delete.superClass_.fromJson.call(this,a);this.ids=a.ids}; -Blockly.Events.Delete.prototype.run=function(a){var b=this.getEventWorkspace_();if(a){a=0;for(var c;c=this.ids[a];a++){var d=b.getBlockById(c);d?d.dispose(!1,!1):c==this.blockId&&console.warn("Can't delete non-existent block: "+c)}}else a=Blockly.Xml.utils.createElement("xml"),a.appendChild(this.oldXml),Blockly.Xml.domToWorkspace(a,b)}; +Blockly.Events.Delete.prototype.run=function(a){var b=this.getEventWorkspace_();if(a){a=0;for(var c;c=this.ids[a];a++){var d=b.getBlockById(c);d?d.dispose(!1,!1):c==this.blockId&&console.warn("Can't delete non-existent block: "+c)}}else a=Blockly.utils.xml.createElement("xml"),a.appendChild(this.oldXml),Blockly.Xml.domToWorkspace(a,b)}; Blockly.Events.Move=function(a){a&&(Blockly.Events.Move.superClass_.constructor.call(this,a),a=this.currentLocation_(),this.oldParentId=a.parentId,this.oldInputName=a.inputName,this.oldCoordinate=a.coordinate)};goog.inherits(Blockly.Events.Move,Blockly.Events.BlockBase);Blockly.Events.BlockMove=Blockly.Events.Move;Blockly.Events.Move.prototype.type=Blockly.Events.MOVE; Blockly.Events.Move.prototype.toJson=function(){var a=Blockly.Events.Move.superClass_.toJson.call(this);this.newParentId&&(a.newParentId=this.newParentId);this.newInputName&&(a.newInputName=this.newInputName);this.newCoordinate&&(a.newCoordinate=Math.round(this.newCoordinate.x)+","+Math.round(this.newCoordinate.y));return a}; -Blockly.Events.Move.prototype.fromJson=function(a){Blockly.Events.Move.superClass_.fromJson.call(this,a);this.newParentId=a.newParentId;this.newInputName=a.newInputName;a.newCoordinate&&(a=a.newCoordinate.split(","),this.newCoordinate=new goog.math.Coordinate(parseFloat(a[0]),parseFloat(a[1])))};Blockly.Events.Move.prototype.recordNew=function(){var a=this.currentLocation_();this.newParentId=a.parentId;this.newInputName=a.inputName;this.newCoordinate=a.coordinate}; -Blockly.Events.Move.prototype.currentLocation_=function(){var a=Blockly.Workspace.getById(this.workspaceId).getBlockById(this.blockId),b={},c=a.getParent();if(c){if(b.parentId=c.id,a=c.getInputWithBlock(a))b.inputName=a.name}else b.coordinate=a.getRelativeToSurfaceXY();return b};Blockly.Events.Move.prototype.isNull=function(){return this.oldParentId==this.newParentId&&this.oldInputName==this.newInputName&&goog.math.Coordinate.equals(this.oldCoordinate,this.newCoordinate)}; +Blockly.Events.Move.prototype.fromJson=function(a){Blockly.Events.Move.superClass_.fromJson.call(this,a);this.newParentId=a.newParentId;this.newInputName=a.newInputName;a.newCoordinate&&(a=a.newCoordinate.split(","),this.newCoordinate=new Blockly.utils.Coordinate(parseFloat(a[0]),parseFloat(a[1])))};Blockly.Events.Move.prototype.recordNew=function(){var a=this.currentLocation_();this.newParentId=a.parentId;this.newInputName=a.inputName;this.newCoordinate=a.coordinate}; +Blockly.Events.Move.prototype.currentLocation_=function(){var a=Blockly.Workspace.getById(this.workspaceId).getBlockById(this.blockId),b={},c=a.getParent();if(c){if(b.parentId=c.id,a=c.getInputWithBlock(a))b.inputName=a.name}else b.coordinate=a.getRelativeToSurfaceXY();return b};Blockly.Events.Move.prototype.isNull=function(){return this.oldParentId==this.newParentId&&this.oldInputName==this.newInputName&&Blockly.utils.Coordinate.equals(this.oldCoordinate,this.newCoordinate)}; Blockly.Events.Move.prototype.run=function(a){var b=this.getEventWorkspace_(),c=b.getBlockById(this.blockId);if(c){var d=a?this.newParentId:this.oldParentId,e=a?this.newInputName:this.oldInputName;a=a?this.newCoordinate:this.oldCoordinate;var f=null;if(d&&(f=b.getBlockById(d),!f)){console.warn("Can't connect to non-existent block: "+d);return}c.getParent()&&c.unplug();if(a)e=c.getRelativeToSurfaceXY(),c.moveBy(a.x-e.x,a.y-e.y);else{c=c.outputConnection||c.previousConnection;if(e){if(b=f.getInput(e))var g= -b.connection}else c.type==Blockly.PREVIOUS_STATEMENT&&(g=f.nextConnection);g?c.connect(g):console.warn("Can't connect to non-existent input: "+e)}}else console.warn("Can't move non-existent block: "+this.blockId)}; -Blockly.Events.FinishedLoading=function(a){this.workspaceId=a.id;this.group=Blockly.Events.group_;this.recordUndo=!1};goog.inherits(Blockly.Events.FinishedLoading,Blockly.Events.Abstract);Blockly.Events.FinishedLoading.prototype.type=Blockly.Events.FINISHED_LOADING;Blockly.Events.FinishedLoading.prototype.toJson=function(){var a={type:this.type};this.group&&(a.group=this.group);this.workspaceId&&(a.workspaceId=this.workspaceId);return a}; -Blockly.Events.FinishedLoading.prototype.fromJson=function(a){this.workspaceId=a.workspaceId;this.group=a.group};Blockly.Xml.workspaceToDom=function(a,b){var c=Blockly.Xml.utils.createElement("xml"),d=Blockly.Xml.variablesToDom(Blockly.Variables.allUsedVarModels(a));d.hasChildNodes()&&c.appendChild(d);var e=a.getTopComments(!0);d=0;for(var f;f=e[d];d++)c.appendChild(f.toXmlWithXY(b));e=a.getTopBlocks(!0);for(d=0;f=e[d];d++)c.appendChild(Blockly.Xml.blockToDomWithXY(f,b));return c}; -Blockly.Xml.variablesToDom=function(a){for(var b=Blockly.Xml.utils.createElement("variables"),c=0,d;d=a[c];c++){var e=Blockly.Xml.utils.createElement("variable");e.appendChild(Blockly.Xml.utils.createTextNode(d.name));e.setAttribute("type",d.type);e.setAttribute("id",d.getId());b.appendChild(e)}return b}; -Blockly.Xml.blockToDomWithXY=function(a,b){var c;a.workspace.RTL&&(c=a.workspace.getWidth());var d=Blockly.Xml.blockToDom(a,b),e=a.getRelativeToSurfaceXY();d.setAttribute("x",Math.round(a.workspace.RTL?c-e.x:e.x));d.setAttribute("y",Math.round(e.y));return d}; -Blockly.Xml.fieldToDomVariable_=function(a){null==a.getValue()&&(a.initModel(),a.getValue());var b=a.getVariable();if(!b)throw Error("Tried to serialize a variable field with no variable.");var c=Blockly.Xml.utils.createElement("field");c.appendChild(Blockly.Xml.utils.createTextNode(b.name));c.setAttribute("name",a.name);c.setAttribute("id",b.getId());c.setAttribute("variabletype",b.type);return c}; -Blockly.Xml.fieldToDom_=function(a){if(a.name&&a.EDITABLE){if(a.referencesVariables())return Blockly.Xml.fieldToDomVariable_(a);var b=Blockly.Xml.utils.createElement("field");b.appendChild(Blockly.Xml.utils.createTextNode(a.getValue()));b.setAttribute("name",a.name);return b}return null};Blockly.Xml.allFieldsToDom_=function(a,b){for(var c=0,d;d=a.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)(f=Blockly.Xml.fieldToDom_(f))&&b.appendChild(f)}; -Blockly.Xml.blockToDom=function(a,b){var c=Blockly.Xml.utils.createElement(a.isShadow()?"shadow":"block");c.setAttribute("type",a.type);b||c.setAttribute("id",a.id);if(a.mutationToDom){var d=a.mutationToDom();d&&(d.hasChildNodes()||d.hasAttributes())&&c.appendChild(d)}Blockly.Xml.allFieldsToDom_(a,c);var e=a.getCommentText();e&&(d=Blockly.Xml.utils.createElement("comment"),d.appendChild(Blockly.Xml.utils.createTextNode(e)),"object"==typeof a.comment&&(d.setAttribute("pinned",a.comment.isVisible()), -e=a.comment.getBubbleSize(),d.setAttribute("h",e.height),d.setAttribute("w",e.width)),c.appendChild(d));a.data&&(d=Blockly.Xml.utils.createElement("data"),d.appendChild(Blockly.Xml.utils.createTextNode(a.data)),c.appendChild(d));e=0;for(var f;f=a.inputList[e];e++){var g,h=!0;if(f.type!=Blockly.DUMMY_INPUT){var k=f.connection.targetBlock();f.type==Blockly.INPUT_VALUE?g=Blockly.Xml.utils.createElement("value"):f.type==Blockly.NEXT_STATEMENT&&(g=Blockly.Xml.utils.createElement("statement"));d=f.connection.getShadowDom(); -!d||k&&k.isShadow()||g.appendChild(Blockly.Xml.cloneShadow_(d));k&&(g.appendChild(Blockly.Xml.blockToDom(k,b)),h=!1);g.setAttribute("name",f.name);h||c.appendChild(g)}}a.inputsInlineDefault!=a.inputsInline&&c.setAttribute("inline",a.inputsInline);a.isCollapsed()&&c.setAttribute("collapsed",!0);a.disabled&&c.setAttribute("disabled",!0);a.isDeletable()||a.isShadow()||c.setAttribute("deletable",!1);a.isMovable()||a.isShadow()||c.setAttribute("movable",!1);a.isEditable()||c.setAttribute("editable",!1); -if(e=a.getNextBlock())g=Blockly.Xml.utils.createElement("next"),g.appendChild(Blockly.Xml.blockToDom(e,b)),c.appendChild(g);d=a.nextConnection&&a.nextConnection.getShadowDom();!d||e&&e.isShadow()||g.appendChild(Blockly.Xml.cloneShadow_(d));return c}; -Blockly.Xml.cloneShadow_=function(a){for(var b=a=a.cloneNode(!0),c;b;)if(b.firstChild)b=b.firstChild;else{for(;b&&!b.nextSibling;)c=b,b=b.parentNode,3==c.nodeType&&""==c.data.trim()&&b.firstChild!=c&&Blockly.utils.removeNode(c);b&&(c=b,b=b.nextSibling,3==c.nodeType&&""==c.data.trim()&&Blockly.utils.removeNode(c))}return a};Blockly.Xml.domToText=function(a){return Blockly.Xml.utils.domToText(a)}; +b.connection}else c.type==Blockly.PREVIOUS_STATEMENT&&(g=f.nextConnection);g?c.connect(g):console.warn("Can't connect to non-existent input: "+e)}}else console.warn("Can't move non-existent block: "+this.blockId)};Blockly.Events.FinishedLoading=function(a){this.workspaceId=a.id;this.group=Blockly.Events.group_;this.recordUndo=!1};goog.inherits(Blockly.Events.FinishedLoading,Blockly.Events.Abstract);Blockly.Events.FinishedLoading.prototype.type=Blockly.Events.FINISHED_LOADING;Blockly.Events.FinishedLoading.prototype.toJson=function(){var a={type:this.type};this.group&&(a.group=this.group);this.workspaceId&&(a.workspaceId=this.workspaceId);return a}; +Blockly.Events.FinishedLoading.prototype.fromJson=function(a){this.workspaceId=a.workspaceId;this.group=a.group};Blockly.Xml={};Blockly.Xml.workspaceToDom=function(a,b){var c=Blockly.utils.xml.createElement("xml"),d=Blockly.Xml.variablesToDom(Blockly.Variables.allUsedVarModels(a));d.hasChildNodes()&&c.appendChild(d);var e=a.getTopComments(!0);d=0;for(var f;f=e[d];d++)c.appendChild(f.toXmlWithXY(b));e=a.getTopBlocks(!0);for(d=0;f=e[d];d++)c.appendChild(Blockly.Xml.blockToDomWithXY(f,b));return c}; +Blockly.Xml.variablesToDom=function(a){for(var b=Blockly.utils.xml.createElement("variables"),c=0,d;d=a[c];c++){var e=Blockly.utils.xml.createElement("variable");e.appendChild(Blockly.utils.xml.createTextNode(d.name));d.type&&e.setAttribute("type",d.type);e.id=d.getId();b.appendChild(e)}return b}; +Blockly.Xml.blockToDomWithXY=function(a,b){var c;a.workspace.RTL&&(c=a.workspace.getWidth());var d=Blockly.Xml.blockToDom(a,b),e=a.getRelativeToSurfaceXY();d.setAttribute("x",Math.round(a.workspace.RTL?c-e.x:e.x));d.setAttribute("y",Math.round(e.y));return d};Blockly.Xml.fieldToDom_=function(a){if(a.isSerializable()){var b=Blockly.utils.xml.createElement("field");b.setAttribute("name",a.name);return a.toXml(b)}return null}; +Blockly.Xml.allFieldsToDom_=function(a,b){for(var c=0,d;d=a.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)(f=Blockly.Xml.fieldToDom_(f))&&b.appendChild(f)}; +Blockly.Xml.blockToDom=function(a,b){var c=Blockly.utils.xml.createElement(a.isShadow()?"shadow":"block");c.setAttribute("type",a.type);b||(c.id=a.id);if(a.mutationToDom){var d=a.mutationToDom();d&&(d.hasChildNodes()||d.hasAttributes())&&c.appendChild(d)}Blockly.Xml.allFieldsToDom_(a,c);var e=a.getCommentText();e&&(d=Blockly.utils.xml.createElement("comment"),d.appendChild(Blockly.utils.xml.createTextNode(e)),"object"==typeof a.comment&&(d.setAttribute("pinned",a.comment.isVisible()),e=a.comment.getBubbleSize(), +d.setAttribute("h",e.height),d.setAttribute("w",e.width)),c.appendChild(d));a.data&&(d=Blockly.utils.xml.createElement("data"),d.appendChild(Blockly.utils.xml.createTextNode(a.data)),c.appendChild(d));e=0;for(var f;f=a.inputList[e];e++){var g,h=!0;if(f.type!=Blockly.DUMMY_INPUT){var k=f.connection.targetBlock();f.type==Blockly.INPUT_VALUE?g=Blockly.utils.xml.createElement("value"):f.type==Blockly.NEXT_STATEMENT&&(g=Blockly.utils.xml.createElement("statement"));d=f.connection.getShadowDom();!d||k&& +k.isShadow()||g.appendChild(Blockly.Xml.cloneShadow_(d,b));k&&(g.appendChild(Blockly.Xml.blockToDom(k,b)),h=!1);g.setAttribute("name",f.name);h||c.appendChild(g)}}void 0!=a.inputsInline&&a.inputsInline!=a.inputsInlineDefault&&c.setAttribute("inline",a.inputsInline);a.isCollapsed()&&c.setAttribute("collapsed",!0);a.isEnabled()||c.setAttribute("disabled",!0);a.isDeletable()||a.isShadow()||c.setAttribute("deletable",!1);a.isMovable()||a.isShadow()||c.setAttribute("movable",!1);a.isEditable()||c.setAttribute("editable", +!1);if(e=a.getNextBlock())g=Blockly.utils.xml.createElement("next"),g.appendChild(Blockly.Xml.blockToDom(e,b)),c.appendChild(g);d=a.nextConnection&&a.nextConnection.getShadowDom();!d||e&&e.isShadow()||g.appendChild(Blockly.Xml.cloneShadow_(d,b));return c}; +Blockly.Xml.cloneShadow_=function(a,b){for(var c=a=a.cloneNode(!0),d;c;)if(b&&"shadow"==c.nodeName&&c.removeAttribute("id"),c.firstChild)c=c.firstChild;else{for(;c&&!c.nextSibling;)d=c,c=c.parentNode,d.nodeType==Node.TEXT_NODE&&""==d.data.trim()&&c.firstChild!=d&&Blockly.utils.dom.removeNode(d);c&&(d=c,c=c.nextSibling,d.nodeType==Node.TEXT_NODE&&""==d.data.trim()&&Blockly.utils.dom.removeNode(d))}return a};Blockly.Xml.domToText=function(a){return Blockly.utils.xml.domToText(a)}; Blockly.Xml.domToPrettyText=function(a){a=Blockly.Xml.domToText(a).split("<");for(var b="",c=1;c"!=d.slice(-2)&&(b+=" ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1");return a.replace(/^\n/,"")}; -Blockly.Xml.textToDom=function(a){a=Blockly.Xml.utils.textToDomDocument(a);if(!a||!a.documentElement||"xml"!=a.documentElement.nodeName.toLowerCase())throw TypeError("Blockly.Xml.textToDom expected an document.");return a.documentElement};Blockly.Xml.clearWorkspaceAndLoadFromXml=function(a,b){b.setResizesEnabled(!1);b.clear();var c=Blockly.Xml.domToWorkspace(a,b);b.setResizesEnabled(!0);return c}; +Blockly.Xml.textToDom=function(a){var b=Blockly.utils.xml.textToDomDocument(a);if(!b||!b.documentElement||b.getElementsByTagName("parsererror").length)throw Error("textToDom was unable to parse: "+a);return b.documentElement};Blockly.Xml.clearWorkspaceAndLoadFromXml=function(a,b){b.setResizesEnabled(!1);b.clear();var c=Blockly.Xml.domToWorkspace(a,b);b.setResizesEnabled(!0);return c}; Blockly.Xml.domToWorkspace=function(a,b){if(a instanceof Blockly.Workspace){var c=a;a=b;b=c;console.warn("Deprecated call to Blockly.Xml.domToWorkspace, swap the arguments.")}var d;b.RTL&&(d=b.getWidth());c=[];Blockly.Field.startCache();var e=a.childNodes.length,f=Blockly.Events.getGroup();f||Blockly.Events.setGroup(!0);b.setResizesEnabled&&b.setResizesEnabled(!1);var g=!0;try{for(var h=0;h"+a.xml+"").firstChild};Blockly.Events.CommentCreate.prototype.run=function(a){Blockly.Events.CommentCreateDeleteHelper(this,a)}; -Blockly.Events.CommentCreateDeleteHelper=function(a,b){var c=a.getEventWorkspace_();if(b){var d=Blockly.Xml.utils.createElement("xml");d.appendChild(a.xml);Blockly.Xml.domToWorkspace(d,c)}else(c=c.getCommentById(a.commentId))?c.dispose(!1,!1):console.warn("Can't uncreate non-existent comment: "+a.commentId)};Blockly.Events.CommentDelete=function(a){a&&(Blockly.Events.CommentDelete.superClass_.constructor.call(this,a),this.xml=a.toXmlWithXY())};goog.inherits(Blockly.Events.CommentDelete,Blockly.Events.CommentBase); +Blockly.Events.CommentCreate.prototype.fromJson=function(a){Blockly.Events.CommentCreate.superClass_.fromJson.call(this,a);this.xml=Blockly.Xml.textToDom(a.xml)};Blockly.Events.CommentCreate.prototype.run=function(a){Blockly.Events.CommentCreateDeleteHelper(this,a)}; +Blockly.Events.CommentCreateDeleteHelper=function(a,b){var c=a.getEventWorkspace_();if(b){var d=Blockly.utils.xml.createElement("xml");d.appendChild(a.xml);Blockly.Xml.domToWorkspace(d,c)}else(c=c.getCommentById(a.commentId))?c.dispose(!1,!1):console.warn("Can't uncreate non-existent comment: "+a.commentId)};Blockly.Events.CommentDelete=function(a){a&&(Blockly.Events.CommentDelete.superClass_.constructor.call(this,a),this.xml=a.toXmlWithXY())};goog.inherits(Blockly.Events.CommentDelete,Blockly.Events.CommentBase); Blockly.Events.CommentDelete.prototype.type=Blockly.Events.COMMENT_DELETE;Blockly.Events.CommentDelete.prototype.toJson=function(){return Blockly.Events.CommentDelete.superClass_.toJson.call(this)};Blockly.Events.CommentDelete.prototype.fromJson=function(a){Blockly.Events.CommentDelete.superClass_.fromJson.call(this,a)};Blockly.Events.CommentDelete.prototype.run=function(a){Blockly.Events.CommentCreateDeleteHelper(this,!a)}; Blockly.Events.CommentMove=function(a){a&&(Blockly.Events.CommentMove.superClass_.constructor.call(this,a),this.comment_=a,this.oldCoordinate_=a.getXY(),this.newCoordinate_=null)};goog.inherits(Blockly.Events.CommentMove,Blockly.Events.CommentBase);Blockly.Events.CommentMove.prototype.recordNew=function(){if(!this.comment_)throw Error("Tried to record the new position of a comment on the same event twice.");this.newCoordinate_=this.comment_.getXY();this.comment_=null}; Blockly.Events.CommentMove.prototype.type=Blockly.Events.COMMENT_MOVE;Blockly.Events.CommentMove.prototype.setOldCoordinate=function(a){this.oldCoordinate_=a};Blockly.Events.CommentMove.prototype.toJson=function(){var a=Blockly.Events.CommentMove.superClass_.toJson.call(this);this.newCoordinate_&&(a.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y));return a}; -Blockly.Events.CommentMove.prototype.fromJson=function(a){Blockly.Events.CommentMove.superClass_.fromJson.call(this,a);a.newCoordinate&&(a=a.newCoordinate.split(","),this.newCoordinate_=new goog.math.Coordinate(parseFloat(a[0]),parseFloat(a[1])))};Blockly.Events.CommentMove.prototype.isNull=function(){return goog.math.Coordinate.equals(this.oldCoordinate_,this.newCoordinate_)}; -Blockly.Events.CommentMove.prototype.run=function(a){var b=this.getEventWorkspace_().getCommentById(this.commentId);if(b){a=a?this.newCoordinate_:this.oldCoordinate_;var c=b.getXY();b.moveBy(a.x-c.x,a.y-c.y)}else console.warn("Can't move non-existent comment: "+this.commentId)};Blockly.WorkspaceComment=function(a,b,c,d,e){this.id=e&&!a.getCommentById(e)?e:Blockly.utils.genUid();a.addTopComment(this);this.xy_=new goog.math.Coordinate(0,0);this.height_=c;this.width_=d;this.workspace=a;this.RTL=a.RTL;this.movable_=this.deletable_=!0;this.content_=b;this.isComment=!0;Blockly.WorkspaceComment.fireCreateEvent(this)}; +Blockly.Events.CommentMove.prototype.fromJson=function(a){Blockly.Events.CommentMove.superClass_.fromJson.call(this,a);a.newCoordinate&&(a=a.newCoordinate.split(","),this.newCoordinate_=new Blockly.utils.Coordinate(parseFloat(a[0]),parseFloat(a[1])))};Blockly.Events.CommentMove.prototype.isNull=function(){return Blockly.utils.Coordinate.equals(this.oldCoordinate_,this.newCoordinate_)}; +Blockly.Events.CommentMove.prototype.run=function(a){var b=this.getEventWorkspace_().getCommentById(this.commentId);if(b){a=a?this.newCoordinate_:this.oldCoordinate_;var c=b.getXY();b.moveBy(a.x-c.x,a.y-c.y)}else console.warn("Can't move non-existent comment: "+this.commentId)};Blockly.WorkspaceComment=function(a,b,c,d,e){this.id=e&&!a.getCommentById(e)?e:Blockly.utils.genUid();a.addTopComment(this);this.xy_=new Blockly.utils.Coordinate(0,0);this.height_=c;this.width_=d;this.workspace=a;this.RTL=a.RTL;this.movable_=this.deletable_=!0;this.content_=b;this.isComment=!0;Blockly.WorkspaceComment.fireCreateEvent(this)}; Blockly.WorkspaceComment.prototype.dispose=function(){this.workspace&&(Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.CommentDelete(this)),this.workspace.removeTopComment(this),this.workspace=null)};Blockly.WorkspaceComment.prototype.getHeight=function(){return this.height_};Blockly.WorkspaceComment.prototype.setHeight=function(a){this.height_=a};Blockly.WorkspaceComment.prototype.getWidth=function(){return this.width_}; -Blockly.WorkspaceComment.prototype.setWidth=function(a){this.width_=a};Blockly.WorkspaceComment.prototype.getXY=function(){return this.xy_.clone()};Blockly.WorkspaceComment.prototype.moveBy=function(a,b){var c=new Blockly.Events.CommentMove(this);this.xy_.translate(a,b);c.recordNew();Blockly.Events.fire(c)};Blockly.WorkspaceComment.prototype.isDeletable=function(){return this.deletable_&&!(this.workspace&&this.workspace.options.readOnly)}; +Blockly.WorkspaceComment.prototype.setWidth=function(a){this.width_=a};Blockly.WorkspaceComment.prototype.getXY=function(){return new Blockly.utils.Coordinate(this.xy_.x,this.xy_.y)};Blockly.WorkspaceComment.prototype.moveBy=function(a,b){var c=new Blockly.Events.CommentMove(this);this.xy_.translate(a,b);c.recordNew();Blockly.Events.fire(c)};Blockly.WorkspaceComment.prototype.isDeletable=function(){return this.deletable_&&!(this.workspace&&this.workspace.options.readOnly)}; Blockly.WorkspaceComment.prototype.setDeletable=function(a){this.deletable_=a};Blockly.WorkspaceComment.prototype.isMovable=function(){return this.movable_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.WorkspaceComment.prototype.setMovable=function(a){this.movable_=a};Blockly.WorkspaceComment.prototype.getContent=function(){return this.content_}; Blockly.WorkspaceComment.prototype.setContent=function(a){this.content_!=a&&(Blockly.Events.fire(new Blockly.Events.CommentChange(this,this.content_,a)),this.content_=a)};Blockly.WorkspaceComment.prototype.toXmlWithXY=function(a){a=this.toXml(a);a.setAttribute("x",Math.round(this.xy_.x));a.setAttribute("y",Math.round(this.xy_.y));a.setAttribute("h",this.height_);a.setAttribute("w",this.width_);return a}; -Blockly.WorkspaceComment.prototype.toXml=function(a){var b=Blockly.Xml.utils.createElement("comment");a||b.setAttribute("id",this.id);b.textContent=this.getContent();return b};Blockly.WorkspaceComment.fireCreateEvent=function(a){if(Blockly.Events.isEnabled()){var b=Blockly.Events.getGroup();b||Blockly.Events.setGroup(!0);try{Blockly.Events.fire(new Blockly.Events.CommentCreate(a))}finally{b||Blockly.Events.setGroup(!1)}}}; +Blockly.WorkspaceComment.prototype.toXml=function(a){var b=Blockly.utils.xml.createElement("comment");a||(b.id=this.id);b.textContent=this.getContent();return b};Blockly.WorkspaceComment.fireCreateEvent=function(a){if(Blockly.Events.isEnabled()){var b=Blockly.Events.getGroup();b||Blockly.Events.setGroup(!0);try{Blockly.Events.fire(new Blockly.Events.CommentCreate(a))}finally{b||Blockly.Events.setGroup(!1)}}}; Blockly.WorkspaceComment.fromXml=function(a,b){var c=Blockly.WorkspaceComment.parseAttributes(a);c=new Blockly.WorkspaceComment(b,c.content,c.h,c.w,c.id);var d=parseInt(a.getAttribute("x"),10),e=parseInt(a.getAttribute("y"),10);isNaN(d)||isNaN(e)||c.moveBy(d,e);Blockly.WorkspaceComment.fireCreateEvent(c);return c}; -Blockly.WorkspaceComment.parseAttributes=function(a){var b=a.getAttribute("h"),c=a.getAttribute("w");return{id:a.getAttribute("id"),h:b?parseInt(b,10):100,w:c?parseInt(c,10):100,x:parseInt(a.getAttribute("x"),10),y:parseInt(a.getAttribute("y"),10),content:a.textContent}};Blockly.Workspace=function(a){this.id=Blockly.utils.genUid();Blockly.Workspace.WorkspaceDB_[this.id]=this;this.options=a||{};this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.topBlocks_=[];this.topComments_=[];this.commentDB_=Object.create(null);this.listeners_=[];this.undoStack_=[];this.redoStack_=[];this.blockDB_=Object.create(null);this.typedBlocksDB_=Object.create(null);this.variableMap_=new Blockly.VariableMap(this); -this.potentialVariableMap_=null};Blockly.Workspace.prototype.rendered=!1;Blockly.Workspace.prototype.isClearing=!1;Blockly.Workspace.prototype.MAX_UNDO=1024;Blockly.Workspace.prototype.dispose=function(){this.listeners_.length=0;this.clear();delete Blockly.Workspace.WorkspaceDB_[this.id]};Blockly.Workspace.SCAN_ANGLE=3; +Blockly.WorkspaceComment.parseAttributes=function(a){var b=a.getAttribute("h"),c=a.getAttribute("w");return{id:a.getAttribute("id"),h:b?parseInt(b,10):100,w:c?parseInt(c,10):100,x:parseInt(a.getAttribute("x"),10),y:parseInt(a.getAttribute("y"),10),content:a.textContent}};Blockly.Theme=function(a,b){this.blockStyles_=a;this.categoryStyles_=b};Blockly.Theme.prototype.setAllBlockStyles=function(a){for(var b in a)this.setBlockStyle(b,a[b])};Blockly.Theme.prototype.getAllBlockStyles=function(){return this.blockStyles_};Blockly.Theme.prototype.getBlockStyle=function(a){return this.blockStyles_[a]};Blockly.Theme.prototype.setBlockStyle=function(a,b){this.blockStyles_[a]=b};Blockly.Theme.prototype.getCategoryStyle=function(a){return this.categoryStyles_[a]}; +Blockly.Theme.prototype.setCategoryStyle=function(a,b){this.categoryStyles_[a]=b};Blockly.Themes={};Blockly.Themes.Classic={};Blockly.Themes.Classic.defaultBlockStyles={colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}}; +Blockly.Themes.Classic.categoryStyles={colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}};Blockly.Themes.Classic=new Blockly.Theme(Blockly.Themes.Classic.defaultBlockStyles,Blockly.Themes.Classic.categoryStyles);Blockly.Workspace=function(a){this.id=Blockly.utils.genUid();Blockly.Workspace.WorkspaceDB_[this.id]=this;this.options=a||{};this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.topBlocks_=[];this.topComments_=[];this.commentDB_=Object.create(null);this.listeners_=[];this.undoStack_=[];this.redoStack_=[];this.blockDB_=Object.create(null);this.typedBlocksDB_=Object.create(null);this.variableMap_=new Blockly.VariableMap(this); +this.potentialVariableMap_=null;Blockly.getTheme()||Blockly.setTheme(Blockly.Themes.Classic)};Blockly.Workspace.prototype.rendered=!1;Blockly.Workspace.prototype.isClearing=!1;Blockly.Workspace.prototype.MAX_UNDO=1024;Blockly.Workspace.prototype.connectionDBList=null;Blockly.Workspace.prototype.dispose=function(){this.listeners_.length=0;this.clear();delete Blockly.Workspace.WorkspaceDB_[this.id]};Blockly.Workspace.SCAN_ANGLE=3; Blockly.Workspace.prototype.sortObjects_=function(a,b){var c=a.getRelativeToSurfaceXY(),d=b.getRelativeToSurfaceXY();return c.y+Blockly.Workspace.prototype.sortObjects_.offset*c.x-(d.y+Blockly.Workspace.prototype.sortObjects_.offset*d.x)};Blockly.Workspace.prototype.addTopBlock=function(a){this.topBlocks_.push(a)};Blockly.Workspace.prototype.removeTopBlock=function(a){if(!Blockly.utils.arrayRemove(this.topBlocks_,a))throw Error("Block not present in workspace's list of top-most blocks.");}; -Blockly.Workspace.prototype.getTopBlocks=function(a){var b=[].concat(this.topBlocks_);a&&1this.remainingCapacityOfType(c))return!1;b+=a[c]}return b>this.remainingCapacity()?!1:!0};Blockly.Workspace.prototype.hasBlockLimits=function(){return Infinity!=this.options.maxBlocks||!!this.options.maxInstances}; Blockly.Workspace.prototype.undo=function(a){var b=a?this.redoStack_:this.undoStack_,c=a?this.undoStack_:this.redoStack_,d=b.pop();if(d){for(var e=[d];b.length&&d.group&&d.group==b[b.length-1].group;)e.push(b.pop());for(b=0;d=e[b];b++)c.push(d);e=Blockly.Events.filter(e,a);Blockly.Events.recordUndo=!1;try{for(b=0;d=e[b];b++)d.run(a)}finally{Blockly.Events.recordUndo=!0}}};Blockly.Workspace.prototype.clearUndo=function(){this.undoStack_.length=0;this.redoStack_.length=0;Blockly.Events.clearPendingUndo()}; Blockly.Workspace.prototype.addChangeListener=function(a){this.listeners_.push(a);return a};Blockly.Workspace.prototype.removeChangeListener=function(a){Blockly.utils.arrayRemove(this.listeners_,a)};Blockly.Workspace.prototype.fireChangeListener=function(a){if(a.recordUndo)for(this.undoStack_.push(a),this.redoStack_.length=0;this.undoStack_.length>this.MAX_UNDO&&0<=this.MAX_UNDO;)this.undoStack_.shift();for(var b=0,c;c=this.listeners_[b];b++)c(a)}; Blockly.Workspace.prototype.getBlockById=function(a){return this.blockDB_[a]||null};Blockly.Workspace.prototype.getCommentById=function(a){return this.commentDB_[a]||null};Blockly.Workspace.prototype.allInputsFilled=function(a){for(var b=this.getTopBlocks(!1),c=0,d;d=b[c];c++)if(!d.allInputsFilled(a))return!1;return!0};Blockly.Workspace.prototype.getPotentialVariableMap=function(){return this.potentialVariableMap_}; Blockly.Workspace.prototype.createPotentialVariableMap=function(){this.potentialVariableMap_=new Blockly.VariableMap(this)};Blockly.Workspace.prototype.getVariableMap=function(){return this.variableMap_};Blockly.Workspace.WorkspaceDB_=Object.create(null);Blockly.Workspace.getById=function(a){return Blockly.Workspace.WorkspaceDB_[a]||null};Blockly.Workspace.getAll=function(){var a=[],b;for(b in Blockly.Workspace.WorkspaceDB_)a.push(Blockly.Workspace.WorkspaceDB_[b]);return a}; -Blockly.Workspace.prototype.clear=Blockly.Workspace.prototype.clear;Blockly.Workspace.prototype.clearUndo=Blockly.Workspace.prototype.clearUndo;Blockly.Workspace.prototype.addChangeListener=Blockly.Workspace.prototype.addChangeListener;Blockly.Workspace.prototype.removeChangeListener=Blockly.Workspace.prototype.removeChangeListener;Blockly.Bubble=function(a,b,c,d,e,f){this.workspace_=a;this.content_=b;this.shape_=c;c=Blockly.Bubble.ARROW_ANGLE;this.workspace_.RTL&&(c=-c);this.arrow_radians_=Blockly.utils.toRadians(c);a.getBubbleCanvas().appendChild(this.createDom_(b,!(!e||!f)));this.setAnchorLocation(d);e&&f||(b=this.content_.getBBox(),e=b.width+2*Blockly.Bubble.BORDER_WIDTH,f=b.height+2*Blockly.Bubble.BORDER_WIDTH);this.setBubbleSize(e,f);this.positionBubble_();this.renderArrow_();this.rendered_=!0;a.options.readOnly||(Blockly.bindEventWithChecks_(this.bubbleBack_, -"mousedown",this,this.bubbleMouseDown_),this.resizeGroup_&&Blockly.bindEventWithChecks_(this.resizeGroup_,"mousedown",this,this.resizeMouseDown_))};Blockly.Bubble.BORDER_WIDTH=6;Blockly.Bubble.ARROW_THICKNESS=5;Blockly.Bubble.ARROW_ANGLE=20;Blockly.Bubble.ARROW_BEND=4;Blockly.Bubble.ANCHOR_RADIUS=8;Blockly.Bubble.onMouseUpWrapper_=null;Blockly.Bubble.onMouseMoveWrapper_=null;Blockly.Bubble.prototype.resizeCallback_=null; +Blockly.Workspace.prototype.clear=Blockly.Workspace.prototype.clear;Blockly.Workspace.prototype.clearUndo=Blockly.Workspace.prototype.clearUndo;Blockly.Workspace.prototype.addChangeListener=Blockly.Workspace.prototype.addChangeListener;Blockly.Workspace.prototype.removeChangeListener=Blockly.Workspace.prototype.removeChangeListener;Blockly.Bubble=function(a,b,c,d,e,f){this.workspace_=a;this.content_=b;this.shape_=c;c=Blockly.Bubble.ARROW_ANGLE;this.workspace_.RTL&&(c=-c);this.arrow_radians_=Blockly.utils.math.toRadians(c);a.getBubbleCanvas().appendChild(this.createDom_(b,!(!e||!f)));this.setAnchorLocation(d);e&&f||(b=this.content_.getBBox(),e=b.width+2*Blockly.Bubble.BORDER_WIDTH,f=b.height+2*Blockly.Bubble.BORDER_WIDTH);this.setBubbleSize(e,f);this.positionBubble_();this.renderArrow_();this.rendered_=!0;a.options.readOnly|| +(Blockly.bindEventWithChecks_(this.bubbleBack_,"mousedown",this,this.bubbleMouseDown_),this.resizeGroup_&&Blockly.bindEventWithChecks_(this.resizeGroup_,"mousedown",this,this.resizeMouseDown_))};Blockly.Bubble.BORDER_WIDTH=6;Blockly.Bubble.ARROW_THICKNESS=5;Blockly.Bubble.ARROW_ANGLE=20;Blockly.Bubble.ARROW_BEND=4;Blockly.Bubble.ANCHOR_RADIUS=8;Blockly.Bubble.onMouseUpWrapper_=null;Blockly.Bubble.onMouseMoveWrapper_=null;Blockly.Bubble.prototype.resizeCallback_=null; Blockly.Bubble.unbindDragEvents_=function(){Blockly.Bubble.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Bubble.onMouseUpWrapper_),Blockly.Bubble.onMouseUpWrapper_=null);Blockly.Bubble.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Bubble.onMouseMoveWrapper_),Blockly.Bubble.onMouseMoveWrapper_=null)};Blockly.Bubble.bubbleMouseUp_=function(){Blockly.Touch.clearTouchIdentifier();Blockly.Bubble.unbindDragEvents_()};Blockly.Bubble.prototype.rendered_=!1;Blockly.Bubble.prototype.anchorXY_=null; Blockly.Bubble.prototype.relativeLeft_=0;Blockly.Bubble.prototype.relativeTop_=0;Blockly.Bubble.prototype.width_=0;Blockly.Bubble.prototype.height_=0;Blockly.Bubble.prototype.autoLayout_=!0; -Blockly.Bubble.prototype.createDom_=function(a,b){this.bubbleGroup_=Blockly.utils.createSvgElement("g",{},null);var c={filter:"url(#"+this.workspace_.options.embossFilterId+")"};-1!=goog.userAgent.getUserAgentString().indexOf("JavaFX")&&(c={});c=Blockly.utils.createSvgElement("g",c,this.bubbleGroup_);this.bubbleArrow_=Blockly.utils.createSvgElement("path",{},c);this.bubbleBack_=Blockly.utils.createSvgElement("rect",{"class":"blocklyDraggable",x:0,y:0,rx:Blockly.Bubble.BORDER_WIDTH,ry:Blockly.Bubble.BORDER_WIDTH}, -c);b?(this.resizeGroup_=Blockly.utils.createSvgElement("g",{"class":this.workspace_.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.bubbleGroup_),c=2*Blockly.Bubble.BORDER_WIDTH,Blockly.utils.createSvgElement("polygon",{points:"0,x x,x x,0".replace(/x/g,c.toString())},this.resizeGroup_),Blockly.utils.createSvgElement("line",{"class":"blocklyResizeLine",x1:c/3,y1:c-1,x2:c-1,y2:c/3},this.resizeGroup_),Blockly.utils.createSvgElement("line",{"class":"blocklyResizeLine",x1:2*c/3,y1:c-1,x2:c-1,y2:2*c/3}, -this.resizeGroup_)):this.resizeGroup_=null;this.bubbleGroup_.appendChild(a);return this.bubbleGroup_};Blockly.Bubble.prototype.getSvgRoot=function(){return this.bubbleGroup_};Blockly.Bubble.prototype.setSvgId=function(a){this.bubbleGroup_.dataset&&(this.bubbleGroup_.dataset.blockId=a)};Blockly.Bubble.prototype.bubbleMouseDown_=function(a){var b=this.workspace_.getGesture(a);b&&b.handleBubbleStart(a,this)};Blockly.Bubble.prototype.showContextMenu_=function(a){}; +Blockly.Bubble.prototype.createDom_=function(a,b){this.bubbleGroup_=Blockly.utils.dom.createSvgElement("g",{},null);var c={filter:"url(#"+this.workspace_.options.embossFilterId+")"};Blockly.utils.userAgent.JAVA_FX&&(c={});c=Blockly.utils.dom.createSvgElement("g",c,this.bubbleGroup_);this.bubbleArrow_=Blockly.utils.dom.createSvgElement("path",{},c);this.bubbleBack_=Blockly.utils.dom.createSvgElement("rect",{"class":"blocklyDraggable",x:0,y:0,rx:Blockly.Bubble.BORDER_WIDTH,ry:Blockly.Bubble.BORDER_WIDTH}, +c);b?(this.resizeGroup_=Blockly.utils.dom.createSvgElement("g",{"class":this.workspace_.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.bubbleGroup_),c=2*Blockly.Bubble.BORDER_WIDTH,Blockly.utils.dom.createSvgElement("polygon",{points:"0,x x,x x,0".replace(/x/g,c.toString())},this.resizeGroup_),Blockly.utils.dom.createSvgElement("line",{"class":"blocklyResizeLine",x1:c/3,y1:c-1,x2:c-1,y2:c/3},this.resizeGroup_),Blockly.utils.dom.createSvgElement("line",{"class":"blocklyResizeLine",x1:2*c/3,y1:c-1,x2:c- +1,y2:2*c/3},this.resizeGroup_)):this.resizeGroup_=null;this.bubbleGroup_.appendChild(a);return this.bubbleGroup_};Blockly.Bubble.prototype.getSvgRoot=function(){return this.bubbleGroup_};Blockly.Bubble.prototype.setSvgId=function(a){this.bubbleGroup_.dataset&&(this.bubbleGroup_.dataset.blockId=a)};Blockly.Bubble.prototype.bubbleMouseDown_=function(a){var b=this.workspace_.getGesture(a);b&&b.handleBubbleStart(a,this)};Blockly.Bubble.prototype.showContextMenu_=function(a){}; Blockly.Bubble.prototype.isDeletable=function(){return!1}; -Blockly.Bubble.prototype.resizeMouseDown_=function(a){this.promote_();Blockly.Bubble.unbindDragEvents_();Blockly.utils.isRightButton(a)||(this.workspace_.startDrag(a,new goog.math.Coordinate(this.workspace_.RTL?-this.width_:this.width_,this.height_)),Blockly.Bubble.onMouseUpWrapper_=Blockly.bindEventWithChecks_(document,"mouseup",this,Blockly.Bubble.bubbleMouseUp_),Blockly.Bubble.onMouseMoveWrapper_=Blockly.bindEventWithChecks_(document,"mousemove",this,this.resizeMouseMove_),Blockly.hideChaff()); +Blockly.Bubble.prototype.resizeMouseDown_=function(a){this.promote_();Blockly.Bubble.unbindDragEvents_();Blockly.utils.isRightButton(a)||(this.workspace_.startDrag(a,new Blockly.utils.Coordinate(this.workspace_.RTL?-this.width_:this.width_,this.height_)),Blockly.Bubble.onMouseUpWrapper_=Blockly.bindEventWithChecks_(document,"mouseup",this,Blockly.Bubble.bubbleMouseUp_),Blockly.Bubble.onMouseMoveWrapper_=Blockly.bindEventWithChecks_(document,"mousemove",this,this.resizeMouseMove_),Blockly.hideChaff()); a.stopPropagation()};Blockly.Bubble.prototype.resizeMouseMove_=function(a){this.autoLayout_=!1;a=this.workspace_.moveDrag(a);this.setBubbleSize(this.workspace_.RTL?-a.x:a.x,a.y);this.workspace_.RTL&&this.positionBubble_()};Blockly.Bubble.prototype.registerResizeEvent=function(a){this.resizeCallback_=a};Blockly.Bubble.prototype.promote_=function(){var a=this.bubbleGroup_.parentNode;return a.lastChild!==this.bubbleGroup_?(a.appendChild(this.bubbleGroup_),!0):!1}; Blockly.Bubble.prototype.setAnchorLocation=function(a){this.anchorXY_=a;this.rendered_&&this.positionBubble_()}; Blockly.Bubble.prototype.layoutBubble_=function(){var a=this.workspace_.getMetrics();a.viewLeft/=this.workspace_.scale;a.viewWidth/=this.workspace_.scale;a.viewTop/=this.workspace_.scale;a.viewHeight/=this.workspace_.scale;var b=this.getOptimalRelativeLeft_(a),c=this.getOptimalRelativeTop_(a),d=this.shape_.getBBox(),e={x:b,y:-this.height_-Blockly.BlockSvg.MIN_BLOCK_Y},f={x:-this.width_-30,y:c};c={x:d.width,y:c};var g={x:b,y:d.height};b=d.widthe&&(g=2*Math.PI-g);var h=g+Math.PI/2;h>2*Math.PI&&(h-=2*Math.PI);var k=Math.sin(h),l=Math.cos(h),n=this.getBubbleSize();h=(n.width+n.height)/Blockly.Bubble.ARROW_THICKNESS;h=Math.min(h,n.width,n.height)/4;n=1-Blockly.Bubble.ANCHOR_RADIUS/f;d=b+ n*d;e=c+n*e;n=b+h*l;var m=c+h*k;b-=h*l;c-=h*k;k=g+this.arrow_radians_;k>2*Math.PI&&(k-=2*Math.PI);g=Math.sin(k)*f/Blockly.Bubble.ARROW_BEND;f=Math.cos(k)*f/Blockly.Bubble.ARROW_BEND;a.push("M"+n+","+m);a.push("C"+(n+f)+","+(m+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");this.bubbleArrow_.setAttribute("d",a.join(" "))};Blockly.Bubble.prototype.setColour=function(a){this.bubbleBack_.setAttribute("fill",a);this.bubbleArrow_.setAttribute("fill",a)}; -Blockly.Bubble.prototype.dispose=function(){Blockly.Bubble.unbindDragEvents_();Blockly.utils.removeNode(this.bubbleGroup_);this.shape_=this.content_=this.workspace_=this.resizeGroup_=this.bubbleBack_=this.bubbleArrow_=this.bubbleGroup_=null};Blockly.Bubble.prototype.moveDuringDrag=function(a,b){a?a.translateSurface(b.x,b.y):this.moveTo(b.x,b.y);this.relativeLeft_=this.workspace_.RTL?this.anchorXY_.x-b.x-this.width_:b.x-this.anchorXY_.x;this.relativeTop_=b.y-this.anchorXY_.y;this.renderArrow_()}; -Blockly.Bubble.prototype.getRelativeToSurfaceXY=function(){return new goog.math.Coordinate(this.anchorXY_.x+this.relativeLeft_,this.anchorXY_.y+this.relativeTop_)};Blockly.Bubble.prototype.setAutoLayout=function(a){this.autoLayout_=a};Blockly.Events.Ui=function(a,b,c,d){Blockly.Events.Ui.superClass_.constructor.call(this);this.blockId=a?a.id:null;this.workspaceId=a?a.workspace.id:null;this.element=b;this.oldValue=c;this.newValue=d;this.recordUndo=!1};goog.inherits(Blockly.Events.Ui,Blockly.Events.Abstract);Blockly.Events.Ui.prototype.type=Blockly.Events.UI; +Blockly.Bubble.prototype.dispose=function(){Blockly.Bubble.unbindDragEvents_();Blockly.utils.dom.removeNode(this.bubbleGroup_);this.shape_=this.content_=this.workspace_=this.resizeGroup_=this.bubbleBack_=this.bubbleArrow_=this.bubbleGroup_=null};Blockly.Bubble.prototype.moveDuringDrag=function(a,b){a?a.translateSurface(b.x,b.y):this.moveTo(b.x,b.y);this.relativeLeft_=this.workspace_.RTL?this.anchorXY_.x-b.x-this.width_:b.x-this.anchorXY_.x;this.relativeTop_=b.y-this.anchorXY_.y;this.renderArrow_()}; +Blockly.Bubble.prototype.getRelativeToSurfaceXY=function(){return new Blockly.utils.Coordinate(this.anchorXY_.x+this.relativeLeft_,this.anchorXY_.y+this.relativeTop_)};Blockly.Bubble.prototype.setAutoLayout=function(a){this.autoLayout_=a};Blockly.Events.Ui=function(a,b,c,d){Blockly.Events.Ui.superClass_.constructor.call(this);this.blockId=a?a.id:null;this.workspaceId=a?a.workspace.id:null;this.element=b;this.oldValue=c;this.newValue=d;this.recordUndo=!1};goog.inherits(Blockly.Events.Ui,Blockly.Events.Abstract);Blockly.Events.Ui.prototype.type=Blockly.Events.UI; Blockly.Events.Ui.prototype.toJson=function(){var a=Blockly.Events.Ui.superClass_.toJson.call(this);a.element=this.element;void 0!==this.newValue&&(a.newValue=this.newValue);this.blockId&&(a.blockId=this.blockId);return a};Blockly.Events.Ui.prototype.fromJson=function(a){Blockly.Events.Ui.superClass_.fromJson.call(this,a);this.element=a.element;this.newValue=a.newValue;this.blockId=a.blockId};Blockly.Icon=function(a){this.block_=a};Blockly.Icon.prototype.collapseHidden=!0;Blockly.Icon.prototype.SIZE=17;Blockly.Icon.prototype.bubble_=null;Blockly.Icon.prototype.iconXY_=null; -Blockly.Icon.prototype.createIcon=function(){this.iconGroup_||(this.iconGroup_=Blockly.utils.createSvgElement("g",{"class":"blocklyIconGroup"},null),this.block_.isInFlyout&&Blockly.utils.addClass(this.iconGroup_,"blocklyIconGroupReadonly"),this.drawIcon_(this.iconGroup_),this.block_.getSvgRoot().appendChild(this.iconGroup_),Blockly.bindEventWithChecks_(this.iconGroup_,"mouseup",this,this.iconClick_),this.updateEditable())}; -Blockly.Icon.prototype.dispose=function(){Blockly.utils.removeNode(this.iconGroup_);this.iconGroup_=null;this.setVisible(!1);this.block_=null};Blockly.Icon.prototype.updateEditable=function(){};Blockly.Icon.prototype.isVisible=function(){return!!this.bubble_};Blockly.Icon.prototype.iconClick_=function(a){this.block_.workspace.isDragging()||this.block_.isInFlyout||Blockly.utils.isRightButton(a)||this.setVisible(!this.isVisible())};Blockly.Icon.prototype.updateColour=function(){this.isVisible()&&this.bubble_.setColour(this.block_.getColour())}; +Blockly.Icon.prototype.createIcon=function(){this.iconGroup_||(this.iconGroup_=Blockly.utils.dom.createSvgElement("g",{"class":"blocklyIconGroup"},null),this.block_.isInFlyout&&Blockly.utils.dom.addClass(this.iconGroup_,"blocklyIconGroupReadonly"),this.drawIcon_(this.iconGroup_),this.block_.getSvgRoot().appendChild(this.iconGroup_),Blockly.bindEventWithChecks_(this.iconGroup_,"mouseup",this,this.iconClick_),this.updateEditable())}; +Blockly.Icon.prototype.dispose=function(){Blockly.utils.dom.removeNode(this.iconGroup_);this.iconGroup_=null;this.setVisible(!1);this.block_=null};Blockly.Icon.prototype.updateEditable=function(){};Blockly.Icon.prototype.isVisible=function(){return!!this.bubble_};Blockly.Icon.prototype.iconClick_=function(a){this.block_.workspace.isDragging()||this.block_.isInFlyout||Blockly.utils.isRightButton(a)||this.setVisible(!this.isVisible())}; +Blockly.Icon.prototype.updateColour=function(){this.isVisible()&&this.bubble_.setColour(this.block_.getColour())}; Blockly.Icon.prototype.renderIcon=function(a){if(this.collapseHidden&&this.block_.isCollapsed()||this.block_.isInsertionMarker())return this.iconGroup_.setAttribute("display","none"),a;this.iconGroup_.setAttribute("display","block");var b=this.SIZE;this.block_.RTL&&(a-=b);this.iconGroup_.setAttribute("transform","translate("+a+",5)");this.computeIconLocation();return a=this.block_.RTL?a-Blockly.BlockSvg.SEP_SPACE_X:a+(b+Blockly.BlockSvg.SEP_SPACE_X)}; -Blockly.Icon.prototype.setIconLocation=function(a){this.iconXY_=a;this.isVisible()&&this.bubble_.setAnchorLocation(a)};Blockly.Icon.prototype.computeIconLocation=function(){var a=this.block_.getRelativeToSurfaceXY(),b=Blockly.utils.getRelativeXY(this.iconGroup_);a=new goog.math.Coordinate(a.x+b.x+this.SIZE/2,a.y+b.y+this.SIZE/2);goog.math.Coordinate.equals(this.getIconLocation(),a)||this.setIconLocation(a)};Blockly.Icon.prototype.getIconLocation=function(){return this.iconXY_}; +Blockly.Icon.prototype.setIconLocation=function(a){this.iconXY_=a;this.isVisible()&&this.bubble_.setAnchorLocation(a)};Blockly.Icon.prototype.computeIconLocation=function(){var a=this.block_.getRelativeToSurfaceXY(),b=Blockly.utils.getRelativeXY(this.iconGroup_);a=new Blockly.utils.Coordinate(a.x+b.x+this.SIZE/2,a.y+b.y+this.SIZE/2);Blockly.utils.Coordinate.equals(this.getIconLocation(),a)||this.setIconLocation(a)};Blockly.Icon.prototype.getIconLocation=function(){return this.iconXY_}; Blockly.Comment=function(a){Blockly.Comment.superClass_.constructor.call(this,a);this.createIcon()};goog.inherits(Blockly.Comment,Blockly.Icon);Blockly.Comment.prototype.text_="";Blockly.Comment.prototype.width_=160;Blockly.Comment.prototype.height_=80; -Blockly.Comment.prototype.drawIcon_=function(a){Blockly.utils.createSvgElement("circle",{"class":"blocklyIconShape",r:"8",cx:"8",cy:"8"},a);Blockly.utils.createSvgElement("path",{"class":"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},a);Blockly.utils.createSvgElement("rect",{"class":"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},a)}; -Blockly.Comment.prototype.createEditor_=function(){this.foreignObject_=Blockly.utils.createSvgElement("foreignObject",{x:Blockly.Bubble.BORDER_WIDTH,y:Blockly.Bubble.BORDER_WIDTH},null);var a=document.createElementNS(Blockly.HTML_NS,"body");a.setAttribute("xmlns",Blockly.HTML_NS);a.className="blocklyMinimalBody";var b=document.createElementNS(Blockly.HTML_NS,"textarea");b.className="blocklyCommentTextarea";b.setAttribute("dir",this.block_.RTL?"RTL":"LTR");a.appendChild(b);this.textarea_=b;this.foreignObject_.appendChild(a); -Blockly.bindEventWithChecks_(b,"mouseup",this,this.textareaFocus_,!0,!0);Blockly.bindEventWithChecks_(b,"wheel",this,function(a){a.stopPropagation()});Blockly.bindEventWithChecks_(b,"change",this,function(a){this.text_!=b.value&&(Blockly.Events.fire(new Blockly.Events.BlockChange(this.block_,"comment",null,this.text_,b.value)),this.text_=b.value)});setTimeout(function(){b.focus()},0);return this.foreignObject_}; +Blockly.Comment.prototype.drawIcon_=function(a){Blockly.utils.dom.createSvgElement("circle",{"class":"blocklyIconShape",r:"8",cx:"8",cy:"8"},a);Blockly.utils.dom.createSvgElement("path",{"class":"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},a);Blockly.utils.dom.createSvgElement("rect",{"class":"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},a)}; +Blockly.Comment.prototype.createEditor_=function(){this.foreignObject_=Blockly.utils.dom.createSvgElement("foreignObject",{x:Blockly.Bubble.BORDER_WIDTH,y:Blockly.Bubble.BORDER_WIDTH},null);var a=document.createElementNS(Blockly.utils.dom.HTML_NS,"body");a.setAttribute("xmlns",Blockly.utils.dom.HTML_NS);a.className="blocklyMinimalBody";var b=document.createElementNS(Blockly.utils.dom.HTML_NS,"textarea");b.className="blocklyCommentTextarea";b.setAttribute("dir",this.block_.RTL?"RTL":"LTR");a.appendChild(b); +this.textarea_=b;this.foreignObject_.appendChild(a);Blockly.bindEventWithChecks_(b,"mouseup",this,this.textareaFocus_,!0,!0);Blockly.bindEventWithChecks_(b,"wheel",this,function(a){a.stopPropagation()});Blockly.bindEventWithChecks_(b,"change",this,function(a){this.text_!=b.value&&(Blockly.Events.fire(new Blockly.Events.BlockChange(this.block_,"comment",null,this.text_,b.value)),this.text_=b.value)});setTimeout(function(){b.focus()},0);return this.foreignObject_}; Blockly.Comment.prototype.updateEditable=function(){this.isVisible()&&(this.setVisible(!1),this.setVisible(!0));Blockly.Icon.prototype.updateEditable.call(this)};Blockly.Comment.prototype.resizeBubble_=function(){if(this.isVisible()){var a=this.bubble_.getBubbleSize(),b=2*Blockly.Bubble.BORDER_WIDTH;this.foreignObject_.setAttribute("width",a.width-b);this.foreignObject_.setAttribute("height",a.height-b);this.textarea_.style.width=a.width-b-4+"px";this.textarea_.style.height=a.height-b-4+"px"}}; -Blockly.Comment.prototype.setVisible=function(a){if(a!=this.isVisible())if(Blockly.Events.fire(new Blockly.Events.Ui(this.block_,"commentOpen",!a,a)),!this.block_.isEditable()&&!this.textarea_||goog.userAgent.IE)Blockly.Warning.prototype.setVisible.call(this,a);else{var b=this.getText(),c=this.getBubbleSize();a?(this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svgPath_,this.iconXY_,this.width_,this.height_),this.bubble_.setSvgId(this.block_.id),this.bubble_.registerResizeEvent(this.resizeBubble_.bind(this)), +Blockly.Comment.prototype.setVisible=function(a){if(a!=this.isVisible())if(Blockly.Events.fire(new Blockly.Events.Ui(this.block_,"commentOpen",!a,a)),!this.block_.isEditable()&&!this.textarea_||Blockly.utils.userAgent.IE)Blockly.Warning.prototype.setVisible.call(this,a);else{var b=this.getText(),c=this.getBubbleSize();a?(this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svgPath_,this.iconXY_,this.width_,this.height_),this.bubble_.setSvgId(this.block_.id),this.bubble_.registerResizeEvent(this.resizeBubble_.bind(this)), this.updateColour()):(this.bubble_.dispose(),this.foreignObject_=this.textarea_=this.bubble_=null);this.setText(b);this.setBubbleSize(c.width,c.height)}};Blockly.Comment.prototype.textareaFocus_=function(a){this.bubble_.promote_()&&this.textarea_.focus()};Blockly.Comment.prototype.getBubbleSize=function(){return this.isVisible()?this.bubble_.getBubbleSize():{width:this.width_,height:this.height_}}; Blockly.Comment.prototype.setBubbleSize=function(a,b){this.textarea_?this.bubble_.setBubbleSize(a,b):(this.width_=a,this.height_=b)};Blockly.Comment.prototype.getText=function(){return this.textarea_?this.textarea_.value:this.text_};Blockly.Comment.prototype.setText=function(a){this.text_!=a&&(Blockly.Events.fire(new Blockly.Events.BlockChange(this.block_,"comment",null,this.text_,a)),this.text_=a);this.textarea_&&(this.textarea_.value=a)}; Blockly.Comment.prototype.dispose=function(){Blockly.Events.isEnabled()&&this.setText("");this.block_.comment=null;Blockly.Icon.prototype.dispose.call(this)};Blockly.Connection=function(a,b){this.sourceBlock_=a;this.type=b;a.workspace.connectionDBList&&(this.db_=a.workspace.connectionDBList[b],this.dbOpposite_=a.workspace.connectionDBList[Blockly.OPPOSITE_TYPE[b]],this.hidden_=!this.db_)};Blockly.Connection.CAN_CONNECT=0;Blockly.Connection.REASON_SELF_CONNECTION=1;Blockly.Connection.REASON_WRONG_TYPE=2;Blockly.Connection.REASON_TARGET_NULL=3;Blockly.Connection.REASON_CHECKS_FAILED=4;Blockly.Connection.REASON_DIFFERENT_WORKSPACES=5; Blockly.Connection.REASON_SHADOW_PARENT=6;Blockly.Connection.prototype.targetConnection=null;Blockly.Connection.prototype.check_=null;Blockly.Connection.prototype.shadowDom_=null;Blockly.Connection.prototype.x_=0;Blockly.Connection.prototype.y_=0;Blockly.Connection.prototype.inDB_=!1;Blockly.Connection.prototype.db_=null;Blockly.Connection.prototype.dbOpposite_=null;Blockly.Connection.prototype.hidden_=null; Blockly.Connection.prototype.connect_=function(a){var b=this,c=b.getSourceBlock(),d=a.getSourceBlock();a.isConnected()&&a.disconnect();if(b.isConnected()){var e=b.targetBlock(),f=b.getShadowDom();b.setShadowDom(null);if(e.isShadow())f=Blockly.Xml.blockToDom(e),e.dispose(),e=null;else if(b.type==Blockly.INPUT_VALUE){if(!e.outputConnection)throw Error("Orphan block does not have an output connection.");var g=Blockly.Connection.lastConnectionInRow_(d,e);g&&(e.outputConnection.connect(g),e=null)}else if(b.type== Blockly.NEXT_STATEMENT){if(!e.previousConnection)throw Error("Orphan block does not have a previous connection.");for(g=d;g.nextConnection;){var h=g.getNextBlock();if(h&&!h.isShadow())g=h;else{e.previousConnection.checkType_(g.nextConnection)&&(g.nextConnection.connect(e.previousConnection),e=null);break}}}if(e&&(b.disconnect(),Blockly.Events.recordUndo)){var k=Blockly.Events.getGroup();setTimeout(function(){e.workspace&&!e.getParent()&&(Blockly.Events.setGroup(k),e.outputConnection?e.outputConnection.bumpAwayFrom_(b): -e.previousConnection&&e.previousConnection.bumpAwayFrom_(b),Blockly.Events.setGroup(!1))},Blockly.BUMP_DELAY)}b.setShadowDom(f)}var l;Blockly.Events.isEnabled()&&(l=new Blockly.Events.BlockMove(d));Blockly.Connection.connectReciprocally_(b,a);d.setParent(c);l&&(l.recordNew(),Blockly.Events.fire(l))}; -Blockly.Connection.prototype.dispose=function(){if(this.isConnected())throw Error("Disconnect connection before disposing of it.");this.inDB_&&this.db_.removeConnection_(this);this.dbOpposite_=this.db_=null};Blockly.Connection.prototype.getSourceBlock=function(){return this.sourceBlock_};Blockly.Connection.prototype.isSuperior=function(){return this.type==Blockly.INPUT_VALUE||this.type==Blockly.NEXT_STATEMENT};Blockly.Connection.prototype.isConnected=function(){return!!this.targetConnection}; +e.previousConnection&&e.previousConnection.bumpAwayFrom_(b),Blockly.Events.setGroup(!1))},Blockly.BUMP_DELAY)}b.setShadowDom(f)}var l;Blockly.Events.isEnabled()&&(l=new Blockly.Events.BlockMove(d));Blockly.Connection.connectReciprocally_(b,a);d.setParent(c);l&&(l.recordNew(),Blockly.Events.fire(l))};Blockly.Connection.prototype.dispose=function(){if(this.isConnected())throw Error("Disconnect connection before disposing of it.");this.inDB_&&this.db_.removeConnection_(this)}; +Blockly.Connection.prototype.getSourceBlock=function(){return this.sourceBlock_};Blockly.Connection.prototype.isSuperior=function(){return this.type==Blockly.INPUT_VALUE||this.type==Blockly.NEXT_STATEMENT};Blockly.Connection.prototype.isConnected=function(){return!!this.targetConnection}; Blockly.Connection.prototype.canConnectWithReason_=function(a){if(!a)return Blockly.Connection.REASON_TARGET_NULL;if(this.isSuperior())var b=this.sourceBlock_,c=a.getSourceBlock();else c=this.sourceBlock_,b=a.getSourceBlock();return b&&b==c?Blockly.Connection.REASON_SELF_CONNECTION:a.type!=Blockly.OPPOSITE_TYPE[this.type]?Blockly.Connection.REASON_WRONG_TYPE:b&&c&&b.workspace!==c.workspace?Blockly.Connection.REASON_DIFFERENT_WORKSPACES:this.checkType_(a)?b.isShadow()&&!c.isShadow()?Blockly.Connection.REASON_SHADOW_PARENT: Blockly.Connection.CAN_CONNECT:Blockly.Connection.REASON_CHECKS_FAILED}; Blockly.Connection.prototype.checkConnection_=function(a){switch(this.canConnectWithReason_(a)){case Blockly.Connection.CAN_CONNECT:break;case Blockly.Connection.REASON_SELF_CONNECTION:throw Error("Attempted to connect a block to itself.");case Blockly.Connection.REASON_DIFFERENT_WORKSPACES:throw Error("Blocks not on same workspace.");case Blockly.Connection.REASON_WRONG_TYPE:throw Error("Attempt to connect incompatible types.");case Blockly.Connection.REASON_TARGET_NULL:throw Error("Target connection is null."); case Blockly.Connection.REASON_CHECKS_FAILED:throw Error("Connection checks failed. "+(this+" expected "+this.check_+", found "+a.check_));case Blockly.Connection.REASON_SHADOW_PARENT:throw Error("Connecting non-shadow to shadow block.");default:throw Error("Unknown connection failure: this should never happen!");}}; Blockly.Connection.prototype.canConnectToPrevious_=function(a){if(this.targetConnection||-1!=Blockly.draggingConnections_.indexOf(a))return!1;if(!a.targetConnection)return!0;a=a.targetBlock();return a.isInsertionMarker()?!a.getPreviousBlock():!1}; Blockly.Connection.prototype.isConnectionAllowed=function(a){if(a.sourceBlock_.isInsertionMarker()||this.canConnectWithReason_(a)!=Blockly.Connection.CAN_CONNECT)return!1;switch(a.type){case Blockly.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(a);case Blockly.OUTPUT_VALUE:if(a.isConnected()&&!a.targetBlock().isInsertionMarker()||this.isConnected())return!1;break;case Blockly.INPUT_VALUE:if(a.isConnected()&&!a.targetBlock().isMovable()&&!a.targetBlock().isShadow())return!1;break;case Blockly.NEXT_STATEMENT:if(a.isConnected()&& -!this.sourceBlock_.nextConnection&&!a.targetBlock().isShadow()&&a.targetBlock().nextConnection)return!1;break;default:throw Error("Unknown connection type in isConnectionAllowed");}return-1!=Blockly.draggingConnections_.indexOf(a)?!1:!0};Blockly.Connection.prototype.connect=function(a){this.targetConnection!=a&&(this.checkConnection_(a),this.isSuperior()?this.connect_(a):a.connect_(this))}; +!this.sourceBlock_.nextConnection&&!a.targetBlock().isShadow()&&a.targetBlock().nextConnection)return!1;break;default:throw Error("Unknown connection type in isConnectionAllowed");}return-1!=Blockly.draggingConnections_.indexOf(a)?!1:!0};Blockly.Connection.prototype.connect=function(a){if(this.targetConnection!=a){this.checkConnection_(a);var b=Blockly.Events.getGroup();b||Blockly.Events.setGroup(!0);this.isSuperior()?this.connect_(a):a.connect_(this);b||Blockly.Events.setGroup(!1)}}; Blockly.Connection.connectReciprocally_=function(a,b){if(!a||!b)throw Error("Cannot connect null connections.");a.targetConnection=b;b.targetConnection=a};Blockly.Connection.singleConnection_=function(a,b){for(var c=!1,d=0;d=this.connections_.length)return-1;for(var c=a.y_,d=b;0<=d&&this.connections_[d].y_==c;){if(this.connections_[d]==a)return d;d--}for(;bc)){var d=b.getSvgXY(a.getSvgRoot());a.outputConnection?(d.x+=(a.RTL?3:-3)*c,d.y+=13*c):a.previousConnection&&(d.x+=(a.RTL?-23:23)*c,d.y+=3*c);a=Blockly.utils.createSvgElement("circle",{cx:d.x,cy:d.y,r:0,fill:"none",stroke:"#888","stroke-width":10},b.getParentSvg());Blockly.BlockAnimations.connectionUiStep_(a,new Date,c)}}; -Blockly.BlockAnimations.connectionUiStep_=function(a,b,c){var d=(new Date-b)/150;1a.workspace.scale)){var b=a.getHeightWidth().height;b=Math.atan(10/b)/Math.PI*180;a.RTL||(b*=-1);Blockly.BlockAnimations.disconnectUiStep_(a.getSvgRoot(),b,new Date)}}; -Blockly.BlockAnimations.disconnectUiStep_=function(a,b,c){var d=(new Date-c)/200;1c)){var d=b.getSvgXY(a.getSvgRoot());a.outputConnection?(d.x+=(a.RTL?3:-3)*c,d.y+=13*c):a.previousConnection&&(d.x+=(a.RTL?-23:23)*c,d.y+=3*c);a=Blockly.utils.dom.createSvgElement("circle",{cx:d.x,cy:d.y,r:0,fill:"none",stroke:"#888","stroke-width":10},b.getParentSvg());Blockly.blockAnimations.connectionUiStep_(a,new Date,c)}}; +Blockly.blockAnimations.connectionUiStep_=function(a,b,c){var d=(new Date-b)/150;1a.workspace.scale)){var b=a.getHeightWidth().height;b=Math.atan(10/b)/Math.PI*180;a.RTL||(b*=-1);Blockly.blockAnimations.disconnectUiStep_(a.getSvgRoot(),b,new Date)}}; +Blockly.blockAnimations.disconnectUiStep_=function(a,b,c){var d=(new Date-c)/200;1b?!1:Blockly.RenderedConnection.superClass_.isConnectionAllowed.call(this,a)}; Blockly.RenderedConnection.prototype.disconnectInternal_=function(a,b){Blockly.RenderedConnection.superClass_.disconnectInternal_.call(this,a,b);a.rendered&&a.render();b.rendered&&(b.updateDisabled(),b.render())}; Blockly.RenderedConnection.prototype.respawnShadow_=function(){var a=this.getSourceBlock(),b=this.getShadowDom();if(a.workspace&&b&&Blockly.Events.recordUndo){Blockly.RenderedConnection.superClass_.respawnShadow_.call(this);b=this.targetBlock();if(!b)throw Error("Couldn't respawn the shadow block that should exist here.");b.initSvg();b.render(!1);a.rendered&&a.render()}};Blockly.RenderedConnection.prototype.neighbours_=function(a){return this.dbOpposite_.getNeighbours(this,a)}; @@ -1119,9 +1105,9 @@ Blockly.RenderedConnection.prototype.connect_=function(a){Blockly.RenderedConnec Blockly.RenderedConnection.prototype.onCheckChanged_=function(){this.isConnected()&&!this.checkType_(this.targetConnection)&&((this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug(),this.sourceBlock_.bumpNeighbours_())};Blockly.InsertionMarkerManager=function(a){this.topBlock_=Blockly.selected=a;this.workspace_=a.workspace;this.lastMarker_=this.lastOnStack_=null;this.firstMarker_=this.createMarkerBlock_(this.topBlock_);this.localConnection_=this.closestConnection_=null;this.wouldDeleteBlock_=!1;this.markerConnection_=null;this.highlightingBlock_=!1;this.highlightedBlock_=null;this.availableConnections_=this.initAvailableConnections_()}; Blockly.InsertionMarkerManager.prototype.dispose=function(){this.workspace_=this.topBlock_=null;this.availableConnections_.length=0;this.localConnection_=this.closestConnection_=null;Blockly.Events.disable();try{this.firstMarker_&&(this.firstMarker_.dispose(),this.firstMarker_=null),this.lastMarker_&&(this.lastMarker_.dispose(),this.lastMarker_=null)}finally{Blockly.Events.enable()}this.highlightedBlock_=null};Blockly.InsertionMarkerManager.prototype.wouldDeleteBlock=function(){return this.wouldDeleteBlock_}; Blockly.InsertionMarkerManager.prototype.wouldConnectBlock=function(){return!!this.closestConnection_}; -Blockly.InsertionMarkerManager.prototype.applyConnections=function(){if(this.closestConnection_&&(Blockly.Events.disable(),this.hidePreview_(),Blockly.Events.enable(),this.localConnection_.connect(this.closestConnection_),this.topBlock_.rendered)){var a=this.localConnection_.isSuperior()?this.closestConnection_:this.localConnection_;Blockly.BlockAnimations.connectionUiEffect(a.getSourceBlock());this.topBlock_.getRootBlock().bringToFront()}}; +Blockly.InsertionMarkerManager.prototype.applyConnections=function(){if(this.closestConnection_&&(Blockly.Events.disable(),this.hidePreview_(),Blockly.Events.enable(),this.localConnection_.connect(this.closestConnection_),this.topBlock_.rendered)){var a=this.localConnection_.isSuperior()?this.closestConnection_:this.localConnection_;Blockly.blockAnimations.connectionUiEffect(a.getSourceBlock());this.topBlock_.getRootBlock().bringToFront()}}; Blockly.InsertionMarkerManager.prototype.update=function(a,b){var c=this.getCandidate_(a);if((this.wouldDeleteBlock_=this.shouldDelete_(c,b))||this.shouldUpdatePreviews_(c,a))Blockly.Events.disable(),this.maybeHidePreview_(c),this.maybeShowPreview_(c),Blockly.Events.enable()}; -Blockly.InsertionMarkerManager.prototype.createMarkerBlock_=function(a){var b=a.type;Blockly.Events.disable();try{var c=this.workspace_.newBlock(b);c.setInsertionMarker(!0,a.width);if(a.mutationToDom){var d=a.mutationToDom();d&&c.domToMutation(d)}for(b=0;bc-Blockly.CURRENT_CONNECTION_PREFERENCE)}if(this.localConnection_||this.closestConnection_)console.error("Only one of localConnection_ and closestConnection_ was set."); else return!0}else return!(!this.localConnection_||!this.closestConnection_);console.error("Returning true from shouldUpdatePreviews, but it's not clear why.");return!0};Blockly.InsertionMarkerManager.prototype.getCandidate_=function(a){for(var b=this.getStartRadius_(),c=null,d=null,e=0;e=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom};Blockly.WorkspaceCommentSvg=function(a,b,c,d,e){this.svgGroup_=Blockly.utils.dom.createSvgElement("g",{"class":"blocklyComment"},null);this.svgGroup_.translate_="";this.svgRect_=Blockly.utils.dom.createSvgElement("rect",{"class":"blocklyCommentRect",x:0,y:0,rx:Blockly.WorkspaceCommentSvg.BORDER_RADIUS,ry:Blockly.WorkspaceCommentSvg.BORDER_RADIUS});this.svgGroup_.appendChild(this.svgRect_);this.rendered_=!1;this.useDragSurface_=Blockly.utils.is3dSupported()&&!!a.blockDragSurface_;Blockly.WorkspaceCommentSvg.superClass_.constructor.call(this, a,b,c,d,e);this.render()};goog.inherits(Blockly.WorkspaceCommentSvg,Blockly.WorkspaceComment);Blockly.WorkspaceCommentSvg.DEFAULT_SIZE=100; -Blockly.WorkspaceCommentSvg.prototype.dispose=function(){this.workspace&&(Blockly.selected==this&&(this.unselect(),this.workspace.cancelCurrentGesture()),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.CommentDelete(this)),Blockly.utils.removeNode(this.svgGroup_),this.svgRect_=this.svgGroup_=null,this.disposeInternal_(),Blockly.Events.disable(),Blockly.WorkspaceCommentSvg.superClass_.dispose.call(this),Blockly.Events.enable())}; +Blockly.WorkspaceCommentSvg.prototype.dispose=function(){this.workspace&&(Blockly.selected==this&&(this.unselect(),this.workspace.cancelCurrentGesture()),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.CommentDelete(this)),Blockly.utils.dom.removeNode(this.svgGroup_),this.svgRect_=this.svgGroup_=null,this.disposeInternal_(),Blockly.Events.disable(),Blockly.WorkspaceCommentSvg.superClass_.dispose.call(this),Blockly.Events.enable())}; Blockly.WorkspaceCommentSvg.prototype.initSvg=function(){if(!this.workspace.rendered)throw TypeError("Workspace is headless.");this.workspace.options.readOnly||this.eventsInit_||(Blockly.bindEventWithChecks_(this.svgRectTarget_,"mousedown",this,this.pathMouseDown_),Blockly.bindEventWithChecks_(this.svgHandleTarget_,"mousedown",this,this.pathMouseDown_));this.eventsInit_=!0;this.updateMovable();this.getSvgRoot().parentNode||this.workspace.getBubbleCanvas().appendChild(this.getSvgRoot())}; Blockly.WorkspaceCommentSvg.prototype.pathMouseDown_=function(a){var b=this.workspace.getGesture(a);b&&b.handleBubbleStart(a,this)};Blockly.WorkspaceCommentSvg.prototype.showContextMenu_=function(a){if(!this.workspace.options.readOnly){var b=[];this.isDeletable()&&this.isMovable()&&(b.push(Blockly.ContextMenu.commentDuplicateOption(this)),b.push(Blockly.ContextMenu.commentDeleteOption(this)));Blockly.ContextMenu.show(a,b,this.RTL)}}; Blockly.WorkspaceCommentSvg.prototype.select=function(){if(Blockly.selected!=this){var a=null;if(Blockly.selected){a=Blockly.selected.id;Blockly.Events.disable();try{Blockly.selected.unselect()}finally{Blockly.Events.enable()}}a=new Blockly.Events.Ui(null,"selected",a,this.id);a.workspaceId=this.workspace.id;Blockly.Events.fire(a);Blockly.selected=this;this.addSelect()}}; -Blockly.WorkspaceCommentSvg.prototype.unselect=function(){if(Blockly.selected==this){var a=new Blockly.Events.Ui(null,"selected",this.id,null);a.workspaceId=this.workspace.id;Blockly.Events.fire(a);Blockly.selected=null;this.removeSelect();this.blurFocus()}};Blockly.WorkspaceCommentSvg.prototype.addSelect=function(){Blockly.utils.addClass(this.svgGroup_,"blocklySelected");this.setFocus()}; -Blockly.WorkspaceCommentSvg.prototype.removeSelect=function(){Blockly.utils.removeClass(this.svgGroup_,"blocklySelected");this.blurFocus()};Blockly.WorkspaceCommentSvg.prototype.addFocus=function(){Blockly.utils.addClass(this.svgGroup_,"blocklyFocused")};Blockly.WorkspaceCommentSvg.prototype.removeFocus=function(){Blockly.utils.removeClass(this.svgGroup_,"blocklyFocused")}; -Blockly.WorkspaceCommentSvg.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=this.useDragSurface_?this.workspace.blockDragSurface_.getGroup():null,d=this.getSvgRoot();if(d){do{var e=Blockly.utils.getRelativeXY(d);a+=e.x;b+=e.y;this.useDragSurface_&&this.workspace.blockDragSurface_.getCurrentBlock()==d&&(e=this.workspace.blockDragSurface_.getSurfaceTranslation(),a+=e.x,b+=e.y);d=d.parentNode}while(d&&d!=this.workspace.getBubbleCanvas()&&d!=c)}return this.xy_=new goog.math.Coordinate(a,b)}; -Blockly.WorkspaceCommentSvg.prototype.moveBy=function(a,b){var c=new Blockly.Events.CommentMove(this),d=this.getRelativeToSurfaceXY();this.translate(d.x+a,d.y+b);this.xy_=new goog.math.Coordinate(d.x+a,d.y+b);c.recordNew();Blockly.Events.fire(c);this.workspace.resizeContents()};Blockly.WorkspaceCommentSvg.prototype.translate=function(a,b){this.xy_=new goog.math.Coordinate(a,b);this.getSvgRoot().setAttribute("transform","translate("+a+","+b+")")}; +Blockly.WorkspaceCommentSvg.prototype.unselect=function(){if(Blockly.selected==this){var a=new Blockly.Events.Ui(null,"selected",this.id,null);a.workspaceId=this.workspace.id;Blockly.Events.fire(a);Blockly.selected=null;this.removeSelect();this.blurFocus()}};Blockly.WorkspaceCommentSvg.prototype.addSelect=function(){Blockly.utils.dom.addClass(this.svgGroup_,"blocklySelected");this.setFocus()}; +Blockly.WorkspaceCommentSvg.prototype.removeSelect=function(){Blockly.utils.dom.removeClass(this.svgGroup_,"blocklySelected");this.blurFocus()};Blockly.WorkspaceCommentSvg.prototype.addFocus=function(){Blockly.utils.dom.addClass(this.svgGroup_,"blocklyFocused")};Blockly.WorkspaceCommentSvg.prototype.removeFocus=function(){Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyFocused")}; +Blockly.WorkspaceCommentSvg.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=this.useDragSurface_?this.workspace.blockDragSurface_.getGroup():null,d=this.getSvgRoot();if(d){do{var e=Blockly.utils.getRelativeXY(d);a+=e.x;b+=e.y;this.useDragSurface_&&this.workspace.blockDragSurface_.getCurrentBlock()==d&&(e=this.workspace.blockDragSurface_.getSurfaceTranslation(),a+=e.x,b+=e.y);d=d.parentNode}while(d&&d!=this.workspace.getBubbleCanvas()&&d!=c)}return this.xy_=new Blockly.utils.Coordinate(a, +b)};Blockly.WorkspaceCommentSvg.prototype.moveBy=function(a,b){var c=new Blockly.Events.CommentMove(this),d=this.getRelativeToSurfaceXY();this.translate(d.x+a,d.y+b);this.xy_=new Blockly.utils.Coordinate(d.x+a,d.y+b);c.recordNew();Blockly.Events.fire(c);this.workspace.resizeContents()};Blockly.WorkspaceCommentSvg.prototype.translate=function(a,b){this.xy_=new Blockly.utils.Coordinate(a,b);this.getSvgRoot().setAttribute("transform","translate("+a+","+b+")")}; Blockly.WorkspaceCommentSvg.prototype.moveToDragSurface_=function(){if(this.useDragSurface_){var a=this.getRelativeToSurfaceXY();this.clearTransformAttributes_();this.workspace.blockDragSurface_.translateSurface(a.x,a.y);this.workspace.blockDragSurface_.setBlocksAndShow(this.getSvgRoot())}};Blockly.WorkspaceCommentSvg.prototype.moveOffDragSurface_=function(a){this.useDragSurface_&&(this.translate(a.x,a.y),this.workspace.blockDragSurface_.clearAndHide(this.workspace.getCanvas()))}; -Blockly.WorkspaceCommentSvg.prototype.moveDuringDrag=function(a,b){a?a.translateSurface(b.x,b.y):(this.svgGroup_.translate_="translate("+b.x+","+b.y+")",this.svgGroup_.setAttribute("transform",this.svgGroup_.translate_+this.svgGroup_.skew_))};Blockly.WorkspaceCommentSvg.prototype.moveTo=function(a,b){this.translate(a,b)};Blockly.WorkspaceCommentSvg.prototype.clearTransformAttributes_=function(){Blockly.utils.removeAttribute(this.getSvgRoot(),"transform")}; -Blockly.WorkspaceCommentSvg.prototype.getBoundingRectangle=function(){var a=this.getRelativeToSurfaceXY(),b=this.getHeightWidth();if(this.RTL){var c=new goog.math.Coordinate(a.x-b.width,a.y);a=new goog.math.Coordinate(a.x,a.y+b.height)}else c=new goog.math.Coordinate(a.x,a.y),a=new goog.math.Coordinate(a.x+b.width,a.y+b.height);return{topLeft:c,bottomRight:a}}; -Blockly.WorkspaceCommentSvg.prototype.updateMovable=function(){this.isMovable()?Blockly.utils.addClass(this.svgGroup_,"blocklyDraggable"):Blockly.utils.removeClass(this.svgGroup_,"blocklyDraggable")};Blockly.WorkspaceCommentSvg.prototype.setMovable=function(a){Blockly.WorkspaceCommentSvg.superClass_.setMovable.call(this,a);this.updateMovable()}; -Blockly.WorkspaceCommentSvg.prototype.setDragging=function(a){a?(a=this.getSvgRoot(),a.translate_="",a.skew_="",Blockly.utils.addClass(this.svgGroup_,"blocklyDragging")):Blockly.utils.removeClass(this.svgGroup_,"blocklyDragging")};Blockly.WorkspaceCommentSvg.prototype.getSvgRoot=function(){return this.svgGroup_};Blockly.WorkspaceCommentSvg.prototype.getContent=function(){return this.textarea_?this.textarea_.value:this.content_}; -Blockly.WorkspaceCommentSvg.prototype.setContent=function(a){Blockly.WorkspaceCommentSvg.superClass_.setContent.call(this,a);this.textarea_&&(this.textarea_.value=a)};Blockly.WorkspaceCommentSvg.prototype.setDeleteStyle=function(a){a?Blockly.utils.addClass(this.svgGroup_,"blocklyDraggingDelete"):Blockly.utils.removeClass(this.svgGroup_,"blocklyDraggingDelete")};Blockly.WorkspaceCommentSvg.prototype.setAutoLayout=function(){}; -Blockly.WorkspaceCommentSvg.fromXml=function(a,b,c){Blockly.Events.disable();try{var d=Blockly.WorkspaceComment.parseAttributes(a),e=new Blockly.WorkspaceCommentSvg(b,d.content,d.h,d.w,d.id);b.rendered&&(e.initSvg(),e.render(!1));if(!isNaN(d.x)&&!isNaN(d.y))if(b.RTL){var f=c||b.getWidth();e.moveBy(f-d.x,d.y)}else e.moveBy(d.x,d.y)}finally{Blockly.Events.enable()}Blockly.WorkspaceComment.fireCreateEvent(e);return e}; +Blockly.WorkspaceCommentSvg.prototype.moveDuringDrag=function(a,b){a?a.translateSurface(b.x,b.y):(this.svgGroup_.translate_="translate("+b.x+","+b.y+")",this.svgGroup_.setAttribute("transform",this.svgGroup_.translate_+this.svgGroup_.skew_))};Blockly.WorkspaceCommentSvg.prototype.moveTo=function(a,b){this.translate(a,b)};Blockly.WorkspaceCommentSvg.prototype.clearTransformAttributes_=function(){this.getSvgRoot().removeAttribute("transform")}; +Blockly.WorkspaceCommentSvg.prototype.getBoundingRectangle=function(){var a=this.getRelativeToSurfaceXY(),b=this.getHeightWidth(),c=a.y,d=a.y+b.height;if(this.RTL){var e=a.x-b.width;a=a.x}else e=a.x,a=a.x+b.width;return new Blockly.utils.Rect(c,d,e,a)};Blockly.WorkspaceCommentSvg.prototype.updateMovable=function(){this.isMovable()?Blockly.utils.dom.addClass(this.svgGroup_,"blocklyDraggable"):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyDraggable")}; +Blockly.WorkspaceCommentSvg.prototype.setMovable=function(a){Blockly.WorkspaceCommentSvg.superClass_.setMovable.call(this,a);this.updateMovable()};Blockly.WorkspaceCommentSvg.prototype.setDragging=function(a){a?(a=this.getSvgRoot(),a.translate_="",a.skew_="",Blockly.utils.dom.addClass(this.svgGroup_,"blocklyDragging")):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyDragging")};Blockly.WorkspaceCommentSvg.prototype.getSvgRoot=function(){return this.svgGroup_}; +Blockly.WorkspaceCommentSvg.prototype.getContent=function(){return this.textarea_?this.textarea_.value:this.content_};Blockly.WorkspaceCommentSvg.prototype.setContent=function(a){Blockly.WorkspaceCommentSvg.superClass_.setContent.call(this,a);this.textarea_&&(this.textarea_.value=a)};Blockly.WorkspaceCommentSvg.prototype.setDeleteStyle=function(a){a?Blockly.utils.dom.addClass(this.svgGroup_,"blocklyDraggingDelete"):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyDraggingDelete")}; +Blockly.WorkspaceCommentSvg.prototype.setAutoLayout=function(){};Blockly.WorkspaceCommentSvg.fromXml=function(a,b,c){Blockly.Events.disable();try{var d=Blockly.WorkspaceComment.parseAttributes(a),e=new Blockly.WorkspaceCommentSvg(b,d.content,d.h,d.w,d.id);b.rendered&&(e.initSvg(),e.render(!1));if(!isNaN(d.x)&&!isNaN(d.y))if(b.RTL){var f=c||b.getWidth();e.moveBy(f-d.x,d.y)}else e.moveBy(d.x,d.y)}finally{Blockly.Events.enable()}Blockly.WorkspaceComment.fireCreateEvent(e);return e}; Blockly.WorkspaceCommentSvg.prototype.toXmlWithXY=function(a){var b;this.workspace.RTL&&(b=this.workspace.getWidth());a=this.toXml(a);var c=this.getRelativeToSurfaceXY();a.setAttribute("x",Math.round(this.workspace.RTL?b-c.x:c.x));a.setAttribute("y",Math.round(c.y));a.setAttribute("h",this.getHeight());a.setAttribute("w",this.getWidth());return a};Blockly.BubbleDragger=function(a,b){this.draggingBubble_=a;this.workspace_=b;this.deleteArea_=null;this.wouldDeleteBubble_=!1;this.startXY_=this.draggingBubble_.getRelativeToSurfaceXY();this.dragSurface_=Blockly.utils.is3dSupported()&&b.getBlockDragSurface()?b.getBlockDragSurface():null};Blockly.BubbleDragger.prototype.dispose=function(){this.dragSurface_=this.workspace_=this.draggingBubble_=null}; Blockly.BubbleDragger.prototype.startBubbleDrag=function(){Blockly.Events.getGroup()||Blockly.Events.setGroup(!0);this.workspace_.setResizesEnabled(!1);this.draggingBubble_.setAutoLayout(!1);this.dragSurface_&&this.moveToDragSurface_();this.draggingBubble_.setDragging&&this.draggingBubble_.setDragging(!0);var a=this.workspace_.getToolbox();if(a){var b=this.draggingBubble_.isDeletable()?"blocklyToolboxDelete":"blocklyToolboxGrab";a.addStyle(b)}}; -Blockly.BubbleDragger.prototype.dragBubble=function(a,b){var c=this.pixelsToWorkspaceUnits_(b);c=goog.math.Coordinate.sum(this.startXY_,c);this.draggingBubble_.moveDuringDrag(this.dragSurface_,c);this.draggingBubble_.isDeletable()&&(this.deleteArea_=this.workspace_.isDeleteArea(a),this.updateCursorDuringBubbleDrag_())}; +Blockly.BubbleDragger.prototype.dragBubble=function(a,b){var c=this.pixelsToWorkspaceUnits_(b);c=Blockly.utils.Coordinate.sum(this.startXY_,c);this.draggingBubble_.moveDuringDrag(this.dragSurface_,c);this.draggingBubble_.isDeletable()&&(this.deleteArea_=this.workspace_.isDeleteArea(a),this.updateCursorDuringBubbleDrag_())}; Blockly.BubbleDragger.prototype.maybeDeleteBubble_=function(){var a=this.workspace_.trashcan;this.wouldDeleteBubble_?(a&&setTimeout(a.close.bind(a),100),this.fireMoveEvent_(),this.draggingBubble_.dispose(!1,!0)):a&&a.close();return this.wouldDeleteBubble_}; Blockly.BubbleDragger.prototype.updateCursorDuringBubbleDrag_=function(){this.wouldDeleteBubble_=this.deleteArea_!=Blockly.DELETE_AREA_NONE;var a=this.workspace_.trashcan;this.wouldDeleteBubble_?(this.draggingBubble_.setDeleteStyle(!0),this.deleteArea_==Blockly.DELETE_AREA_TRASH&&a&&a.setOpen_(!0)):(this.draggingBubble_.setDeleteStyle(!1),a&&a.setOpen_(!1))}; -Blockly.BubbleDragger.prototype.endBubbleDrag=function(a,b){this.dragBubble(a,b);var c=this.pixelsToWorkspaceUnits_(b);c=goog.math.Coordinate.sum(this.startXY_,c);this.draggingBubble_.moveTo(c.x,c.y);this.maybeDeleteBubble_()||(this.dragSurface_&&this.dragSurface_.clearAndHide(this.workspace_.getBubbleCanvas()),this.draggingBubble_.setDragging&&this.draggingBubble_.setDragging(!1),this.fireMoveEvent_());this.workspace_.setResizesEnabled(!0);this.workspace_.toolbox_&&(c=this.draggingBubble_.isDeletable()? +Blockly.BubbleDragger.prototype.endBubbleDrag=function(a,b){this.dragBubble(a,b);var c=this.pixelsToWorkspaceUnits_(b);c=Blockly.utils.Coordinate.sum(this.startXY_,c);this.draggingBubble_.moveTo(c.x,c.y);this.maybeDeleteBubble_()||(this.dragSurface_&&this.dragSurface_.clearAndHide(this.workspace_.getBubbleCanvas()),this.draggingBubble_.setDragging&&this.draggingBubble_.setDragging(!1),this.fireMoveEvent_());this.workspace_.setResizesEnabled(!0);this.workspace_.toolbox_&&(c=this.draggingBubble_.isDeletable()? "blocklyToolboxDelete":"blocklyToolboxGrab",this.workspace_.toolbox_.removeStyle(c));Blockly.Events.setGroup(!1)};Blockly.BubbleDragger.prototype.fireMoveEvent_=function(){if(this.draggingBubble_.isComment){var a=new Blockly.Events.CommentMove(this.draggingBubble_);a.setOldCoordinate(this.startXY_);a.recordNew();Blockly.Events.fire(a)}}; -Blockly.BubbleDragger.prototype.pixelsToWorkspaceUnits_=function(a){a=new goog.math.Coordinate(a.x/this.workspace_.scale,a.y/this.workspace_.scale);this.workspace_.isMutator&&(a=a.scale(1/this.workspace_.options.parentWorkspace.scale));return a};Blockly.BubbleDragger.prototype.moveToDragSurface_=function(){this.draggingBubble_.moveTo(0,0);this.dragSurface_.translateSurface(this.startXY_.x,this.startXY_.y);this.dragSurface_.setBlocksAndShow(this.draggingBubble_.getSvgRoot())};Blockly.WorkspaceDragger=function(a){this.workspace_=a;this.startScrollXY_=new goog.math.Coordinate(a.scrollX,a.scrollY)};Blockly.WorkspaceDragger.prototype.dispose=function(){this.workspace_=null};Blockly.WorkspaceDragger.prototype.startDrag=function(){Blockly.selected&&Blockly.selected.unselect();this.workspace_.setupDragSurface()};Blockly.WorkspaceDragger.prototype.endDrag=function(a){this.drag(a);this.workspace_.resetDragSurface()}; -Blockly.WorkspaceDragger.prototype.drag=function(a){a=goog.math.Coordinate.sum(this.startScrollXY_,a);this.workspace_.scroll(a.x,a.y)};Blockly.FlyoutDragger=function(a){Blockly.FlyoutDragger.superClass_.constructor.call(this,a.getWorkspace());this.scrollbar_=a.scrollbar_;this.horizontalLayout_=a.horizontalLayout_};goog.inherits(Blockly.FlyoutDragger,Blockly.WorkspaceDragger);Blockly.FlyoutDragger.prototype.updateScroll_=function(a,b){this.horizontalLayout_?this.scrollbar_.set(a):this.scrollbar_.set(b)};Blockly.Tooltip={};Blockly.Tooltip.visible=!1;Blockly.Tooltip.blocked_=!1;Blockly.Tooltip.LIMIT=50;Blockly.Tooltip.mouseOutPid_=0;Blockly.Tooltip.showPid_=0;Blockly.Tooltip.lastX_=0;Blockly.Tooltip.lastY_=0;Blockly.Tooltip.element_=null;Blockly.Tooltip.poisonedElement_=null;Blockly.Tooltip.OFFSET_X=0;Blockly.Tooltip.OFFSET_Y=10;Blockly.Tooltip.RADIUS_OK=10;Blockly.Tooltip.HOVER_MS=750;Blockly.Tooltip.MARGINS=5;Blockly.Tooltip.DIV=null; +Blockly.BubbleDragger.prototype.pixelsToWorkspaceUnits_=function(a){a=new Blockly.utils.Coordinate(a.x/this.workspace_.scale,a.y/this.workspace_.scale);this.workspace_.isMutator&&a.scale(1/this.workspace_.options.parentWorkspace.scale);return a};Blockly.BubbleDragger.prototype.moveToDragSurface_=function(){this.draggingBubble_.moveTo(0,0);this.dragSurface_.translateSurface(this.startXY_.x,this.startXY_.y);this.dragSurface_.setBlocksAndShow(this.draggingBubble_.getSvgRoot())};Blockly.WorkspaceDragger=function(a){this.workspace_=a;this.startScrollXY_=new Blockly.utils.Coordinate(a.scrollX,a.scrollY)};Blockly.WorkspaceDragger.prototype.dispose=function(){this.workspace_=null};Blockly.WorkspaceDragger.prototype.startDrag=function(){Blockly.selected&&Blockly.selected.unselect();this.workspace_.setupDragSurface()};Blockly.WorkspaceDragger.prototype.endDrag=function(a){this.drag(a);this.workspace_.resetDragSurface()}; +Blockly.WorkspaceDragger.prototype.drag=function(a){a=Blockly.utils.Coordinate.sum(this.startScrollXY_,a);this.workspace_.scroll(a.x,a.y)};Blockly.FlyoutDragger=function(a){Blockly.FlyoutDragger.superClass_.constructor.call(this,a.getWorkspace());this.scrollbar_=a.scrollbar_;this.horizontalLayout_=a.horizontalLayout_};goog.inherits(Blockly.FlyoutDragger,Blockly.WorkspaceDragger);Blockly.FlyoutDragger.prototype.updateScroll_=function(a,b){this.horizontalLayout_?this.scrollbar_.set(a):this.scrollbar_.set(b)};Blockly.Tooltip={};Blockly.Tooltip.visible=!1;Blockly.Tooltip.blocked_=!1;Blockly.Tooltip.LIMIT=50;Blockly.Tooltip.mouseOutPid_=0;Blockly.Tooltip.showPid_=0;Blockly.Tooltip.lastX_=0;Blockly.Tooltip.lastY_=0;Blockly.Tooltip.element_=null;Blockly.Tooltip.poisonedElement_=null;Blockly.Tooltip.OFFSET_X=0;Blockly.Tooltip.OFFSET_Y=10;Blockly.Tooltip.RADIUS_OK=10;Blockly.Tooltip.HOVER_MS=750;Blockly.Tooltip.MARGINS=5;Blockly.Tooltip.DIV=null; Blockly.Tooltip.createDom=function(){Blockly.Tooltip.DIV||(Blockly.Tooltip.DIV=document.createElement("div"),Blockly.Tooltip.DIV.className="blocklyTooltipDiv",document.body.appendChild(Blockly.Tooltip.DIV))};Blockly.Tooltip.bindMouseEvents=function(a){Blockly.bindEvent_(a,"mouseover",null,Blockly.Tooltip.onMouseOver_);Blockly.bindEvent_(a,"mouseout",null,Blockly.Tooltip.onMouseOut_);a.addEventListener("mousemove",Blockly.Tooltip.onMouseMove_,!1)}; -Blockly.Tooltip.onMouseOver_=function(a){if(!Blockly.Tooltip.blocked_){for(a=a.target;"string"!=typeof a.tooltip&&"function"!=typeof a.tooltip;)a=a.tooltip;Blockly.Tooltip.element_!=a&&(Blockly.Tooltip.hide(),Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.element_=a);clearTimeout(Blockly.Tooltip.mouseOutPid_)}}; +Blockly.Tooltip.onMouseOver_=function(a){if(!Blockly.Tooltip.blocked_){for(a=a.currentTarget;"string"!=typeof a.tooltip&&"function"!=typeof a.tooltip;)a=a.tooltip;Blockly.Tooltip.element_!=a&&(Blockly.Tooltip.hide(),Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.element_=a);clearTimeout(Blockly.Tooltip.mouseOutPid_)}}; Blockly.Tooltip.onMouseOut_=function(a){Blockly.Tooltip.blocked_||(Blockly.Tooltip.mouseOutPid_=setTimeout(function(){Blockly.Tooltip.element_=null;Blockly.Tooltip.poisonedElement_=null;Blockly.Tooltip.hide()},1),clearTimeout(Blockly.Tooltip.showPid_))}; -Blockly.Tooltip.onMouseMove_=function(a){if(Blockly.Tooltip.element_&&Blockly.Tooltip.element_.tooltip&&!Blockly.WidgetDiv.isVisible()&&!Blockly.Tooltip.blocked_)if(Blockly.Tooltip.visible){var b=Blockly.Tooltip.lastX_-a.pageX;a=Blockly.Tooltip.lastY_-a.pageY;Math.sqrt(b*b+a*a)>Blockly.Tooltip.RADIUS_OK&&Blockly.Tooltip.hide()}else Blockly.Tooltip.poisonedElement_!=Blockly.Tooltip.element_&&(clearTimeout(Blockly.Tooltip.showPid_),Blockly.Tooltip.lastX_=a.pageX,Blockly.Tooltip.lastY_=a.pageY,Blockly.Tooltip.showPid_= -setTimeout(Blockly.Tooltip.show_,Blockly.Tooltip.HOVER_MS))};Blockly.Tooltip.hide=function(){Blockly.Tooltip.visible&&(Blockly.Tooltip.visible=!1,Blockly.Tooltip.DIV&&(Blockly.Tooltip.DIV.style.display="none"));Blockly.Tooltip.showPid_&&clearTimeout(Blockly.Tooltip.showPid_)};Blockly.Tooltip.block=function(){Blockly.Tooltip.hide();Blockly.Tooltip.blocked_=!0};Blockly.Tooltip.unblock=function(){Blockly.Tooltip.blocked_=!1}; -Blockly.Tooltip.show_=function(){if(!Blockly.Tooltip.blocked_&&(Blockly.Tooltip.poisonedElement_=Blockly.Tooltip.element_,Blockly.Tooltip.DIV)){Blockly.Tooltip.DIV.innerHTML="";for(var a=Blockly.Tooltip.element_.tooltip;"function"==typeof a;)a=a();a=Blockly.utils.wrap(a,Blockly.Tooltip.LIMIT);a=a.split("\n");for(var b=0;bb.height+window.scrollY&&(d-=Blockly.Tooltip.DIV.offsetHeight+2*Blockly.Tooltip.OFFSET_Y);a?c=Math.max(Blockly.Tooltip.MARGINS-window.scrollX,c):c+Blockly.Tooltip.DIV.offsetWidth> -b.width+window.scrollX-2*Blockly.Tooltip.MARGINS&&(c=b.width-Blockly.Tooltip.DIV.offsetWidth-2*Blockly.Tooltip.MARGINS);Blockly.Tooltip.DIV.style.top=d+"px";Blockly.Tooltip.DIV.style.left=c+"px"}};Blockly.Gesture=function(a,b){this.startWorkspace_=this.targetBlock_=this.startBlock_=this.startField_=this.startBubble_=this.currentDragDeltaXY_=this.mouseDownXY_=null;this.creatorWorkspace_=b;this.isDraggingBubble_=this.isDraggingBlock_=this.isDraggingWorkspace_=this.hasExceededDragRadius_=!1;this.mostRecentEvent_=a;this.flyout_=this.workspaceDragger_=this.blockDragger_=this.bubbleDragger_=this.onUpWrapper_=this.onMoveWrapper_=null;this.isEnding_=this.hasStarted_=this.calledUpdateIsDragging_=!1; +Blockly.Tooltip.onMouseMove_=function(a){if(Blockly.Tooltip.element_&&Blockly.Tooltip.element_.tooltip&&!Blockly.Tooltip.blocked_)if(Blockly.Tooltip.visible){var b=Blockly.Tooltip.lastX_-a.pageX;a=Blockly.Tooltip.lastY_-a.pageY;Math.sqrt(b*b+a*a)>Blockly.Tooltip.RADIUS_OK&&Blockly.Tooltip.hide()}else Blockly.Tooltip.poisonedElement_!=Blockly.Tooltip.element_&&(clearTimeout(Blockly.Tooltip.showPid_),Blockly.Tooltip.lastX_=a.pageX,Blockly.Tooltip.lastY_=a.pageY,Blockly.Tooltip.showPid_=setTimeout(Blockly.Tooltip.show_, +Blockly.Tooltip.HOVER_MS))};Blockly.Tooltip.hide=function(){Blockly.Tooltip.visible&&(Blockly.Tooltip.visible=!1,Blockly.Tooltip.DIV&&(Blockly.Tooltip.DIV.style.display="none"));Blockly.Tooltip.showPid_&&clearTimeout(Blockly.Tooltip.showPid_)};Blockly.Tooltip.block=function(){Blockly.Tooltip.hide();Blockly.Tooltip.blocked_=!0};Blockly.Tooltip.unblock=function(){Blockly.Tooltip.blocked_=!1}; +Blockly.Tooltip.show_=function(){if(!Blockly.Tooltip.blocked_&&(Blockly.Tooltip.poisonedElement_=Blockly.Tooltip.element_,Blockly.Tooltip.DIV)){Blockly.Tooltip.DIV.innerHTML="";for(var a=Blockly.Tooltip.element_.tooltip;"function"==typeof a;)a=a();a=Blockly.utils.string.wrap(a,Blockly.Tooltip.LIMIT);a=a.split("\n");for(var b=0;bc+window.scrollY&&(e-=Blockly.Tooltip.DIV.offsetHeight+2*Blockly.Tooltip.OFFSET_Y);a?d=Math.max(Blockly.Tooltip.MARGINS-window.scrollX, +d):d+Blockly.Tooltip.DIV.offsetWidth>b+window.scrollX-2*Blockly.Tooltip.MARGINS&&(d=b-Blockly.Tooltip.DIV.offsetWidth-2*Blockly.Tooltip.MARGINS);Blockly.Tooltip.DIV.style.top=e+"px";Blockly.Tooltip.DIV.style.left=d+"px"}};Blockly.Gesture=function(a,b){this.startWorkspace_=this.targetBlock_=this.startBlock_=this.startField_=this.startBubble_=this.currentDragDeltaXY_=this.mouseDownXY_=null;this.creatorWorkspace_=b;this.isDraggingBubble_=this.isDraggingBlock_=this.isDraggingWorkspace_=this.hasExceededDragRadius_=!1;this.mostRecentEvent_=a;this.flyout_=this.workspaceDragger_=this.blockDragger_=this.bubbleDragger_=this.onUpWrapper_=this.onMoveWrapper_=null;this.isEnding_=this.hasStarted_=this.calledUpdateIsDragging_=!1; this.healStack_=!Blockly.DRAG_STACK}; Blockly.Gesture.prototype.dispose=function(){Blockly.Touch.clearTouchIdentifier();Blockly.Tooltip.unblock();this.creatorWorkspace_.clearGesture();this.onMoveWrapper_&&Blockly.unbindEvent_(this.onMoveWrapper_);this.onUpWrapper_&&Blockly.unbindEvent_(this.onUpWrapper_);this.flyout_=this.startWorkspace_=this.targetBlock_=this.startBlock_=this.startField_=null;this.blockDragger_&&(this.blockDragger_.dispose(),this.blockDragger_=null);this.workspaceDragger_&&(this.workspaceDragger_.dispose(),this.workspaceDragger_= -null);this.bubbleDragger_&&(this.bubbleDragger_.dispose(),this.bubbleDragger_=null)};Blockly.Gesture.prototype.updateFromEvent_=function(a){var b=new goog.math.Coordinate(a.clientX,a.clientY);this.updateDragDelta_(b)&&(this.updateIsDragging_(),Blockly.longStop_());this.mostRecentEvent_=a}; -Blockly.Gesture.prototype.updateDragDelta_=function(a){this.currentDragDeltaXY_=goog.math.Coordinate.difference(a,this.mouseDownXY_);return this.hasExceededDragRadius_?!1:this.hasExceededDragRadius_=goog.math.Coordinate.magnitude(this.currentDragDeltaXY_)>(this.flyout_?Blockly.FLYOUT_DRAG_RADIUS:Blockly.DRAG_RADIUS)}; +null);this.bubbleDragger_&&(this.bubbleDragger_.dispose(),this.bubbleDragger_=null)};Blockly.Gesture.prototype.updateFromEvent_=function(a){var b=new Blockly.utils.Coordinate(a.clientX,a.clientY);this.updateDragDelta_(b)&&(this.updateIsDragging_(),Blockly.longStop_());this.mostRecentEvent_=a}; +Blockly.Gesture.prototype.updateDragDelta_=function(a){this.currentDragDeltaXY_=Blockly.utils.Coordinate.difference(a,this.mouseDownXY_);return this.hasExceededDragRadius_?!1:this.hasExceededDragRadius_=Blockly.utils.Coordinate.magnitude(this.currentDragDeltaXY_)>(this.flyout_?Blockly.FLYOUT_DRAG_RADIUS:Blockly.DRAG_RADIUS)}; Blockly.Gesture.prototype.updateIsDraggingFromFlyout_=function(){return this.flyout_.isBlockCreatable_(this.targetBlock_)?!this.flyout_.isScrollable()||this.flyout_.isDragTowardWorkspace(this.currentDragDeltaXY_)?(this.startWorkspace_=this.flyout_.targetWorkspace_,this.startWorkspace_.updateScreenCalculationsIfScrolled(),Blockly.Events.getGroup()||Blockly.Events.setGroup(!0),this.startBlock_=null,this.targetBlock_=this.flyout_.createBlock(this.targetBlock_),this.targetBlock_.select(),!0):!1:!1}; Blockly.Gesture.prototype.updateIsDraggingBubble_=function(){if(!this.startBubble_)return!1;this.isDraggingBubble_=!0;this.startDraggingBubble_();return!0};Blockly.Gesture.prototype.updateIsDraggingBlock_=function(){if(!this.targetBlock_)return!1;this.flyout_?this.isDraggingBlock_=this.updateIsDraggingFromFlyout_():this.targetBlock_.isMovable()&&(this.isDraggingBlock_=!0);return this.isDraggingBlock_?(this.startDraggingBlock_(),!0):!1}; Blockly.Gesture.prototype.updateIsDraggingWorkspace_=function(){if(this.flyout_?this.flyout_.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())this.workspaceDragger_=this.flyout_?new Blockly.FlyoutDragger(this.flyout_):new Blockly.WorkspaceDragger(this.startWorkspace_),this.isDraggingWorkspace_=!0,this.workspaceDragger_.startDrag()}; Blockly.Gesture.prototype.updateIsDragging_=function(){if(this.calledUpdateIsDragging_)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging_=!0;this.updateIsDraggingBubble_()||this.updateIsDraggingBlock_()||this.updateIsDraggingWorkspace_()}; Blockly.Gesture.prototype.startDraggingBlock_=function(){this.blockDragger_=new Blockly.BlockDragger(this.targetBlock_,this.startWorkspace_);this.blockDragger_.startBlockDrag(this.currentDragDeltaXY_,this.healStack_);this.blockDragger_.dragBlock(this.mostRecentEvent_,this.currentDragDeltaXY_)}; Blockly.Gesture.prototype.startDraggingBubble_=function(){this.bubbleDragger_=new Blockly.BubbleDragger(this.startBubble_,this.startWorkspace_);this.bubbleDragger_.startBubbleDrag();this.bubbleDragger_.dragBubble(this.mostRecentEvent_,this.currentDragDeltaXY_)}; -Blockly.Gesture.prototype.doStart=function(a){Blockly.utils.isTargetInput(a)?this.cancel():(this.hasStarted_=!0,Blockly.BlockAnimations.disconnectUiStop(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.startWorkspace_.markFocused(),this.mostRecentEvent_=a,Blockly.hideChaff(!!this.flyout_),Blockly.Tooltip.block(),this.targetBlock_&&this.targetBlock_.select(),Blockly.utils.isRightButton(a)?this.handleRightClick(a):("touchstart"!= -a.type.toLowerCase()&&"pointerdown"!=a.type.toLowerCase()||"mouse"==a.pointerType||Blockly.longStart_(a,this),this.mouseDownXY_=new goog.math.Coordinate(a.clientX,a.clientY),this.healStack_=a.altKey||a.ctrlKey||a.metaKey,this.bindMouseEvents(a)))}; +Blockly.Gesture.prototype.doStart=function(a){Blockly.utils.isTargetInput(a)?this.cancel():(this.hasStarted_=!0,Blockly.blockAnimations.disconnectUiStop(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.startWorkspace_.markFocused(),this.mostRecentEvent_=a,Blockly.hideChaff(!!this.flyout_),Blockly.Tooltip.block(),this.targetBlock_&&this.targetBlock_.select(),Blockly.utils.isRightButton(a)?this.handleRightClick(a):("touchstart"!= +a.type.toLowerCase()&&"pointerdown"!=a.type.toLowerCase()||"mouse"==a.pointerType||Blockly.longStart_(a,this),this.mouseDownXY_=new Blockly.utils.Coordinate(a.clientX,a.clientY),this.healStack_=a.altKey||a.ctrlKey||a.metaKey,this.bindMouseEvents(a)))}; Blockly.Gesture.prototype.bindMouseEvents=function(a){this.onMoveWrapper_=Blockly.bindEventWithChecks_(document,"mousemove",null,this.handleMove.bind(this));this.onUpWrapper_=Blockly.bindEventWithChecks_(document,"mouseup",null,this.handleUp.bind(this));a.preventDefault();a.stopPropagation()}; Blockly.Gesture.prototype.handleMove=function(a){this.updateFromEvent_(a);this.isDraggingWorkspace_?this.workspaceDragger_.drag(this.currentDragDeltaXY_):this.isDraggingBlock_?this.blockDragger_.dragBlock(this.mostRecentEvent_,this.currentDragDeltaXY_):this.isDraggingBubble_&&this.bubbleDragger_.dragBubble(this.mostRecentEvent_,this.currentDragDeltaXY_);a.preventDefault();a.stopPropagation()}; Blockly.Gesture.prototype.handleUp=function(a){this.updateFromEvent_(a);Blockly.longStop_();this.isEnding_?console.log("Trying to end a gesture recursively."):(this.isEnding_=!0,this.isDraggingBubble_?this.bubbleDragger_.endBubbleDrag(a,this.currentDragDeltaXY_):this.isDraggingBlock_?this.blockDragger_.endBlockDrag(a,this.currentDragDeltaXY_):this.isDraggingWorkspace_?this.workspaceDragger_.endDrag(this.currentDragDeltaXY_):this.isBubbleClick_()?this.doBubbleClick_():this.isFieldClick_()?this.doFieldClick_(): @@ -1201,141 +1186,140 @@ Blockly.Gesture.prototype.handleRightClick=function(a){this.targetBlock_?(this.b Blockly.Gesture.prototype.handleWsStart=function(a,b){if(this.hasStarted_)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace_(b);this.mostRecentEvent_=a;this.doStart(a)};Blockly.Gesture.prototype.handleFlyoutStart=function(a,b){if(this.hasStarted_)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout_(b);this.handleWsStart(a,b.getWorkspace())}; Blockly.Gesture.prototype.handleBlockStart=function(a,b){if(this.hasStarted_)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");this.setStartBlock(b);this.mostRecentEvent_=a};Blockly.Gesture.prototype.handleBubbleStart=function(a,b){if(this.hasStarted_)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(b);this.mostRecentEvent_=a}; Blockly.Gesture.prototype.doBubbleClick_=function(){this.startBubble_.setFocus&&this.startBubble_.setFocus();this.startBubble_.select&&this.startBubble_.select()};Blockly.Gesture.prototype.doFieldClick_=function(){this.startField_.showEditor_();this.bringBlockToFront_()}; -Blockly.Gesture.prototype.doBlockClick_=function(){this.flyout_&&this.flyout_.autoClose?this.targetBlock_.disabled||(Blockly.Events.getGroup()||Blockly.Events.setGroup(!0),this.flyout_.createBlock(this.targetBlock_).scheduleSnapAndBump()):Blockly.Events.fire(new Blockly.Events.Ui(this.startBlock_,"click",void 0,void 0));this.bringBlockToFront_();Blockly.Events.setGroup(!1)};Blockly.Gesture.prototype.doWorkspaceClick_=function(){Blockly.selected&&Blockly.selected.unselect()}; +Blockly.Gesture.prototype.doBlockClick_=function(){this.flyout_&&this.flyout_.autoClose?this.targetBlock_.isEnabled()&&(Blockly.Events.getGroup()||Blockly.Events.setGroup(!0),this.flyout_.createBlock(this.targetBlock_).scheduleSnapAndBump()):Blockly.Events.fire(new Blockly.Events.Ui(this.startBlock_,"click",void 0,void 0));this.bringBlockToFront_();Blockly.Events.setGroup(!1)};Blockly.Gesture.prototype.doWorkspaceClick_=function(){Blockly.selected&&Blockly.selected.unselect()}; Blockly.Gesture.prototype.bringBlockToFront_=function(){this.targetBlock_&&!this.flyout_&&this.targetBlock_.bringToFront()};Blockly.Gesture.prototype.setStartField=function(a){if(this.hasStarted_)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField_||(this.startField_=a)};Blockly.Gesture.prototype.setStartBubble=function(a){this.startBubble_||(this.startBubble_=a)}; Blockly.Gesture.prototype.setStartBlock=function(a){this.startBlock_||this.startBubble_||(this.startBlock_=a,a.isInFlyout&&a!=a.getRootBlock()?this.setTargetBlock_(a.getRootBlock()):this.setTargetBlock_(a))};Blockly.Gesture.prototype.setTargetBlock_=function(a){a.isShadow()?this.setTargetBlock_(a.getParent()):this.targetBlock_=a};Blockly.Gesture.prototype.setStartWorkspace_=function(a){this.startWorkspace_||(this.startWorkspace_=a)}; -Blockly.Gesture.prototype.setStartFlyout_=function(a){this.flyout_||(this.flyout_=a)};Blockly.Gesture.prototype.isBubbleClick_=function(){return!!this.startBubble_&&!this.hasExceededDragRadius_};Blockly.Gesture.prototype.isBlockClick_=function(){return!!this.startBlock_&&!this.hasExceededDragRadius_&&!this.isFieldClick_()};Blockly.Gesture.prototype.isFieldClick_=function(){return(this.startField_?this.startField_.isCurrentlyEditable():!1)&&!this.hasExceededDragRadius_&&(!this.flyout_||!this.flyout_.autoClose)}; +Blockly.Gesture.prototype.setStartFlyout_=function(a){this.flyout_||(this.flyout_=a)};Blockly.Gesture.prototype.isBubbleClick_=function(){return!!this.startBubble_&&!this.hasExceededDragRadius_};Blockly.Gesture.prototype.isBlockClick_=function(){return!!this.startBlock_&&!this.hasExceededDragRadius_&&!this.isFieldClick_()};Blockly.Gesture.prototype.isFieldClick_=function(){return(this.startField_?this.startField_.isClickable():!1)&&!this.hasExceededDragRadius_&&(!this.flyout_||!this.flyout_.autoClose)}; Blockly.Gesture.prototype.isWorkspaceClick_=function(){return!this.startBlock_&&!this.startBubble_&&!this.startField_&&!this.hasExceededDragRadius_};Blockly.Gesture.prototype.isDragging=function(){return this.isDraggingWorkspace_||this.isDraggingBlock_||this.isDraggingBubble_};Blockly.Gesture.prototype.hasStarted=function(){return this.hasStarted_};Blockly.Gesture.prototype.getInsertionMarkers=function(){return this.blockDragger_?this.blockDragger_.getInsertionMarkers():[]}; Blockly.Gesture.inProgress=function(){for(var a=Blockly.Workspace.getAll(),b=0,c;c=a[b];b++)if(c.currentGesture_)return!0;return!1};Blockly.Grid=function(a,b){this.gridPattern_=a;this.spacing_=b.spacing;this.length_=b.length;this.line2_=(this.line1_=a.firstChild)&&this.line1_.nextSibling;this.snapToGrid_=b.snap};Blockly.Grid.prototype.scale_=1;Blockly.Grid.prototype.dispose=function(){this.gridPattern_=null};Blockly.Grid.prototype.shouldSnap=function(){return this.snapToGrid_};Blockly.Grid.prototype.getSpacing=function(){return this.spacing_};Blockly.Grid.prototype.getPatternId=function(){return this.gridPattern_.id}; Blockly.Grid.prototype.update=function(a){this.scale_=a;var b=this.spacing_*a||100;this.gridPattern_.setAttribute("width",b);this.gridPattern_.setAttribute("height",b);b=Math.floor(this.spacing_/2)+.5;var c=b-this.length_/2,d=b+this.length_/2;b*=a;c*=a;d*=a;this.setLineAttributes_(this.line1_,a,c,d,b,b);this.setLineAttributes_(this.line2_,a,b,b,c,d)}; -Blockly.Grid.prototype.setLineAttributes_=function(a,b,c,d,e,f){a&&(a.setAttribute("stroke-width",b),a.setAttribute("x1",c),a.setAttribute("y1",e),a.setAttribute("x2",d),a.setAttribute("y2",f))};Blockly.Grid.prototype.moveTo=function(a,b){this.gridPattern_.setAttribute("x",a);this.gridPattern_.setAttribute("y",b);(goog.userAgent.IE||goog.userAgent.EDGE)&&this.update(this.scale_)}; -Blockly.Grid.createDom=function(a,b,c){a=Blockly.utils.createSvgElement("pattern",{id:"blocklyGridPattern"+a,patternUnits:"userSpaceOnUse"},c);0 document.");}else a=null;return a};Blockly.ScrollbarPair=function(a){this.workspace_=a;this.hScroll=new Blockly.Scrollbar(a,!0,!0,"blocklyMainWorkspaceScrollbar");this.vScroll=new Blockly.Scrollbar(a,!1,!0,"blocklyMainWorkspaceScrollbar");this.corner_=Blockly.utils.dom.createSvgElement("rect",{height:Blockly.Scrollbar.scrollbarThickness,width:Blockly.Scrollbar.scrollbarThickness,"class":"blocklyScrollbarBackground"},null);Blockly.utils.dom.insertAfter(this.corner_,a.getBubbleCanvas())}; +Blockly.ScrollbarPair.prototype.oldHostMetrics_=null;Blockly.ScrollbarPair.prototype.dispose=function(){Blockly.utils.dom.removeNode(this.corner_);this.oldHostMetrics_=this.workspace_=this.corner_=null;this.hScroll.dispose();this.hScroll=null;this.vScroll.dispose();this.vScroll=null}; Blockly.ScrollbarPair.prototype.resize=function(){var a=this.workspace_.getMetrics();if(a){var b=!1,c=!1;this.oldHostMetrics_&&this.oldHostMetrics_.viewWidth==a.viewWidth&&this.oldHostMetrics_.viewHeight==a.viewHeight&&this.oldHostMetrics_.absoluteTop==a.absoluteTop&&this.oldHostMetrics_.absoluteLeft==a.absoluteLeft?(this.oldHostMetrics_&&this.oldHostMetrics_.contentWidth==a.contentWidth&&this.oldHostMetrics_.viewLeft==a.viewLeft&&this.oldHostMetrics_.contentLeft==a.contentLeft||(b=!0),this.oldHostMetrics_&& this.oldHostMetrics_.contentHeight==a.contentHeight&&this.oldHostMetrics_.viewTop==a.viewTop&&this.oldHostMetrics_.contentTop==a.contentTop||(c=!0)):c=b=!0;b&&this.hScroll.resize(a);c&&this.vScroll.resize(a);this.oldHostMetrics_&&this.oldHostMetrics_.viewWidth==a.viewWidth&&this.oldHostMetrics_.absoluteLeft==a.absoluteLeft||this.corner_.setAttribute("x",this.vScroll.position_.x);this.oldHostMetrics_&&this.oldHostMetrics_.viewHeight==a.viewHeight&&this.oldHostMetrics_.absoluteTop==a.absoluteTop||this.corner_.setAttribute("y", this.hScroll.position_.y);this.oldHostMetrics_=a}};Blockly.ScrollbarPair.prototype.set=function(a,b){var c={},d=a*this.hScroll.ratio_,e=b*this.vScroll.ratio_,f=this.vScroll.scrollViewSize_;c.x=this.getRatio_(d,this.hScroll.scrollViewSize_);c.y=this.getRatio_(e,f);this.workspace_.setMetrics(c);this.hScroll.setHandlePosition(d);this.vScroll.setHandlePosition(e)};Blockly.ScrollbarPair.prototype.getRatio_=function(a,b){var c=a/b;return isNaN(c)?0:c}; -Blockly.Scrollbar=function(a,b,c,d){this.workspace_=a;this.pair_=c||!1;this.horizontal_=b;this.oldHostMetrics_=null;this.createDom_(d);this.position_=new goog.math.Coordinate(0,0);a=Blockly.Scrollbar.scrollbarThickness;b?(this.svgBackground_.setAttribute("height",a),this.outerSvg_.setAttribute("height",a),this.svgHandle_.setAttribute("height",a-5),this.svgHandle_.setAttribute("y",2.5),this.lengthAttribute_="width",this.positionAttribute_="x"):(this.svgBackground_.setAttribute("width",a),this.outerSvg_.setAttribute("width", -a),this.svgHandle_.setAttribute("width",a-5),this.svgHandle_.setAttribute("x",2.5),this.lengthAttribute_="height",this.positionAttribute_="y");this.onMouseDownBarWrapper_=Blockly.bindEventWithChecks_(this.svgBackground_,"mousedown",this,this.onMouseDownBar_);this.onMouseDownHandleWrapper_=Blockly.bindEventWithChecks_(this.svgHandle_,"mousedown",this,this.onMouseDownHandle_)};Blockly.Scrollbar.prototype.origin_=new goog.math.Coordinate(0,0);Blockly.Scrollbar.prototype.startDragMouse_=0; -Blockly.Scrollbar.prototype.scrollViewSize_=0;Blockly.Scrollbar.prototype.handleLength_=0;Blockly.Scrollbar.prototype.handlePosition_=0;Blockly.Scrollbar.prototype.isVisible_=!0;Blockly.Scrollbar.prototype.containerVisible_=!0;Blockly.Scrollbar.scrollbarThickness=15;goog.events.BrowserFeature.TOUCH_ENABLED&&(Blockly.Scrollbar.scrollbarThickness=25); +Blockly.Scrollbar=function(a,b,c,d){this.workspace_=a;this.pair_=c||!1;this.horizontal_=b;this.oldHostMetrics_=null;this.createDom_(d);this.position_=new Blockly.utils.Coordinate(0,0);a=Blockly.Scrollbar.scrollbarThickness;b?(this.svgBackground_.setAttribute("height",a),this.outerSvg_.setAttribute("height",a),this.svgHandle_.setAttribute("height",a-5),this.svgHandle_.setAttribute("y",2.5),this.lengthAttribute_="width",this.positionAttribute_="x"):(this.svgBackground_.setAttribute("width",a),this.outerSvg_.setAttribute("width", +a),this.svgHandle_.setAttribute("width",a-5),this.svgHandle_.setAttribute("x",2.5),this.lengthAttribute_="height",this.positionAttribute_="y");this.onMouseDownBarWrapper_=Blockly.bindEventWithChecks_(this.svgBackground_,"mousedown",this,this.onMouseDownBar_);this.onMouseDownHandleWrapper_=Blockly.bindEventWithChecks_(this.svgHandle_,"mousedown",this,this.onMouseDownHandle_)};Blockly.Scrollbar.prototype.origin_=new Blockly.utils.Coordinate(0,0);Blockly.Scrollbar.prototype.startDragMouse_=0; +Blockly.Scrollbar.prototype.scrollViewSize_=0;Blockly.Scrollbar.prototype.handleLength_=0;Blockly.Scrollbar.prototype.handlePosition_=0;Blockly.Scrollbar.prototype.isVisible_=!0;Blockly.Scrollbar.prototype.containerVisible_=!0;Blockly.Scrollbar.scrollbarThickness=15;Blockly.Touch.TOUCH_ENABLED&&(Blockly.Scrollbar.scrollbarThickness=25); Blockly.Scrollbar.metricsAreEquivalent_=function(a,b){return a&&b&&a.viewWidth==b.viewWidth&&a.viewHeight==b.viewHeight&&a.viewLeft==b.viewLeft&&a.viewTop==b.viewTop&&a.absoluteTop==b.absoluteTop&&a.absoluteLeft==b.absoluteLeft&&a.contentWidth==b.contentWidth&&a.contentHeight==b.contentHeight&&a.contentLeft==b.contentLeft&&a.contentTop==b.contentTop?!0:!1}; -Blockly.Scrollbar.prototype.dispose=function(){this.cleanUp_();Blockly.unbindEvent_(this.onMouseDownBarWrapper_);this.onMouseDownBarWrapper_=null;Blockly.unbindEvent_(this.onMouseDownHandleWrapper_);this.onMouseDownHandleWrapper_=null;Blockly.utils.removeNode(this.outerSvg_);this.workspace_=this.svgHandle_=this.svgBackground_=this.svgGroup_=this.outerSvg_=null};Blockly.Scrollbar.prototype.setHandleLength_=function(a){this.handleLength_=a;this.svgHandle_.setAttribute(this.lengthAttribute_,this.handleLength_)}; +Blockly.Scrollbar.prototype.dispose=function(){this.cleanUp_();Blockly.unbindEvent_(this.onMouseDownBarWrapper_);this.onMouseDownBarWrapper_=null;Blockly.unbindEvent_(this.onMouseDownHandleWrapper_);this.onMouseDownHandleWrapper_=null;Blockly.utils.dom.removeNode(this.outerSvg_);this.workspace_=this.svgHandle_=this.svgBackground_=this.svgGroup_=this.outerSvg_=null};Blockly.Scrollbar.prototype.setHandleLength_=function(a){this.handleLength_=a;this.svgHandle_.setAttribute(this.lengthAttribute_,this.handleLength_)}; Blockly.Scrollbar.prototype.setHandlePosition=function(a){this.handlePosition_=a;this.svgHandle_.setAttribute(this.positionAttribute_,this.handlePosition_)};Blockly.Scrollbar.prototype.setScrollViewSize_=function(a){this.scrollViewSize_=a;this.outerSvg_.setAttribute(this.lengthAttribute_,this.scrollViewSize_);this.svgBackground_.setAttribute(this.lengthAttribute_,this.scrollViewSize_)};Blockly.ScrollbarPair.prototype.setContainerVisible=function(a){this.hScroll.setContainerVisible(a);this.vScroll.setContainerVisible(a)}; -Blockly.Scrollbar.prototype.setPosition_=function(a,b){this.position_.x=a;this.position_.y=b;Blockly.utils.setCssTransform(this.outerSvg_,"translate("+(this.position_.x+this.origin_.x)+"px,"+(this.position_.y+this.origin_.y)+"px)")};Blockly.Scrollbar.prototype.resize=function(a){if(!a&&(a=this.workspace_.getMetrics(),!a))return;Blockly.Scrollbar.metricsAreEquivalent_(a,this.oldHostMetrics_)||(this.oldHostMetrics_=a,this.horizontal_?this.resizeHorizontal_(a):this.resizeVertical_(a),this.onScroll_())}; +Blockly.Scrollbar.prototype.setPosition_=function(a,b){this.position_.x=a;this.position_.y=b;Blockly.utils.dom.setCssTransform(this.outerSvg_,"translate("+(this.position_.x+this.origin_.x)+"px,"+(this.position_.y+this.origin_.y)+"px)")};Blockly.Scrollbar.prototype.resize=function(a){if(!a&&(a=this.workspace_.getMetrics(),!a))return;Blockly.Scrollbar.metricsAreEquivalent_(a,this.oldHostMetrics_)||(this.oldHostMetrics_=a,this.horizontal_?this.resizeHorizontal_(a):this.resizeVertical_(a),this.onScroll_())}; Blockly.Scrollbar.prototype.resizeHorizontal_=function(a){this.resizeViewHorizontal(a)};Blockly.Scrollbar.prototype.resizeViewHorizontal=function(a){var b=a.viewWidth-1;this.pair_&&(b-=Blockly.Scrollbar.scrollbarThickness);this.setScrollViewSize_(Math.max(0,b));b=a.absoluteLeft+.5;this.pair_&&this.workspace_.RTL&&(b+=Blockly.Scrollbar.scrollbarThickness);this.setPosition_(b,a.absoluteTop+a.viewHeight-Blockly.Scrollbar.scrollbarThickness-.5);this.resizeContentHorizontal(a)}; Blockly.Scrollbar.prototype.resizeContentHorizontal=function(a){this.pair_||this.setVisible(this.scrollViewSize_=c+this.handleLength_&&(d+= e);this.setHandlePosition(this.constrainHandle_(d));this.onScroll_();a.stopPropagation();a.preventDefault()}}; Blockly.Scrollbar.prototype.onMouseDownHandle_=function(a){this.workspace_.markFocused();this.cleanUp_();Blockly.utils.isRightButton(a)?a.stopPropagation():(this.startDragHandle=this.handlePosition_,this.workspace_.setupDragSurface(),this.startDragMouse_=this.horizontal_?a.clientX:a.clientY,Blockly.Scrollbar.onMouseUpWrapper_=Blockly.bindEventWithChecks_(document,"mouseup",this,this.onMouseUpHandle_),Blockly.Scrollbar.onMouseMoveWrapper_=Blockly.bindEventWithChecks_(document,"mousemove",this,this.onMouseMoveHandle_), a.stopPropagation(),a.preventDefault())};Blockly.Scrollbar.prototype.onMouseMoveHandle_=function(a){this.setHandlePosition(this.constrainHandle_(this.startDragHandle+((this.horizontal_?a.clientX:a.clientY)-this.startDragMouse_)));this.onScroll_()};Blockly.Scrollbar.prototype.onMouseUpHandle_=function(){this.workspace_.resetDragSurface();Blockly.Touch.clearTouchIdentifier();this.cleanUp_()}; Blockly.Scrollbar.prototype.cleanUp_=function(){Blockly.hideChaff(!0);Blockly.Scrollbar.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseUpWrapper_),Blockly.Scrollbar.onMouseUpWrapper_=null);Blockly.Scrollbar.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseMoveWrapper_),Blockly.Scrollbar.onMouseMoveWrapper_=null)}; Blockly.Scrollbar.prototype.constrainHandle_=function(a){return a=0>=a||isNaN(a)||this.scrollViewSize_this.previousScale_){var c=b-this.previousScale_;c=0Object.keys(this.cachedPoints_).length&&(this.cachedPoints_={},this.previousScale_=0)}; -Blockly.TouchGesture.prototype.getTouchPoint=function(a){return this.startWorkspace_?new goog.math.Coordinate(a.pageX?a.pageX:a.changedTouches[0].pageX,a.pageY?a.pageY:a.changedTouches[0].pageY):null};Blockly.Trashcan=function(a){this.workspace_=a;this.hasBlocks_=!1;this.contents_=[];0>=this.workspace_.options.maxTrashcanContents||(a={scrollbars:!0,disabledPatternId:this.workspace_.options.disabledPatternId,parentWorkspace:this.workspace_,RTL:this.workspace_.RTL,oneBasedIndex:this.workspace_.options.oneBasedIndex},this.workspace_.horizontalLayout?(a.toolboxPosition=this.workspace_.toolboxPosition==Blockly.TOOLBOX_AT_TOP?Blockly.TOOLBOX_AT_BOTTOM:Blockly.TOOLBOX_AT_TOP,this.flyout_=new Blockly.HorizontalFlyout(a)): +Blockly.TouchGesture.prototype.dispose=function(){Blockly.TouchGesture.superClass_.dispose.call(this);this.onStartWrapper_&&Blockly.unbindEvent_(this.onStartWrapper_)};Blockly.TouchGesture.prototype.handleTouchStart=function(a){var b=Blockly.Touch.getTouchIdentifierFromEvent(a);this.cachedPoints_[b]=this.getTouchPoint(a);b=Object.keys(this.cachedPoints_);2==b.length&&(this.startDistance_=Blockly.utils.Coordinate.distance(this.cachedPoints_[b[0]],this.cachedPoints_[b[1]]),this.isMultiTouch_=!0,a.preventDefault())}; +Blockly.TouchGesture.prototype.handleTouchMove=function(a){var b=Blockly.Touch.getTouchIdentifierFromEvent(a);this.cachedPoints_[b]=this.getTouchPoint(a);b=Object.keys(this.cachedPoints_);if(2==b.length){b=this.touchScale_=Blockly.utils.Coordinate.distance(this.cachedPoints_[b[0]],this.cachedPoints_[b[1]])/this.startDistance_;if(0this.previousScale_){var c=b-this.previousScale_;c=0Object.keys(this.cachedPoints_).length&&(this.cachedPoints_={},this.previousScale_=0)}; +Blockly.TouchGesture.prototype.getTouchPoint=function(a){return this.startWorkspace_?new Blockly.utils.Coordinate(a.pageX?a.pageX:a.changedTouches[0].pageX,a.pageY?a.pageY:a.changedTouches[0].pageY):null};Blockly.Trashcan=function(a){this.workspace_=a;this.hasBlocks_=!1;this.contents_=[];0>=this.workspace_.options.maxTrashcanContents||(a={scrollbars:!0,disabledPatternId:this.workspace_.options.disabledPatternId,parentWorkspace:this.workspace_,RTL:this.workspace_.RTL,oneBasedIndex:this.workspace_.options.oneBasedIndex},this.workspace_.horizontalLayout?(a.toolboxPosition=this.workspace_.toolboxPosition==Blockly.TOOLBOX_AT_TOP?Blockly.TOOLBOX_AT_BOTTOM:Blockly.TOOLBOX_AT_TOP,this.flyout_=new Blockly.HorizontalFlyout(a)): (a.toolboxPosition=this.workspace_.toolboxPosition==Blockly.TOOLBOX_AT_RIGHT?Blockly.TOOLBOX_AT_LEFT:Blockly.TOOLBOX_AT_RIGHT,this.flyout_=new Blockly.VerticalFlyout(a)),this.workspace_.addChangeListener(this.onDelete_()))};Blockly.Trashcan.prototype.WIDTH_=47;Blockly.Trashcan.prototype.BODY_HEIGHT_=44;Blockly.Trashcan.prototype.LID_HEIGHT_=16;Blockly.Trashcan.prototype.MARGIN_BOTTOM_=20;Blockly.Trashcan.prototype.MARGIN_SIDE_=20;Blockly.Trashcan.prototype.MARGIN_HOTSPOT_=10; Blockly.Trashcan.prototype.SPRITE_LEFT_=0;Blockly.Trashcan.prototype.SPRITE_TOP_=32;Blockly.Trashcan.prototype.HAS_BLOCKS_LID_ANGLE=.1;Blockly.Trashcan.prototype.isOpen=!1;Blockly.Trashcan.prototype.minOpenness_=0;Blockly.Trashcan.prototype.svgGroup_=null;Blockly.Trashcan.prototype.svgLid_=null;Blockly.Trashcan.prototype.lidTask_=0;Blockly.Trashcan.prototype.lidOpen_=0;Blockly.Trashcan.prototype.left_=0;Blockly.Trashcan.prototype.top_=0; -Blockly.Trashcan.prototype.createDom=function(){this.svgGroup_=Blockly.utils.createSvgElement("g",{"class":"blocklyTrash"},null);var a=String(Math.random()).substring(2);var b=Blockly.utils.createSvgElement("clipPath",{id:"blocklyTrashBodyClipPath"+a},this.svgGroup_);Blockly.utils.createSvgElement("rect",{width:this.WIDTH_,height:this.BODY_HEIGHT_,y:this.LID_HEIGHT_},b);var c=Blockly.utils.createSvgElement("image",{width:Blockly.SPRITE.width,x:-this.SPRITE_LEFT_,height:Blockly.SPRITE.height,y:-this.SPRITE_TOP_, -"clip-path":"url(#blocklyTrashBodyClipPath"+a+")"},this.svgGroup_);c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.workspace_.options.pathToMedia+Blockly.SPRITE.url);b=Blockly.utils.createSvgElement("clipPath",{id:"blocklyTrashLidClipPath"+a},this.svgGroup_);Blockly.utils.createSvgElement("rect",{width:this.WIDTH_,height:this.LID_HEIGHT_},b);this.svgLid_=Blockly.utils.createSvgElement("image",{width:Blockly.SPRITE.width,x:-this.SPRITE_LEFT_,height:Blockly.SPRITE.height,y:-this.SPRITE_TOP_, -"clip-path":"url(#blocklyTrashLidClipPath"+a+")"},this.svgGroup_);this.svgLid_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.workspace_.options.pathToMedia+Blockly.SPRITE.url);Blockly.bindEventWithChecks_(this.svgGroup_,"mouseup",this,this.click);Blockly.bindEvent_(c,"mouseover",this,this.mouseOver_);Blockly.bindEvent_(c,"mouseout",this,this.mouseOut_);this.animateLid_();return this.svgGroup_}; -Blockly.Trashcan.prototype.init=function(a){0this.minOpenness_&&1>this.lidOpen_&&(this.lidTask_=setTimeout(this.animateLid_.bind(this),20))}; -Blockly.Trashcan.prototype.setLidAngle_=function(a){var b=this.workspace_.toolboxPosition==Blockly.TOOLBOX_AT_RIGHT||this.workspace_.horizontalLayout&&this.workspace_.RTL;this.svgLid_.setAttribute("transform","rotate("+(b?-a:a)+","+(b?4:this.WIDTH_-4)+","+(this.LID_HEIGHT_-2)+")")};Blockly.Trashcan.prototype.close=function(){this.setOpen_(!1)};Blockly.Trashcan.prototype.click=function(){if(this.hasBlocks_){for(var a=[],b=0,c;c=this.contents_[b];b++)a[b]=Blockly.Xml.textToDom(c).firstChild;this.flyout_.show(a)}}; +Blockly.Trashcan.prototype.setLidAngle_=function(a){var b=this.workspace_.toolboxPosition==Blockly.TOOLBOX_AT_RIGHT||this.workspace_.horizontalLayout&&this.workspace_.RTL;this.svgLid_.setAttribute("transform","rotate("+(b?-a:a)+","+(b?4:this.WIDTH_-4)+","+(this.LID_HEIGHT_-2)+")")};Blockly.Trashcan.prototype.close=function(){this.setOpen_(!1)};Blockly.Trashcan.prototype.click=function(){if(this.hasBlocks_){for(var a=[],b=0,c;c=this.contents_[b];b++)a[b]=Blockly.Xml.textToDom(c);this.flyout_.show(a)}}; Blockly.Trashcan.prototype.mouseOver_=function(){this.hasBlocks_&&this.setOpen_(!0)};Blockly.Trashcan.prototype.mouseOut_=function(){this.setOpen_(!1)}; -Blockly.Trashcan.prototype.onDelete_=function(){var a=this;return function(b){0>=a.workspace_.options.maxTrashcanContents||b.type!=Blockly.Events.BLOCK_DELETE||(b=a.cleanBlockXML_(b.oldXml),-1==a.contents_.indexOf(b)&&(a.contents_.unshift(b),a.contents_.length>a.workspace_.options.maxTrashcanContents&&a.contents_.splice(a.workspace_.options.maxTrashcanContents,a.contents_.length-a.workspace_.options.maxTrashcanContents),a.hasBlocks_=!0,a.minOpenness_=a.HAS_BLOCKS_LID_ANGLE,a.setLidAngle_(45*a.minOpenness_)))}}; -Blockly.Trashcan.prototype.cleanBlockXML_=function(a){for(var b=a=a.cloneNode(!0);b;){b.removeAttribute&&(b.removeAttribute("x"),b.removeAttribute("y"),b.removeAttribute("id"));var c=b.firstChild||b.nextSibling;if(!c)for(c=b.parentNode;c;){if(c.nextSibling){c=c.nextSibling;break}c=c.parentNode}b=c}return""+Blockly.Xml.domToText(a)+""};Blockly.VariableModel=function(a,b,c,d){this.workspace=a;this.name=b;this.type=c||"";this.id_=d||Blockly.utils.genUid();Blockly.Events.fire(new Blockly.Events.VarCreate(this))};Blockly.VariableModel.prototype.getId=function(){return this.id_};Blockly.VariableModel.compareByName=function(a,b){var c=a.name.toLowerCase(),d=b.name.toLowerCase();return c=a.workspace_.options.maxTrashcanContents||b.type!=Blockly.Events.BLOCK_DELETE||"shadow"==b.oldXml.tagName.toLowerCase()||(b=a.cleanBlockXML_(b.oldXml),-1==a.contents_.indexOf(b)&&(a.contents_.unshift(b),a.contents_.length>a.workspace_.options.maxTrashcanContents&&a.contents_.splice(a.workspace_.options.maxTrashcanContents,a.contents_.length-a.workspace_.options.maxTrashcanContents),a.hasBlocks_=!0,a.minOpenness_=a.HAS_BLOCKS_LID_ANGLE, +a.setLidAngle_(45*a.minOpenness_)))}};Blockly.Trashcan.prototype.cleanBlockXML_=function(a){for(var b=a=a.cloneNode(!0);b;){b.removeAttribute&&(b.removeAttribute("x"),b.removeAttribute("y"),b.removeAttribute("id"));var c=b.firstChild||b.nextSibling;if(!c)for(c=b.parentNode;c;){if(c.nextSibling){c=c.nextSibling;break}c=c.parentNode}b=c}return Blockly.Xml.domToText(a)};Blockly.VariableModel=function(a,b,c,d){this.workspace=a;this.name=b;this.type=c||"";this.id_=d||Blockly.utils.genUid();Blockly.Events.fire(new Blockly.Events.VarCreate(this))};Blockly.VariableModel.prototype.getId=function(){return this.id_};Blockly.VariableModel.compareByName=function(a,b){var c=a.name.toLowerCase(),d=b.name.toLowerCase();return c'+c+"").firstChild;b.push(d)}Blockly.Blocks.math_change&&(d=Blockly.Blocks.variables_get?20:8,d=Blockly.Xml.textToDom(''+c+'1').firstChild, -b.push(d));if(Blockly.Blocks.variables_get)for(a.sort(Blockly.VariableModel.compareByName),c=0;d=a[c];c++)d=''+Blockly.Variables.generateVariableFieldXmlString(d)+"",d=Blockly.Xml.textToDom(d).firstChild,b.push(d)}return b}; +Blockly.Variables.flyoutCategoryBlocks=function(a){a=a.getVariablesOfType("");var b=[];if(01'),d.appendChild(c),b.push(d));if(Blockly.Blocks.variables_get){a.sort(Blockly.VariableModel.compareByName);c=0;for(var e;e=a[c];c++)d=Blockly.utils.xml.createElement("block"),d.setAttribute("type","variables_get"),d.setAttribute("gap",8),d.appendChild(Blockly.Variables.generateVariableFieldDom(e)),b.push(d)}}return b}; Blockly.Variables.generateUniqueName=function(a){a=a.getAllVariables();var b="";if(a.length)for(var c=1,d=0,e="ijkmnopqrstuvwxyzabcdefgh".charAt(d);!b;){for(var f=!1,g=0;g'+goog.string.htmlEscape(a.name)+""}; -Blockly.Variables.generateVariableFieldDom=function(a){a=Blockly.Variables.generateVariableFieldXmlString(a);return Blockly.Xml.textToDom(""+a+"").firstChild};Blockly.Variables.getOrCreateVariablePackage=function(a,b,c,d){var e=Blockly.Variables.getVariable(a,b,c,d);e||(e=Blockly.Variables.createVariable_(a,b,c,d));return e}; -Blockly.Variables.getVariable=function(a,b,c,d){var e=a.getPotentialVariableMap();if(b){var f=a.getVariableById(b);!f&&e&&(f=e.getVariableById(b));if(f)return f}if(c){if(void 0==d)throw Error("Tried to look up a variable by name without a type");f=a.getVariable(c,d);!f&&e&&(f=e.getVariable(c,d))}return f}; +Blockly.Variables.promptName=function(a,b,c){Blockly.prompt(a,b,function(a){a&&(a=a.replace(/[\s\xa0]+/g," ").trim(),a==Blockly.Msg.RENAME_VARIABLE||a==Blockly.Msg.NEW_VARIABLE)&&(a=null);c(a)})};Blockly.Variables.nameUsedWithOtherType_=function(a,b,c){c=c.getVariableMap().getAllVariables();a=a.toLowerCase();for(var d=0,e;e=c[d];d++)if(e.name.toLowerCase()==a&&e.type!=b)return e;return null}; +Blockly.Variables.nameUsedWithAnyType_=function(a,b){var c=b.getVariableMap().getAllVariables();a=a.toLowerCase();for(var d=0,e;e=c[d];d++)if(e.name.toLowerCase()==a)return e;return null};Blockly.Variables.generateVariableFieldDom=function(a){var b=Blockly.utils.xml.createElement("field");b.setAttribute("name","VAR");b.setAttribute("id",a.getId());b.setAttribute("variabletype",a.type);a=Blockly.utils.xml.createTextNode(a.name);b.appendChild(a);return b}; +Blockly.Variables.getOrCreateVariablePackage=function(a,b,c,d){var e=Blockly.Variables.getVariable(a,b,c,d);e||(e=Blockly.Variables.createVariable_(a,b,c,d));return e};Blockly.Variables.getVariable=function(a,b,c,d){var e=a.getPotentialVariableMap();if(b){var f=a.getVariableById(b);!f&&e&&(f=e.getVariableById(b));if(f)return f}if(c){if(void 0==d)throw Error("Tried to look up a variable by name without a type");f=a.getVariable(c,d);!f&&e&&(f=e.getVariable(c,d))}return f}; Blockly.Variables.createVariable_=function(a,b,c,d){var e=a.getPotentialVariableMap();c||(c=Blockly.Variables.generateUniqueName(a.isFlyout?a.targetWorkspace:a));return e?e.createVariable(c,d,b):a.createVariable(c,d,b)};Blockly.Variables.getAddedVariables=function(a,b){var c=a.getAllVariables(),d=[];if(b.length!=c.length)for(var e=0;e";c=Blockly.Xml.textToDom(c).firstChild;b.push(c)}if(Blockly.Blocks.variables_get_dynamic){a.sort(Blockly.VariableModel.compareByName);for(var d=0;c=a[d];d++)c=''+Blockly.Variables.generateVariableFieldXmlString(c)+ -"",c=Blockly.Xml.textToDom(c).firstChild,b.push(c)}}return b};Blockly.WorkspaceAudio=function(a){this.parentWorkspace_=a;this.SOUNDS_=Object.create(null)};Blockly.WorkspaceAudio.prototype.lastSound_=null;Blockly.WorkspaceAudio.prototype.dispose=function(){this.SOUNDS_=this.parentWorkspace_=null};Blockly.WorkspaceAudio.prototype.load=function(a,b){if(a.length){try{var c=new window.Audio}catch(h){return}for(var d,e=0;e=this.remainingCapacity()||(this.currentGesture_&&this.currentGesture_.cancel(),"comment"==a.tagName.toLowerCase()?this.pasteWorkspaceComment_(a):this.pasteBlock_(a))}; -Blockly.WorkspaceSvg.prototype.pasteBlock_=function(a){Blockly.Events.disable();try{var b=Blockly.Xml.domToBlock(a,this),c=parseInt(a.getAttribute("x"),10),d=parseInt(a.getAttribute("y"),10);if(!isNaN(c)&&!isNaN(d)){this.RTL&&(c=-c);do{a=!1;for(var e=this.getAllBlocks(!1),f=0,g;g=e[f];f++){var h=g.getRelativeToSurfaceXY();if(1>=Math.abs(c-h.x)&&1>=Math.abs(d-h.y)){a=!0;break}}if(!a){var k=b.getConnections_(!1);f=0;for(var l;l=k[f];f++)if(l.closest(Blockly.SNAP_RADIUS,new goog.math.Coordinate(c,d)).connection){a= -!0;break}}a&&(c=this.RTL?c-Blockly.SNAP_RADIUS:c+Blockly.SNAP_RADIUS,d+=2*Blockly.SNAP_RADIUS)}while(a);b.moveBy(c,d)}}finally{Blockly.Events.enable()}Blockly.Events.isEnabled()&&!b.isShadow()&&Blockly.Events.fire(new Blockly.Events.BlockCreate(b));b.select()}; +Blockly.WorkspaceSvg.prototype.pasteBlock_=function(a){Blockly.Events.disable();try{var b=Blockly.Xml.domToBlock(a,this),c=parseInt(a.getAttribute("x"),10),d=parseInt(a.getAttribute("y"),10);if(!isNaN(c)&&!isNaN(d)){this.RTL&&(c=-c);do{a=!1;for(var e=this.getAllBlocks(!1),f=0,g;g=e[f];f++){var h=g.getRelativeToSurfaceXY();if(1>=Math.abs(c-h.x)&&1>=Math.abs(d-h.y)){a=!0;break}}if(!a){var k=b.getConnections_(!1);f=0;for(var l;l=k[f];f++)if(l.closest(Blockly.SNAP_RADIUS,new Blockly.utils.Coordinate(c, +d)).connection){a=!0;break}}a&&(c=this.RTL?c-Blockly.SNAP_RADIUS:c+Blockly.SNAP_RADIUS,d+=2*Blockly.SNAP_RADIUS)}while(a);b.moveBy(c,d)}}finally{Blockly.Events.enable()}Blockly.Events.isEnabled()&&!b.isShadow()&&Blockly.Events.fire(new Blockly.Events.BlockCreate(b));b.select()}; Blockly.WorkspaceSvg.prototype.pasteWorkspaceComment_=function(a){Blockly.Events.disable();try{var b=Blockly.WorkspaceCommentSvg.fromXml(a,this),c=parseInt(a.getAttribute("x"),10),d=parseInt(a.getAttribute("y"),10);isNaN(c)||isNaN(d)||(this.RTL&&(c=-c),b.moveBy(c+50,d+50))}finally{Blockly.Events.enable()}Blockly.Events.isEnabled();b.select()}; Blockly.WorkspaceSvg.prototype.refreshToolboxSelection=function(){var a=this.isFlyout?this.targetWorkspace:this;a&&!a.currentGesture_&&a.toolbox_&&a.toolbox_.flyout_&&a.toolbox_.refreshSelection()};Blockly.WorkspaceSvg.prototype.renameVariableById=function(a,b){Blockly.WorkspaceSvg.superClass_.renameVariableById.call(this,a,b);this.refreshToolboxSelection()};Blockly.WorkspaceSvg.prototype.deleteVariableById=function(a){Blockly.WorkspaceSvg.superClass_.deleteVariableById.call(this,a);this.refreshToolboxSelection()}; Blockly.WorkspaceSvg.prototype.createVariable=function(a,b,c){a=Blockly.WorkspaceSvg.superClass_.createVariable.call(this,a,b,c);this.refreshToolboxSelection();return a};Blockly.WorkspaceSvg.prototype.recordDeleteAreas=function(){this.deleteAreaTrash_=this.trashcan&&this.svgGroup_.parentNode?this.trashcan.getClientRect():null;this.deleteAreaToolbox_=this.flyout_?this.flyout_.getClientRect():this.toolbox_?this.toolbox_.getClientRect():null}; -Blockly.WorkspaceSvg.prototype.isDeleteArea=function(a){a=new goog.math.Coordinate(a.clientX,a.clientY);return this.deleteAreaTrash_&&this.deleteAreaTrash_.contains(a)?Blockly.DELETE_AREA_TRASH:this.deleteAreaToolbox_&&this.deleteAreaToolbox_.contains(a)?Blockly.DELETE_AREA_TOOLBOX:Blockly.DELETE_AREA_NONE};Blockly.WorkspaceSvg.prototype.onMouseDown_=function(a){var b=this.getGesture(a);b&&b.handleWsStart(a,this)}; -Blockly.WorkspaceSvg.prototype.startDrag=function(a,b){var c=Blockly.utils.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM());c.x/=this.scale;c.y/=this.scale;this.dragDeltaXY_=goog.math.Coordinate.difference(b,c)};Blockly.WorkspaceSvg.prototype.moveDrag=function(a){a=Blockly.utils.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM());a.x/=this.scale;a.y/=this.scale;return goog.math.Coordinate.sum(this.dragDeltaXY_,a)}; +Blockly.WorkspaceSvg.prototype.isDeleteArea=function(a){return this.deleteAreaTrash_&&this.deleteAreaTrash_.contains(a.clientX,a.clientY)?Blockly.DELETE_AREA_TRASH:this.deleteAreaToolbox_&&this.deleteAreaToolbox_.contains(a.clientX,a.clientY)?Blockly.DELETE_AREA_TOOLBOX:Blockly.DELETE_AREA_NONE};Blockly.WorkspaceSvg.prototype.onMouseDown_=function(a){var b=this.getGesture(a);b&&b.handleWsStart(a,this)}; +Blockly.WorkspaceSvg.prototype.startDrag=function(a,b){var c=Blockly.utils.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM());c.x/=this.scale;c.y/=this.scale;this.dragDeltaXY_=Blockly.utils.Coordinate.difference(b,c)};Blockly.WorkspaceSvg.prototype.moveDrag=function(a){a=Blockly.utils.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM());a.x/=this.scale;a.y/=this.scale;return Blockly.utils.Coordinate.sum(this.dragDeltaXY_,a)}; Blockly.WorkspaceSvg.prototype.isDragging=function(){return null!=this.currentGesture_&&this.currentGesture_.isDragging()};Blockly.WorkspaceSvg.prototype.isDraggable=function(){return this.options.moveOptions&&this.options.moveOptions.drag}; Blockly.WorkspaceSvg.prototype.isContentBounded=function(){return this.options.moveOptions&&this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.controls||this.options.zoomOptions&&this.options.zoomOptions.wheel}; Blockly.WorkspaceSvg.prototype.isMovable=function(){return this.options.moveOptions&&this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel}; Blockly.WorkspaceSvg.prototype.onMouseWheel_=function(a){if(Blockly.Gesture.inProgress())a.preventDefault(),a.stopPropagation();else{var b=this.options.zoomOptions&&this.options.zoomOptions.wheel,c=this.options.moveOptions&&this.options.moveOptions.wheel;if(b||c){var d=Blockly.utils.getScrollDeltaPixels(a);!b||!a.ctrlKey&&c?(b=this.scrollX-d.x,c=this.scrollY-d.y,a.shiftKey&&!d.x&&(b=this.scrollX-d.y,c=this.scrollY),this.scroll(b,c)):(d=-d.y/50,b=Blockly.utils.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM()), -this.zoom(b.x,b.y,d));a.preventDefault()}}}; -Blockly.WorkspaceSvg.prototype.getBlocksBoundingBox=function(){var a=this.getTopBlocks(!1),b=this.getTopComments(!1);a=a.concat(b);if(!a.length)return{x:0,y:0,width:0,height:0};b=a[0].getBoundingRectangle();for(var c=1;cb.bottomRight.x&&(b.bottomRight.x=d.bottomRight.x);d.topLeft.yb.bottomRight.y&&(b.bottomRight.y=d.bottomRight.y)}return{x:b.topLeft.x, -y:b.topLeft.y,width:b.bottomRight.x-b.topLeft.x,height:b.bottomRight.y-b.topLeft.y}};Blockly.WorkspaceSvg.prototype.cleanUp=function(){this.setResizesEnabled(!1);Blockly.Events.setGroup(!0);for(var a=this.getTopBlocks(!0),b=0,c=0,d;d=a[c];c++)if(d.isMovable()){var e=d.getRelativeToSurfaceXY();d.moveBy(-e.x,b-e.y);d.snapToGrid();b=d.getRelativeToSurfaceXY().y+d.getHeightWidth().height+Blockly.BlockSvg.MIN_BLOCK_Y}Blockly.Events.setGroup(!1);this.setResizesEnabled(!0)}; +this.zoom(b.x,b.y,d));a.preventDefault()}}};Blockly.WorkspaceSvg.prototype.getBlocksBoundingBox=function(){var a=this.getTopBlocks(!1),b=this.getTopComments(!1);a=a.concat(b);if(!a.length)return new Blockly.utils.Rect(0,0,0,0);b=a[0].getBoundingRectangle();for(var c=1;cb.bottom&&(b.bottom=d.bottom);d.leftb.right&&(b.right=d.right)}return b}; +Blockly.WorkspaceSvg.prototype.cleanUp=function(){this.setResizesEnabled(!1);Blockly.Events.setGroup(!0);for(var a=this.getTopBlocks(!0),b=0,c=0,d;d=a[c];c++)if(d.isMovable()){var e=d.getRelativeToSurfaceXY();d.moveBy(-e.x,b-e.y);d.snapToGrid();b=d.getRelativeToSurfaceXY().y+d.getHeightWidth().height+Blockly.BlockSvg.MIN_BLOCK_Y}Blockly.Events.setGroup(!1);this.setResizesEnabled(!0)}; Blockly.WorkspaceSvg.prototype.showContextMenu_=function(a){function b(a){if(a.isDeletable())p=p.concat(a.getDescendants(!1));else{a=a.getChildren(!1);for(var c=0;cp.length?c():Blockly.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace("%1",p.length),function(a){a&& @@ -1366,15 +1349,15 @@ Blockly.WorkspaceSvg.prototype.updateToolbox=function(a){if(a=Blockly.Options.pa this.options.languageTree=a;this.flyout_.show(a.childNodes)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.");};Blockly.WorkspaceSvg.prototype.markFocused=function(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(Blockly.mainWorkspace=this,this.setBrowserFocus())};Blockly.WorkspaceSvg.prototype.setBrowserFocus=function(){document.activeElement&&document.activeElement.blur();try{this.getParentSvg().focus()}catch(a){try{this.getParentSvg().parentNode.setActive()}catch(b){this.getParentSvg().parentNode.focus()}}}; Blockly.WorkspaceSvg.prototype.zoom=function(a,b,c){c=Math.pow(this.options.zoomOptions.scaleSpeed,c);var d=this.scale*c;if(this.scale!=d){d>this.options.zoomOptions.maxScale?c=this.options.zoomOptions.maxScale/this.scale:dthis.options.zoomOptions.maxScale?a=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&aa||Math.abs(this.workspaceHeight_-b)>a)this.workspaceWidth_=c,this.workspaceHeight_=b,this.bubble_.setBubbleSize(c+a,b+a),this.svgDialog_.setAttribute("width",this.workspaceWidth_), this.svgDialog_.setAttribute("height",this.workspaceHeight_);this.block_.RTL&&(a="translate("+this.workspaceWidth_+",0)",this.workspace_.getCanvas().setAttribute("transform",a));this.workspace_.resize()}; Blockly.Mutator.prototype.setVisible=function(a){if(a!=this.isVisible())if(Blockly.Events.fire(new Blockly.Events.Ui(this.block_,"mutatorOpen",!a,a)),a){this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svgPath_,this.iconXY_,null,null);this.bubble_.setSvgId(this.block_.id);if(a=this.workspace_.options.languageTree)this.workspace_.flyout_.init(this.workspace_),this.workspace_.flyout_.show(a.childNodes);this.rootBlock_=this.block_.decompose(this.workspace_);a=this.rootBlock_.getDescendants(!1); @@ -1398,8 +1381,8 @@ Blockly.Mutator.prototype.workspaceChanged_=function(a){if(a.type!=Blockly.Event c.compose(this.rootBlock_);c.rendered=b;c.initSvg();b=(b=c.mutationToDom())&&Blockly.Xml.domToText(b);if(a!=b){Blockly.Events.fire(new Blockly.Events.BlockChange(c,"mutation",null,a,b));var f=Blockly.Events.getGroup();setTimeout(function(){Blockly.Events.setGroup(f);c.bumpNeighbours_();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY)}c.rendered&&c.render();this.workspace_.isDragging()||this.resizeBubble_();Blockly.Events.setGroup(!1)}}}; Blockly.Mutator.prototype.getFlyoutMetrics_=function(){return{viewHeight:this.workspaceHeight_,viewWidth:this.workspaceWidth_-this.workspace_.getFlyout().getWidth(),absoluteTop:0,absoluteLeft:this.workspace_.RTL?0:this.workspace_.getFlyout().getWidth()}};Blockly.Mutator.prototype.dispose=function(){this.block_.mutator=null;Blockly.Icon.prototype.dispose.call(this)}; Blockly.Mutator.prototype.updateBlockStyle=function(){var a=this.workspace_;if(a&&a.getAllBlocks()){for(var b=a.getAllBlocks(),c=0;cthis.maxDisplayLength&&(a=a.substring(0,this.maxDisplayLength-2)+"\u2026");a=a.replace(/\s/g,Blockly.Field.NBSP);this.sourceBlock_.RTL&&(a+="\u200f");return a};Blockly.Field.prototype.getText=function(){return this.text_};Blockly.Field.prototype.setText=function(a){null!==a&&(a=String(a),a!==this.text_&&(this.text_=a,this.forceRerender()))}; -Blockly.Field.prototype.forceRerender=function(){this.size_.width=0;this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_())};Blockly.Field.prototype.getValue=function(){return this.getText()};Blockly.Field.prototype.setValue=function(a){if(null!==a){var b=this.getValue();b!=a&&(this.sourceBlock_&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this.sourceBlock_,"field",this.name,b,a)),this.setText(a))}}; -Blockly.Field.prototype.onMouseDown_=function(a){this.sourceBlock_&&this.sourceBlock_.workspace&&(a=this.sourceBlock_.workspace.getGesture(a))&&a.setStartField(this)};Blockly.Field.prototype.setTooltip=function(a){};Blockly.Field.prototype.getClickTarget_=function(){return this.clickTarget_||this.getSvgRoot()};Blockly.Field.prototype.getAbsoluteXY_=function(){return goog.style.getPageOffset(this.borderRect_)};Blockly.Field.prototype.referencesVariables=function(){return!1};Blockly.FieldLabel=function(a,b){this.size_=new goog.math.Size(0,17.5);this.class_=b;this.setValue(a);this.tooltip_=""};goog.inherits(Blockly.FieldLabel,Blockly.Field);Blockly.FieldLabel.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.text);return new Blockly.FieldLabel(b,a["class"])};Blockly.FieldLabel.prototype.EDITABLE=!1; -Blockly.FieldLabel.prototype.init=function(){this.textElement_||(this.textElement_=Blockly.utils.createSvgElement("text",{"class":"blocklyText",y:this.size_.height-5},null),this.class_&&Blockly.utils.addClass(this.textElement_,this.class_),this.visible_||(this.textElement_.style.display="none"),this.sourceBlock_.getSvgRoot().appendChild(this.textElement_),this.textElement_.tooltip=this.tooltip_?this.tooltip_:this.sourceBlock_,Blockly.Tooltip.bindMouseEvents(this.textElement_),this.render_())}; -Blockly.FieldLabel.prototype.dispose=function(){this.textElement_&&(Blockly.utils.removeNode(this.textElement_),this.textElement_=null)};Blockly.FieldLabel.prototype.getSvgRoot=function(){return this.textElement_};Blockly.FieldLabel.prototype.setTooltip=function(a){this.tooltip_=a;this.textElement_&&(this.textElement_.tooltip=a)};Blockly.Field.register("field_label",Blockly.FieldLabel);Blockly.Input=function(a,b,c,d){if(a!=Blockly.DUMMY_INPUT&&!b)throw Error("Value inputs and statement inputs must have non-empty name.");this.type=a;this.name=b;this.sourceBlock_=c;this.connection=d;this.fieldRow=[]};Blockly.Input.prototype.align=Blockly.ALIGN_LEFT;Blockly.Input.prototype.visible_=!0;Blockly.Input.prototype.appendField=function(a,b){this.insertFieldAt(this.fieldRow.length,a,b);return this}; +Blockly.Field.prototype.forceRerender=function(){this.isDirty_=!0;this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_())}; +Blockly.Field.prototype.setValue=function(a){if(null!==a){var b=this.doClassValidation_(a);a=this.processValidation_(a,b);if(!(a instanceof Error)){if(b=this.getValidator())if(b=b.call(this,a),a=this.processValidation_(a,b),a instanceof Error)return;b=this.getValue();b!==a&&(this.sourceBlock_&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this.sourceBlock_,"field",this.name,b,a)),this.doValueUpdate_(a),this.isDirty_&&this.forceRerender())}}}; +Blockly.Field.prototype.processValidation_=function(a,b){if(null===b)return this.doValueInvalid_(a),this.isDirty_&&this.forceRerender(),Error();void 0!==b&&(a=b);return a};Blockly.Field.prototype.getValue=function(){return this.value_};Blockly.Field.prototype.doClassValidation_=function(a){return a=this.classValidator(a)};Blockly.Field.prototype.doValueUpdate_=function(a){this.value_=a;this.isDirty_=!0;this.text_=String(a)};Blockly.Field.prototype.doValueInvalid_=function(a){}; +Blockly.Field.prototype.onMouseDown_=function(a){this.sourceBlock_&&this.sourceBlock_.workspace&&(a=this.sourceBlock_.workspace.getGesture(a))&&a.setStartField(this)};Blockly.Field.prototype.setTooltip=function(a){var b=this.getClickTarget_();b?b.tooltip=a||""===a?a:this.sourceBlock_:this.tooltip_=a};Blockly.Field.prototype.getClickTarget_=function(){return this.clickTarget_||this.getSvgRoot()};Blockly.Field.prototype.getAbsoluteXY_=function(){return goog.style.getPageOffset(this.borderRect_)}; +Blockly.Field.prototype.referencesVariables=function(){return!1};Blockly.FieldLabel=function(a,b){this.size_=new goog.math.Size(0,17.5);this.class_=b;a=this.doClassValidation_(a);null===a&&(a="");this.setValue(a)};goog.inherits(Blockly.FieldLabel,Blockly.Field);Blockly.FieldLabel.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.text);return new Blockly.FieldLabel(b,a["class"])};Blockly.FieldLabel.prototype.EDITABLE=!1; +Blockly.FieldLabel.prototype.initView=function(){this.createTextElement_();this.textElement_.setAttribute("y",this.size_.height-5);this.class_&&Blockly.utils.dom.addClass(this.textElement_,this.class_)};Blockly.FieldLabel.prototype.doClassValidation_=function(a){return null===a||void 0===a?null:String(a)};Blockly.Field.register("field_label",Blockly.FieldLabel);Blockly.Input=function(a,b,c,d){if(a!=Blockly.DUMMY_INPUT&&!b)throw Error("Value inputs and statement inputs must have non-empty name.");this.type=a;this.name=b;this.sourceBlock_=c;this.connection=d;this.fieldRow=[]};Blockly.Input.prototype.align=Blockly.ALIGN_LEFT;Blockly.Input.prototype.visible_=!0;Blockly.Input.prototype.appendField=function(a,b){this.insertFieldAt(this.fieldRow.length,a,b);return this}; Blockly.Input.prototype.insertFieldAt=function(a,b,c){if(0>a||a>this.fieldRow.length)throw Error("index "+a+" out of bounds.");if(!b&&!c)return a;"string"==typeof b&&(b=new Blockly.FieldLabel(b));b.setSourceBlock(this.sourceBlock_);this.sourceBlock_.rendered&&b.init();b.name=c;b.prefixField&&(a=this.insertFieldAt(a,b.prefixField));this.fieldRow.splice(a,0,b);++a;b.suffixField&&(a=this.insertFieldAt(a,b.suffixField));this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_()); return a};Blockly.Input.prototype.removeField=function(a){for(var b=0,c;c=this.fieldRow[b];b++)if(c.name===a){c.dispose();this.fieldRow.splice(b,1);this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_());return}throw Error('Field "%s" not found.',a);};Blockly.Input.prototype.isVisible=function(){return this.visible_}; Blockly.Input.prototype.setVisible=function(a){var b=[];if(this.visible_==a)return b;for(var c=(this.visible_=a)?"block":"none",d=0,e;e=this.fieldRow[d];d++)e.setVisible(a);this.connection&&(a?b=this.connection.unhideAll():this.connection.hideAll(),d=this.connection.targetBlock())&&(d.getSvgRoot().style.display=c,a||(d.rendered=!1));return b};Blockly.Input.prototype.setCheck=function(a){if(!this.connection)throw Error("This input does not have a connection.");this.connection.setCheck(a);return this}; Blockly.Input.prototype.setAlign=function(a){this.align=a;this.sourceBlock_.rendered&&this.sourceBlock_.render();return this};Blockly.Input.prototype.init=function(){if(this.sourceBlock_.workspace.rendered)for(var a=0;a=c)this.hue_=c,this.colour_=Blockly.hueToRgb(c);else if("string"==typeof b&&/^#[0-9a-fA-F]{6}$/.test(b))this.colour_=b,this.hue_=null;else throw c='Invalid colour: "'+b+'"',a!=b&&(c+=' (from "'+a+'")'),Error(c);}; +Blockly.Block.prototype.getColourTertiary=function(){return this.colourTertiary_};Blockly.Block.prototype.getColourShadow=function(){var a=this.getColourSecondary();return a?a:Blockly.utils.colour.blend("white",this.getColour(),.6)}; +Blockly.Block.prototype.getColourBorder=function(){var a=this.getColourTertiary();if(a)return{colourBorder:a,colourLight:null,colourDark:null};a=this.getColour();return{colourBorder:null,colourLight:Blockly.utils.colour.blend("white",a,.3),colourDark:Blockly.utils.colour.blend("black",a,.2)}};Blockly.Block.prototype.getStyleName=function(){return this.styleName_};Blockly.Block.prototype.getHue=function(){return this.hue_}; +Blockly.Block.prototype.setColour=function(a){var b="string"==typeof a?Blockly.utils.replaceMessageReferences(a):a,c=Number(b);if(!isNaN(c)&&0<=c&&360>=c)this.hue_=c,this.colour_=Blockly.hueToHex(c);else if(c=Blockly.utils.colour.parse(b))this.colour_=c,this.hue_=null;else throw c='Invalid colour: "'+b+'"',a!=b&&(c+=' (from "'+a+'")'),Error(c);}; Blockly.Block.prototype.setStyle=function(a){var b=Blockly.getTheme();if(!b)throw Error("Trying to set block style to "+a+" before theme was defined via Blockly.setTheme().");b=b.getBlockStyle(a);this.styleName_=a;if(b)this.colourSecondary_=b.colourSecondary,this.colourTertiary_=b.colourTertiary,this.hat=b.hat,this.setColour(b.colourPrimary);else throw Error("Invalid style name: "+a);}; Blockly.Block.prototype.setOnChange=function(a){if(a&&"function"!=typeof a)throw Error("onchange must be a function.");this.onchangeWrapper_&&this.workspace.removeChangeListener(this.onchangeWrapper_);if(this.onchange=a)this.onchangeWrapper_=a.bind(this),this.workspace.addChangeListener(this.onchangeWrapper_)};Blockly.Block.prototype.getField=function(a){for(var b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)if(e.name===a)return e;return null}; Blockly.Block.prototype.getVars=function(){for(var a=[],b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)e.referencesVariables()&&a.push(e.getValue());return a};Blockly.Block.prototype.getVarModels=function(){for(var a=[],b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)e.referencesVariables()&&(e=this.workspace.getVariableById(e.getValue()))&&a.push(e);return a}; @@ -1465,8 +1457,8 @@ this.previousConnection=null}};Blockly.Block.prototype.setNextStatement=function Blockly.Block.prototype.setOutput=function(a,b){if(a){void 0===b&&(b=null);if(!this.outputConnection){if(this.previousConnection)throw Error("Remove previous connection prior to adding output connection.");this.outputConnection=this.makeConnection_(Blockly.OUTPUT_VALUE)}this.outputConnection.setCheck(b)}else if(this.outputConnection){if(this.outputConnection.isConnected())throw Error("Must disconnect output value before removing connection.");this.outputConnection.dispose();this.outputConnection= null}};Blockly.Block.prototype.setInputsInline=function(a){this.inputsInline!=a&&(Blockly.Events.fire(new Blockly.Events.BlockChange(this,"inline",null,this.inputsInline,a)),this.inputsInline=a)}; Blockly.Block.prototype.getInputsInline=function(){if(void 0!=this.inputsInline)return this.inputsInline;for(var a=1;aa&&(c=c.substring(0,a-3)+"...");return c}; Blockly.Block.prototype.appendValueInput=function(a){return this.appendInput_(Blockly.INPUT_VALUE,a)};Blockly.Block.prototype.appendStatementInput=function(a){return this.appendInput_(Blockly.NEXT_STATEMENT,a)};Blockly.Block.prototype.appendDummyInput=function(a){return this.appendInput_(Blockly.DUMMY_INPUT,a||"")}; Blockly.Block.prototype.jsonInit=function(a){var b=a.type?'Block "'+a.type+'": ':"";if(a.output&&a.previousStatement)throw Error(b+"Must not have both an output and a previousStatement.");a.style&&a.style.hat&&(this.hat=a.style.hat,a.style=null);if(a.style&&a.colour)throw Error(b+"Must not have both a colour and a style.");a.style?this.jsonInitStyle_(a,b):this.jsonInitColour_(a,b);for(var c=0;void 0!==a["message"+c];)this.interpolate_(a["message"+c],a["args"+c]||[],a["lastDummyAlign"+c]),c++;void 0!== @@ -1475,7 +1467,7 @@ a.inputsInline&&this.setInputsInline(a.inputsInline);void 0!==a.output&&this.set Blockly.Block.prototype.jsonInitColour_=function(a,b){if("colour"in a)if(void 0===a.colour)console.warn(b+"Undefined colour value.");else{var c=a.colour;try{this.setColour(c)}catch(d){console.warn(b+"Illegal colour value: ",c)}}};Blockly.Block.prototype.jsonInitStyle_=function(a,b){var c=a.style;try{this.setStyle(c)}catch(d){console.warn(b+"Style does not exist: ",c)}}; Blockly.Block.prototype.mixin=function(a,b){if(void 0!==b&&"boolean"!=typeof b)throw Error("opt_disableCheck must be a boolean if provided");if(!b){var c=[],d;for(d in a)void 0!==this[d]&&c.push(d);if(c.length)throw Error("Mixin will overwrite block members: "+JSON.stringify(c));}goog.mixin(this,a)}; Blockly.Block.prototype.interpolate_=function(a,b,c){var d=Blockly.utils.tokenizeInterpolation(a),e=[],f=0;a=[];for(var g=0;g=h||h>b.length)throw Error('Block "'+this.type+'": Message index %'+h+" out of range.");if(e[h])throw Error('Block "'+this.type+'": Message index %'+h+" duplicated.");e[h]=!0;f++;a.push(b[h-1])}else(h=h.trim())&&a.push(h)}if(f!=b.length)throw Error('Block "'+this.type+'": Message does not reference all '+b.length+" arg(s)."); -a.length&&("string"==typeof a[a.length-1]||Blockly.utils.startsWith(a[a.length-1].type,"field_"))&&(g={type:"input_dummy"},c&&(g.align=c),a.push(g));c={LEFT:Blockly.ALIGN_LEFT,RIGHT:Blockly.ALIGN_RIGHT,CENTRE:Blockly.ALIGN_CENTRE};b=[];for(g=0;ge.bottom)if(d-f.heighte.bottom)if(d-f.heightc;c+=15)Blockly.utils.createSvgElement("line",{x1:Blockly.FieldAngle.HALF+ -Blockly.FieldAngle.RADIUS,y1:Blockly.FieldAngle.HALF,x2:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS-(0==c%45?10:5),y2:Blockly.FieldAngle.HALF,"class":"blocklyAngleMarks",transform:"rotate("+c+","+Blockly.FieldAngle.HALF+","+Blockly.FieldAngle.HALF+")"},a);Blockly.DropDownDiv.setColour(this.sourceBlock_.getColour(),this.sourceBlock_.getColour());Blockly.DropDownDiv.showPositionedByField(this);this.clickWrapper_=Blockly.bindEvent_(a,"click",this,this.hide_.bind(this));this.moveWrapper1_=Blockly.bindEvent_(b, -"mousemove",this,this.onMouseMove);this.moveWrapper2_=Blockly.bindEvent_(this.gauge_,"mousemove",this,this.onMouseMove);this.updateGraph_()};Blockly.FieldAngle.prototype.hide_=function(){Blockly.unbindEvent_(this.moveWrapper1_);Blockly.unbindEvent_(this.moveWrapper2_);Blockly.unbindEvent_(this.clickWrapper_);Blockly.DropDownDiv.hideIfOwner(this);Blockly.WidgetDiv.hide()}; -Blockly.FieldAngle.prototype.onMouseMove=function(a){var b=this.gauge_.ownerSVGElement.getBoundingClientRect(),c=a.clientX-b.left-Blockly.FieldAngle.HALF;a=a.clientY-b.top-Blockly.FieldAngle.HALF;b=Math.atan(-a/c);isNaN(b)||(b=Blockly.utils.toDegrees(b),0>c?b+=180:0c;c+=15)Blockly.utils.dom.createSvgElement("line",{x1:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS,y1:Blockly.FieldAngle.HALF,x2:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS-(0==c%45?10:5),y2:Blockly.FieldAngle.HALF,"class":"blocklyAngleMarks",transform:"rotate("+c+","+Blockly.FieldAngle.HALF+","+Blockly.FieldAngle.HALF+ +")"},a);this.clickWrapper_=Blockly.bindEvent_(a,"click",this,this.hide_);this.moveWrapper1_=Blockly.bindEvent_(b,"mousemove",this,this.onMouseMove);this.moveWrapper2_=Blockly.bindEvent_(this.gauge_,"mousemove",this,this.onMouseMove);return a};Blockly.FieldAngle.prototype.dropdownDispose_=function(){Blockly.unbindEvent_(this.clickWrapper_);Blockly.unbindEvent_(this.moveWrapper1_);Blockly.unbindEvent_(this.moveWrapper2_)}; +Blockly.FieldAngle.prototype.hide_=function(){Blockly.DropDownDiv.hideIfOwner(this);Blockly.WidgetDiv.hide()}; +Blockly.FieldAngle.prototype.onMouseMove=function(a){var b=this.gauge_.ownerSVGElement.getBoundingClientRect(),c=a.clientX-b.left-Blockly.FieldAngle.HALF;b=a.clientY-b.top-Blockly.FieldAngle.HALF;a=Math.atan(-b/c);isNaN(a)||(a=Blockly.utils.math.toDegrees(a),0>c?a+=180:0Blockly.FieldAngle.WRAP&& +(a-=360),c=String(a),c!=this.text_&&(this.htmlInput_.value=a,this.setValue(a),this.text_=c,this.forceRerender()))}; +Blockly.FieldAngle.prototype.updateGraph_=function(){if(this.gauge_){var a=Number(this.getText())+Blockly.FieldAngle.OFFSET,b=Blockly.utils.math.toRadians(a%360);a=["M ",Blockly.FieldAngle.HALF,",",Blockly.FieldAngle.HALF];var c=Blockly.FieldAngle.HALF,d=Blockly.FieldAngle.HALF;if(!isNaN(b)){var e=Blockly.utils.math.toRadians(Blockly.FieldAngle.OFFSET),f=Math.cos(e)*Blockly.FieldAngle.RADIUS,g=Math.sin(e)*-Blockly.FieldAngle.RADIUS;Blockly.FieldAngle.CLOCKWISE&&(b=2*e-b);c+=Math.cos(b)*Blockly.FieldAngle.RADIUS; d-=Math.sin(b)*Blockly.FieldAngle.RADIUS;b=Math.abs(Math.floor((b-e)/Math.PI)%2);Blockly.FieldAngle.CLOCKWISE&&(b=1-b);a.push(" l ",f,",",g," A ",Blockly.FieldAngle.RADIUS,",",Blockly.FieldAngle.RADIUS," 0 ",b," ",Number(Blockly.FieldAngle.CLOCKWISE)," ",c,",",d," z")}this.gauge_.setAttribute("d",a.join(""));this.line_.setAttribute("x2",c);this.line_.setAttribute("y2",d)}}; -Blockly.FieldAngle.prototype.classValidator=function(a){if(null===a)return null;a=parseFloat(a||0);if(isNaN(a))return null;a%=360;0>a&&(a+=360);a>Blockly.FieldAngle.WRAP&&(a-=360);return String(a)};Blockly.Field.register("field_angle",Blockly.FieldAngle);Blockly.FieldCheckbox=function(a,b){Blockly.FieldCheckbox.superClass_.constructor.call(this,"",b);this.setValue(a)};goog.inherits(Blockly.FieldCheckbox,Blockly.Field);Blockly.FieldCheckbox.fromJson=function(a){return new Blockly.FieldCheckbox(a.checked?"TRUE":"FALSE")};Blockly.FieldCheckbox.CHECK_CHAR="\u2713";Blockly.FieldCheckbox.prototype.CURSOR="default"; -Blockly.FieldCheckbox.prototype.init=function(){if(!this.fieldGroup_){Blockly.FieldCheckbox.superClass_.init.call(this);this.checkElement_=Blockly.utils.createSvgElement("text",{"class":"blocklyText blocklyCheckbox",x:-3,y:14},this.fieldGroup_);var a=document.createTextNode(Blockly.FieldCheckbox.CHECK_CHAR);this.checkElement_.appendChild(a);this.checkElement_.style.display=this.state_?"block":"none"}};Blockly.FieldCheckbox.prototype.getValue=function(){return String(this.state_).toUpperCase()}; -Blockly.FieldCheckbox.prototype.setValue=function(a){a="string"==typeof a?"TRUE"==a.toUpperCase():!!a;this.state_!==a&&(this.sourceBlock_&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this.sourceBlock_,"field",this.name,this.state_,a)),this.state_=a,this.checkElement_&&(this.checkElement_.style.display=a?"block":"none"))};Blockly.FieldCheckbox.prototype.showEditor_=function(){var a=!this.state_;this.sourceBlock_&&(a=this.callValidator(a));null!==a&&this.setValue(String(a).toUpperCase())}; -Blockly.Field.register("field_checkbox",Blockly.FieldCheckbox);Blockly.FieldColour=function(a,b){Blockly.FieldColour.superClass_.constructor.call(this,a,b);this.setText(Blockly.Field.NBSP+Blockly.Field.NBSP+Blockly.Field.NBSP)};goog.inherits(Blockly.FieldColour,Blockly.Field);Blockly.FieldColour.fromJson=function(a){return new Blockly.FieldColour(a.colour)};Blockly.FieldColour.DEFAULT_WIDTH=16;Blockly.FieldColour.DEFAULT_HEIGHT=12;Blockly.FieldColour.prototype.colours_=null;Blockly.FieldColour.prototype.titles_=null;Blockly.FieldColour.prototype.columns_=0; -Blockly.FieldColour.prototype.DROPDOWN_BORDER_COLOUR="silver";Blockly.FieldColour.prototype.DROPDOWN_BACKGROUND_COLOUR="white";Blockly.FieldColour.prototype.init=function(){Blockly.FieldColour.superClass_.init.call(this);this.borderRect_.style.fillOpacity=1;this.size_=new goog.math.Size(Blockly.FieldColour.DEFAULT_WIDTH,Blockly.FieldColour.DEFAULT_HEIGHT);this.setValue(this.getValue())};Blockly.FieldColour.prototype.CURSOR="default"; -Blockly.FieldColour.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldColour.superClass_.dispose.call(this)};Blockly.FieldColour.prototype.getValue=function(){return this.colour_};Blockly.FieldColour.prototype.getSize=function(){this.size_.width||this.render_();return this.size_}; -Blockly.FieldColour.prototype.updateWidth=function(){var a=Blockly.FieldColour.DEFAULT_WIDTH;this.borderRect_&&this.borderRect_.setAttribute("width",a+Blockly.BlockSvg.SEP_SPACE_X);this.size_.width=a};Blockly.FieldColour.prototype.setValue=function(a){this.sourceBlock_&&Blockly.Events.isEnabled()&&this.colour_!=a&&Blockly.Events.fire(new Blockly.Events.BlockChange(this.sourceBlock_,"field",this.name,this.colour_,a));this.colour_=a;this.borderRect_&&(this.borderRect_.style.fill=a)}; -Blockly.FieldColour.prototype.getText=function(){var a=this.colour_,b=a.match(/^#(.)\1(.)\2(.)\3$/);b&&(a="#"+b[1]+b[2]+b[3]);return a};Blockly.FieldColour.COLOURS="#ffffff #cccccc #c0c0c0 #999999 #666666 #333333 #000000 #ffcccc #ff6666 #ff0000 #cc0000 #990000 #660000 #330000 #ffcc99 #ff9966 #ff9900 #ff6600 #cc6600 #993300 #663300 #ffff99 #ffff66 #ffcc66 #ffcc33 #cc9933 #996633 #663333 #ffffcc #ffff33 #ffff00 #ffcc00 #999900 #666600 #333300 #99ff99 #66ff99 #33ff33 #33cc00 #009900 #006600 #003300 #99ffff #33ffff #66cccc #00cccc #339999 #336666 #003333 #ccffff #66ffff #33ccff #3366ff #3333ff #000099 #000066 #ccccff #9999ff #6666cc #6633ff #6600cc #333399 #330099 #ffccff #ff99ff #cc66cc #cc33cc #993399 #663366 #330033".split(" "); +Blockly.FieldAngle.prototype.doClassValidation_=function(a){if(isNaN(a))return null;a=parseFloat(a||0);a%=360;0>a&&(a+=360);a>Blockly.FieldAngle.WRAP&&(a-=360);return a};Blockly.Field.register("field_angle",Blockly.FieldAngle);Blockly.FieldCheckbox=function(a,b){a=this.doClassValidation_(a);null===a&&(a="FALSE");Blockly.FieldCheckbox.superClass_.constructor.call(this,a,b);this.size_.width=Blockly.FieldCheckbox.WIDTH};goog.inherits(Blockly.FieldCheckbox,Blockly.Field);Blockly.FieldCheckbox.fromJson=function(a){return new Blockly.FieldCheckbox(a.checked)};Blockly.FieldCheckbox.WIDTH=5;Blockly.FieldCheckbox.CHECK_CHAR="\u2713";Blockly.FieldCheckbox.CHECK_X_OFFSET=-3;Blockly.FieldCheckbox.CHECK_Y_OFFSET=14; +Blockly.FieldCheckbox.prototype.SERIALIZABLE=!0;Blockly.FieldCheckbox.prototype.CURSOR="default";Blockly.FieldCheckbox.prototype.isDirty_=!1; +Blockly.FieldCheckbox.prototype.initView=function(){Blockly.FieldCheckbox.superClass_.initView.call(this);this.textElement_.setAttribute("x",Blockly.FieldCheckbox.CHECK_X_OFFSET);this.textElement_.setAttribute("y",Blockly.FieldCheckbox.CHECK_Y_OFFSET);Blockly.utils.dom.addClass(this.textElement_,"blocklyCheckbox");var a=document.createTextNode(Blockly.FieldCheckbox.CHECK_CHAR);this.textElement_.appendChild(a);this.textElement_.style.display=this.value_?"block":"none"}; +Blockly.FieldCheckbox.prototype.showEditor_=function(){this.setValue(!this.value_)};Blockly.FieldCheckbox.prototype.doClassValidation_=function(a){return!0===a||"TRUE"===a?"TRUE":!1===a||"FALSE"===a?"FALSE":null};Blockly.FieldCheckbox.prototype.doValueUpdate_=function(a){this.value_=this.convertValueToBool_(a);this.textElement_&&(this.textElement_.style.display=this.value_?"block":"none")};Blockly.FieldCheckbox.prototype.getValue=function(){return this.value_?"TRUE":"FALSE"}; +Blockly.FieldCheckbox.prototype.getValueBoolean=function(){return this.value_};Blockly.FieldCheckbox.prototype.getText=function(){return String(this.convertValueToBool_(this.value_))};Blockly.FieldCheckbox.prototype.convertValueToBool_=function(a){return"string"==typeof a?"TRUE"==a:!!a};Blockly.Field.register("field_checkbox",Blockly.FieldCheckbox);Blockly.utils.colour={};Blockly.utils.colour.parse=function(a){a=String(a).toLowerCase().trim();var b=Blockly.utils.colour.names[a];if(b)return b;b="#"==a[0]?a:"#"+a;if(/^#[0-9a-f]{6}$/.test(b))return b;if(/^#[0-9a-f]{3}$/.test(b))return["#",b[1],b[1],b[2],b[2],b[3],b[3]].join("");var c=a.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return c&&(a=Number(c[1]),b=Number(c[2]),c=Number(c[3]),0<=a&&256>a&&0<=b&&256>b&&0<=c&&256>c)?Blockly.utils.colour.rgbToHex(a,b,c):null}; +Blockly.utils.colour.rgbToHex=function(a,b,c){b=a<<16|b<<8|c;return 16>a?"#"+(16777216|b).toString(16).substr(1):"#"+b.toString(16)};Blockly.utils.colour.hexToRgb=function(a){a=parseInt(a.substr(1),16);return[a>>16,a>>8&255,a&255]}; +Blockly.utils.colour.hsvToHex=function(a,b,c){var d=0,e=0,f=0;if(0==b)f=e=d=c;else{var g=Math.floor(a/60),h=a/60-g;a=c*(1-b);var k=c*(1-b*h);b=c*(1-b*(1-h));switch(g){case 1:d=k;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=k;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=k;break;case 6:case 0:d=c,e=b,f=a}}return Blockly.utils.colour.rgbToHex(Math.floor(d),Math.floor(e),Math.floor(f))}; +Blockly.utils.colour.blend=function(a,b,c){a=Blockly.utils.colour.hexToRgb(Blockly.utils.colour.parse(a));b=Blockly.utils.colour.hexToRgb(Blockly.utils.colour.parse(b));return Blockly.utils.colour.rgbToHex(Math.round(b[0]+c*(a[0]-b[0])),Math.round(b[1]+c*(a[1]-b[1])),Math.round(b[2]+c*(a[2]-b[2])))}; +Blockly.utils.colour.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"};Blockly.FieldColour=function(a,b){a=this.doClassValidation_(a);null===a&&(a=Blockly.FieldColour.COLOURS[0]);Blockly.FieldColour.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldColour,Blockly.Field);Blockly.FieldColour.fromJson=function(a){return new Blockly.FieldColour(a.colour)};Blockly.FieldColour.DEFAULT_WIDTH=16;Blockly.FieldColour.DEFAULT_HEIGHT=12;Blockly.FieldColour.prototype.SERIALIZABLE=!0;Blockly.FieldColour.prototype.CURSOR="default"; +Blockly.FieldColour.prototype.isDirty_=!1;Blockly.FieldColour.prototype.colours_=null;Blockly.FieldColour.prototype.titles_=null;Blockly.FieldColour.prototype.columns_=0;Blockly.FieldColour.prototype.DROPDOWN_BORDER_COLOUR="silver";Blockly.FieldColour.prototype.DROPDOWN_BACKGROUND_COLOUR="white"; +Blockly.FieldColour.prototype.initView=function(){this.size_=new goog.math.Size(Blockly.FieldColour.DEFAULT_WIDTH,Blockly.FieldColour.DEFAULT_HEIGHT);this.createBorderRect_();this.borderRect_.style.fillOpacity=1;this.borderRect_.style.fill=this.value_};Blockly.FieldColour.prototype.doClassValidation_=function(a){return"string"!=typeof a?null:Blockly.utils.colour.parse(a)};Blockly.FieldColour.prototype.doValueUpdate_=function(a){this.value_=a;this.borderRect_&&(this.borderRect_.style.fill=a)}; +Blockly.FieldColour.prototype.getText=function(){var a=this.value_;/^#(.)\1(.)\2(.)\3$/.test(a)&&(a="#"+a[1]+a[3]+a[5]);return a};Blockly.FieldColour.COLOURS="#ffffff #cccccc #c0c0c0 #999999 #666666 #333333 #000000 #ffcccc #ff6666 #ff0000 #cc0000 #990000 #660000 #330000 #ffcc99 #ff9966 #ff9900 #ff6600 #cc6600 #993300 #663300 #ffff99 #ffff66 #ffcc66 #ffcc33 #cc9933 #996633 #663333 #ffffcc #ffff33 #ffff00 #ffcc00 #999900 #666600 #333300 #99ff99 #66ff99 #33ff33 #33cc00 #009900 #006600 #003300 #99ffff #33ffff #66cccc #00cccc #339999 #336666 #003333 #ccffff #66ffff #33ccff #3366ff #3333ff #000099 #000066 #ccccff #9999ff #6666cc #6633ff #6600cc #333399 #330099 #ffccff #ff99ff #cc66cc #cc33cc #993399 #663366 #330033".split(" "); Blockly.FieldColour.TITLES=[];Blockly.FieldColour.COLUMNS=7;Blockly.FieldColour.prototype.setColours=function(a,b){this.colours_=a;void 0!==b&&(this.titles_=b);return this};Blockly.FieldColour.prototype.setColumns=function(a){this.columns_=a;return this}; -Blockly.FieldColour.prototype.showEditor_=function(){Blockly.DropDownDiv.hideWithoutAnimation();Blockly.DropDownDiv.clearContent();var a=this.createWidget_();Blockly.DropDownDiv.getContentDiv().appendChild(a);Blockly.DropDownDiv.setColour(this.DROPDOWN_BACKGROUND_COLOUR,this.DROPDOWN_BORDER_COLOUR);Blockly.DropDownDiv.showPositionedByField(this);Blockly.FieldColour.onUpWrapper_=Blockly.bindEvent_(a,"mouseup",this,this.onClick_)}; -Blockly.FieldColour.prototype.onClick_=function(a){(a=a.target)&&!a.label&&(a=a.parentNode);a=a&&a.label;Blockly.WidgetDiv.hide();this.sourceBlock_&&(a=this.callValidator(a));null!==a&&this.setValue(a)}; -Blockly.FieldColour.prototype.createWidget_=function(){var a=this.columns_||Blockly.FieldColour.COLUMNS,b=this.colours_||Blockly.FieldColour.COLOURS,c=this.titles_||Blockly.FieldColour.TITLES,d=this.getValue(),e=document.createElement("table");e.className="blocklyColourTable";for(var f,g=0;ge&&(d.height=e);this.sourceBlock_.RTL&&Blockly.utils.uiMenu.adjustBBoxesForRTL(b,c,d);Blockly.WidgetDiv.positionWithAnchor(b,c,d,this.sourceBlock_.RTL);a.getElement().focus()}; -Blockly.FieldDropdown.prototype.createWidget_=function(a){a.render(Blockly.WidgetDiv.DIV);Blockly.utils.addClass(a.getElement(),"blocklyDropdownMenu");a.setAllowAutoFocus(!0)};Blockly.FieldDropdown.prototype.getAnchorDimensions_=function(){var a=this.getScaledBBox_();this.sourceBlock_.RTL?a.right+=Blockly.FieldDropdown.CHECKMARK_OVERHANG:a.left-=Blockly.FieldDropdown.CHECKMARK_OVERHANG;return a}; -Blockly.FieldDropdown.prototype.onItemSelected=function(a,b){var c=b.getValue();this.sourceBlock_&&(c=this.callValidator(c));null!==c&&this.setValue(c)}; -Blockly.FieldDropdown.prototype.trimOptions_=function(){this.suffixField=this.prefixField=null;var a=this.menuGenerator_;if(Array.isArray(a)){for(var b=!1,c=0;ca.length)){b=[];for(c=0;cd&&(a.height=d);this.sourceBlock_.RTL&&Blockly.utils.uiMenu.adjustBBoxesForRTL(b,c,a);Blockly.WidgetDiv.positionWithAnchor(b,c,a,this.sourceBlock_.RTL)}; +Blockly.FieldDropdown.prototype.getAnchorDimensions_=function(){var a=this.getScaledBBox_();this.sourceBlock_.RTL?a.right+=Blockly.FieldDropdown.CHECKMARK_OVERHANG:a.left-=Blockly.FieldDropdown.CHECKMARK_OVERHANG;return a};Blockly.FieldDropdown.prototype.onItemSelected=function(a,b){this.setValue(b.getValue())}; +Blockly.FieldDropdown.prototype.trimOptions_=function(){this.suffixField=this.prefixField=null;var a=this.menuGenerator_;if(Array.isArray(a)){for(var b=!1,c=0;ca.length)){b=[];for(c=0;c=this.height_||0>=this.width_)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new goog.math.Size(this.width_,this.height_+2*Blockly.BlockSvg.INLINE_PADDING_Y);this.flipRtl_=f;this.text_=d||"";this.setValue(a||"");"function"==typeof e&&(this.clickHandler_= +e)};goog.inherits(Blockly.FieldImage,Blockly.Field);Blockly.FieldImage.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.src),c=Number(Blockly.utils.replaceMessageReferences(a.width)),d=Number(Blockly.utils.replaceMessageReferences(a.height)),e=Blockly.utils.replaceMessageReferences(a.alt);return new Blockly.FieldImage(b,c,d,e,null,!!a.flipRtl)};Blockly.FieldImage.prototype.EDITABLE=!1;Blockly.FieldImage.prototype.isDirty_=!1; +Blockly.FieldImage.prototype.initView=function(){this.imageElement_=Blockly.utils.dom.createSvgElement("image",{height:this.height_+"px",width:this.width_+"px",alt:this.text_},this.fieldGroup_);this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,"xlink:href",this.value_)};Blockly.FieldImage.prototype.doClassValidation_=function(a){return"string"!=typeof a?null:a}; +Blockly.FieldImage.prototype.doValueUpdate_=function(a){this.value_=a;this.imageElement_&&this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,"xlink:href",this.value_||"")};Blockly.FieldImage.prototype.getFlipRtl=function(){return this.flipRtl_};Blockly.FieldImage.prototype.setText=function(a){null!==a&&(this.text_=a,this.imageElement_&&this.imageElement_.setAttribute("alt",a||""))};Blockly.FieldImage.prototype.showEditor_=function(){this.clickHandler_&&this.clickHandler_(this)}; +Blockly.Field.register("field_image",Blockly.FieldImage);Blockly.FieldNumber=function(a,b,c,d,e){this.setConstraints(b,c,d);a=this.doClassValidation_(a);null===a&&(a=0);Blockly.FieldNumber.superClass_.constructor.call(this,a,e)};goog.inherits(Blockly.FieldNumber,Blockly.FieldTextInput);Blockly.FieldNumber.fromJson=function(a){return new Blockly.FieldNumber(a.value,a.min,a.max,a.precision)};Blockly.FieldNumber.prototype.SERIALIZABLE=!0; +Blockly.FieldNumber.prototype.setConstraints=function(a,b,c){c=parseFloat(c);this.precision_=isNaN(c)?0:c;c=this.precision_.toString();var d=c.indexOf(".");this.fractionalDigits_=-1==d?-1:c.length-(d+1);a=parseFloat(a);this.min_=isNaN(a)?-Infinity:a;b=parseFloat(b);this.max_=isNaN(b)?Infinity:b;this.setValue(this.getValue())}; +Blockly.FieldNumber.prototype.doClassValidation_=function(a){if(null===a||void 0===a)return null;a=String(a);a=a.replace(/O/ig,"0");a=a.replace(/,/g,"");a=parseFloat(a||0);if(isNaN(a))return null;a=Math.min(Math.max(a,this.min_),this.max_);this.precision_&&isFinite(a)&&(a=Math.round(a/this.precision_)*this.precision_);return a=-1==this.fractionalDigits_?a:Number(a.toFixed(this.fractionalDigits_))};Blockly.Field.register("field_number",Blockly.FieldNumber);Blockly.FieldVariable=function(a,b,c,d){this.menuGenerator_=Blockly.FieldVariable.dropdownCreate;this.size_=new goog.math.Size(0,Blockly.BlockSvg.MIN_BLOCK_Y);this.setValidator(b);this.defaultVariableName=a||"";this.setTypes_(c,d);this.value_=null};goog.inherits(Blockly.FieldVariable,Blockly.FieldDropdown);Blockly.FieldVariable.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.variable);return new Blockly.FieldVariable(b,null,a.variableTypes,a.defaultType)}; +Blockly.FieldVariable.prototype.workspace_=null;Blockly.FieldVariable.prototype.SERIALIZABLE=!0;Blockly.FieldVariable.prototype.initModel=function(){if(!this.variable_){var a=Blockly.Variables.getOrCreateVariablePackage(this.workspace_,null,this.defaultVariableName,this.defaultType_);Blockly.Events.disable();this.setValue(a.getId());Blockly.Events.enable()}}; +Blockly.FieldVariable.prototype.fromXml=function(a){var b=a.getAttribute("id"),c=a.textContent,d=a.getAttribute("variabletype")||a.getAttribute("variableType")||"";b=Blockly.Variables.getOrCreateVariablePackage(this.workspace_,b,c,d);if(null!=d&&d!==b.type)throw Error("Serialized variable type with id '"+b.getId()+"' had type "+b.type+", and does not match variable field that references it: "+Blockly.Xml.domToText(a)+".");this.setValue(b.getId())}; +Blockly.FieldVariable.prototype.toXml=function(a){this.initModel();a.id=this.variable_.getId();a.textContent=this.variable_.name;this.variable_.type&&a.setAttribute("variabletype",this.variable_.type);return a};Blockly.FieldVariable.prototype.setSourceBlock=function(a){if(a.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");Blockly.FieldVariable.superClass_.setSourceBlock.call(this,a);this.workspace_=a.workspace}; +Blockly.FieldVariable.prototype.getValue=function(){return this.variable_?this.variable_.getId():null};Blockly.FieldVariable.prototype.getText=function(){return this.variable_?this.variable_.name:""};Blockly.FieldVariable.prototype.getVariable=function(){return this.variable_};Blockly.FieldVariable.prototype.getValidator=function(){return this.variable_?this.validator_:null}; +Blockly.FieldVariable.prototype.doClassValidation_=function(a){var b=Blockly.Variables.getVariable(this.workspace_,a);if(!b)return console.warn("Variable id doesn't point to a real variable! ID was "+a),null;b=b.type;return this.typeIsAllowed_(b)?a:(console.warn("Variable type doesn't match this field! Type was "+b),null)}; +Blockly.FieldVariable.prototype.doValueUpdate_=function(a){this.variable_=Blockly.Variables.getVariable(this.workspace_,a);this.value_=a;this.text_=this.variable_.name;this.isDirty_=!0};Blockly.FieldVariable.prototype.typeIsAllowed_=function(a){var b=this.getVariableTypes_();if(!b)return!0;for(var c=0;c90-b||a>-90-b&&a<-90+b?!0:!1}; -Blockly.HorizontalFlyout.prototype.getClientRect=function(){if(!this.svgGroup_)return null;var a=this.svgGroup_.getBoundingClientRect(),b=a.top;a=a.height;if(this.toolboxPosition_==Blockly.TOOLBOX_AT_TOP)return new goog.math.Rect(-1E9,b-1E9,2E9,1E9+a);if(this.toolboxPosition_==Blockly.TOOLBOX_AT_BOTTOM)return new goog.math.Rect(-1E9,b,2E9,1E9+a)}; +Blockly.HorizontalFlyout.prototype.getClientRect=function(){if(!this.svgGroup_)return null;var a=this.svgGroup_.getBoundingClientRect(),b=a.top;return this.toolboxPosition_==Blockly.TOOLBOX_AT_TOP?new Blockly.utils.Rect(-1E9,b+a.height,-1E9,1E9):new Blockly.utils.Rect(b,-1E9,-1E9,1E9)}; Blockly.HorizontalFlyout.prototype.reflowInternal_=function(){this.workspace_.scale=this.targetWorkspace_.scale;for(var a=0,b=this.workspace_.getTopBlocks(!1),c=0,d;d=b[c];c++)a=Math.max(a,d.getHeightWidth().height);a+=1.5*this.MARGIN;a*=this.workspace_.scale;a+=Blockly.Scrollbar.scrollbarThickness;if(this.height_!=a){for(c=0;d=b[c];c++)d.flyoutRect_&&this.moveRectToBlock_(d.flyoutRect_,d);this.height_=a;this.position()}};Blockly.VerticalFlyout=function(a){a.getMetrics=this.getMetrics_.bind(this);a.setMetrics=this.setMetrics_.bind(this);Blockly.VerticalFlyout.superClass_.constructor.call(this,a);this.horizontalLayout_=!1};goog.inherits(Blockly.VerticalFlyout,Blockly.Flyout); Blockly.VerticalFlyout.prototype.getMetrics_=function(){if(!this.isVisible())return null;try{var a=this.workspace_.getCanvas().getBBox()}catch(e){a={height:0,y:0,width:0,x:0}}var b=this.SCROLLBAR_PADDING,c=this.height_-2*this.SCROLLBAR_PADDING,d=this.width_;this.RTL||(d-=this.SCROLLBAR_PADDING);return{viewHeight:c,viewWidth:d,contentHeight:a.height*this.workspace_.scale+2*this.MARGIN,contentWidth:a.width*this.workspace_.scale+2*this.MARGIN,viewTop:-this.workspace_.scrollY+a.y,viewLeft:-this.workspace_.scrollX, contentTop:a.y,contentLeft:a.x,absoluteTop:b,absoluteLeft:0}};Blockly.VerticalFlyout.prototype.setMetrics_=function(a){var b=this.getMetrics_();b&&("number"==typeof a.y&&(this.workspace_.scrollY=-b.contentHeight*a.y),this.workspace_.translate(this.workspace_.scrollX+b.absoluteLeft,this.workspace_.scrollY+b.absoluteTop))}; @@ -1750,34 +1731,34 @@ Blockly.VerticalFlyout.prototype.setBackgroundPath_=function(a,b){var c=this.too d.join(" "))};Blockly.VerticalFlyout.prototype.scrollToStart=function(){this.scrollbar_.set(0)};Blockly.VerticalFlyout.prototype.wheel_=function(a){var b=Blockly.utils.getScrollDeltaPixels(a);if(b.y){var c=this.getMetrics_();b=c.viewTop-c.contentTop+b.y;b=Math.min(b,c.contentHeight-c.viewHeight);b=Math.max(b,0);this.scrollbar_.set(b);Blockly.WidgetDiv.hide()}a.preventDefault();a.stopPropagation()}; Blockly.VerticalFlyout.prototype.layout_=function(a,b){this.workspace_.scale=this.targetWorkspace_.scale;for(var c=this.MARGIN,d=this.RTL?c:c+Blockly.BlockSvg.TAB_WIDTH,e=0,f;f=a[e];e++)if("block"==f.type){f=f.block;for(var g=f.getDescendants(!1),h=0,k;k=g[h];h++)k.isInFlyout=!0;f.render();g=f.getSvgRoot();h=f.getHeightWidth();f.moveBy(d,c);k=this.createRect_(f,this.RTL?d-h.width:d,c,h,e);this.addBlockListeners_(g,f,k);c+=h.height+b[e]}else"button"==f.type&&(this.initFlyoutButton_(f.button,d,c),c+= f.button.height+b[e])};Blockly.VerticalFlyout.prototype.isDragTowardWorkspace=function(a){a=Math.atan2(a.y,a.x)/Math.PI*180;var b=this.dragAngleRange_;return a-b||a<-180+b||a>180-b?!0:!1}; -Blockly.VerticalFlyout.prototype.getClientRect=function(){if(!this.svgGroup_)return null;var a=this.svgGroup_.getBoundingClientRect(),b=a.left;a=a.width;if(this.toolboxPosition_==Blockly.TOOLBOX_AT_LEFT)return new goog.math.Rect(b-1E9,-1E9,1E9+a,2E9);if(goog.userAgent.GECKO&&this.targetWorkspace_&&this.targetWorkspace_.isMutator){var c=this.targetWorkspace_.svgGroup_.getBoundingClientRect().x;10>Math.abs(c-b)&&(b+=this.leftEdge_*this.targetWorkspace_.options.parentWorkspace.scale)}return new goog.math.Rect(b, --1E9,1E9+a,2E9)}; +Blockly.VerticalFlyout.prototype.getClientRect=function(){if(!this.svgGroup_)return null;var a=this.svgGroup_.getBoundingClientRect(),b=a.left;if(this.toolboxPosition_==Blockly.TOOLBOX_AT_LEFT)return new Blockly.utils.Rect(-1E9,1E9,-1E9,b+a.width);Blockly.utils.userAgent.GECKO&&this.targetWorkspace_&&this.targetWorkspace_.isMutator&&(a=this.targetWorkspace_.svgGroup_.getBoundingClientRect().x,10>Math.abs(a-b)&&(b+=this.leftEdge_*this.targetWorkspace_.options.parentWorkspace.scale));return new Blockly.utils.Rect(-1E9, +1E9,b,1E9)}; Blockly.VerticalFlyout.prototype.reflowInternal_=function(){this.workspace_.scale=this.targetWorkspace_.scale;for(var a=0,b=this.workspace_.getTopBlocks(!1),c=0,d;d=b[c];c++){var e=d.getHeightWidth().width;d.outputConnection&&(e-=Blockly.BlockSvg.TAB_WIDTH);a=Math.max(a,e)}for(c=0;d=this.buttons_[c];c++)a=Math.max(a,d.width);a+=1.5*this.MARGIN+Blockly.BlockSvg.TAB_WIDTH;a*=this.workspace_.scale;a+=Blockly.Scrollbar.scrollbarThickness;if(this.width_!=a){for(c=0;d=b[c];c++)this.RTL&&(e=d.getRelativeToSurfaceXY().x, d.moveBy(a/this.workspace_.scale-this.MARGIN-Blockly.BlockSvg.TAB_WIDTH-e,0)),d.flyoutRect_&&this.moveRectToBlock_(d.flyoutRect_,d);if(this.RTL)for(c=0;d=this.buttons_[c];c++)b=d.getPosition().y,d.moveTo(a/this.workspace_.scale-d.width-this.MARGIN-Blockly.BlockSvg.TAB_WIDTH,b);this.width_=a;this.position()}};Blockly.Toolbox=function(a){this.workspace_=a;this.RTL=a.options.RTL;this.horizontalLayout_=a.options.horizontalLayout;this.toolboxPosition=a.options.toolboxPosition;this.config_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssHideRoot:"blocklyHidden",cssItem:"",cssTreeRow:"blocklyTreeRow",cssItemLabel:"blocklyTreeLabel",cssTreeIcon:"blocklyTreeIcon",cssExpandedFolderIcon:"blocklyTreeIconOpen",cssFileIcon:"blocklyTreeIconNone",cssSelectedRow:"blocklyTreeSelected"};this.treeSeparatorConfig_={cssTreeRow:"blocklyTreeSeparator"}; this.horizontalLayout_&&(this.config_.cssTreeRow+=a.RTL?" blocklyHorizontalTreeRtl":" blocklyHorizontalTree",this.treeSeparatorConfig_.cssTreeRow="blocklyTreeSeparatorHorizontal "+(a.RTL?"blocklyHorizontalTreeRtl":"blocklyHorizontalTree"),this.config_.cssTreeIcon="")};Blockly.Toolbox.prototype.width=0;Blockly.Toolbox.prototype.height=0;Blockly.Toolbox.prototype.selectedOption_=null;Blockly.Toolbox.prototype.lastCategory_=null; Blockly.Toolbox.prototype.init=function(){var a=this.workspace_,b=this.workspace_.getParentSvg();this.HtmlDiv=document.createElement("div");this.HtmlDiv.className="blocklyToolboxDiv";this.HtmlDiv.setAttribute("dir",a.RTL?"RTL":"LTR");b.parentNode.insertBefore(this.HtmlDiv,b);Blockly.bindEventWithChecks_(this.HtmlDiv,"mousedown",this,function(a){Blockly.utils.isRightButton(a)||a.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0);Blockly.Touch.clearTouchIdentifier()},!1,!0);b={disabledPatternId:a.options.disabledPatternId, -parentWorkspace:a,RTL:a.RTL,oneBasedIndex:a.options.oneBasedIndex,horizontalLayout:a.horizontalLayout,toolboxPosition:a.options.toolboxPosition};this.flyout_=null;this.flyout_=a.horizontalLayout?new Blockly.HorizontalFlyout(b):new Blockly.VerticalFlyout(b);Blockly.utils.insertAfter(this.flyout_.createDom("svg"),this.workspace_.getParentSvg());this.flyout_.init(a);this.config_.cleardotPath=a.options.pathToMedia+"1x1.gif";this.config_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(a.RTL?"Rtl":"Ltr"); -this.tree_=b=new Blockly.Toolbox.TreeControl(this,this.config_);b.setShowRootNode(!1);b.setShowLines(!1);b.setShowExpandIcons(!1);b.setSelectedItem(null);a=this.populate_(a.options.languageTree);b.render(this.HtmlDiv);a&&b.setSelectedItem(a);this.addColour_();this.position()};Blockly.Toolbox.prototype.dispose=function(){this.flyout_.dispose();this.tree_.dispose();Blockly.utils.removeNode(this.HtmlDiv);this.lastCategory_=this.workspace_=null};Blockly.Toolbox.prototype.getWidth=function(){return this.width}; +parentWorkspace:a,RTL:a.RTL,oneBasedIndex:a.options.oneBasedIndex,horizontalLayout:a.horizontalLayout,toolboxPosition:a.options.toolboxPosition};this.flyout_=null;this.flyout_=a.horizontalLayout?new Blockly.HorizontalFlyout(b):new Blockly.VerticalFlyout(b);Blockly.utils.dom.insertAfter(this.flyout_.createDom("svg"),this.workspace_.getParentSvg());this.flyout_.init(a);this.config_.cleardotPath=a.options.pathToMedia+"1x1.gif";this.config_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(a.RTL?"Rtl": +"Ltr");this.tree_=b=new Blockly.Toolbox.TreeControl(this,this.config_);b.setShowRootNode(!1);b.setShowLines(!1);b.setShowExpandIcons(!1);b.setSelectedItem(null);a=this.populate_(a.options.languageTree);b.render(this.HtmlDiv);a&&b.setSelectedItem(a);this.addColour_();this.position()};Blockly.Toolbox.prototype.dispose=function(){this.flyout_.dispose();this.tree_.dispose();Blockly.utils.dom.removeNode(this.HtmlDiv);this.lastCategory_=this.workspace_=null};Blockly.Toolbox.prototype.getWidth=function(){return this.width}; Blockly.Toolbox.prototype.getHeight=function(){return this.height}; Blockly.Toolbox.prototype.position=function(){var a=this.HtmlDiv;if(a){var b=this.workspace_.getParentSvg();b=Blockly.svgSize(b);this.horizontalLayout_?(a.style.left="0",a.style.height="auto",a.style.width=b.width+"px",this.height=a.offsetHeight,this.toolboxPosition==Blockly.TOOLBOX_AT_TOP?a.style.top="0":a.style.bottom="0"):(this.toolboxPosition==Blockly.TOOLBOX_AT_RIGHT?a.style.right="0":a.style.left="0",a.style.height=b.height+"px",this.width=a.offsetWidth);this.flyout_.position()}}; Blockly.Toolbox.prototype.populate_=function(a){this.tree_.removeChildren();this.tree_.blocks=[];this.hasColours_=!1;a=this.syncTrees_(a,this.tree_,this.workspace_.options.pathToMedia);if(this.tree_.blocks.length)throw Error("Toolbox cannot have both blocks and categories in the root level.");this.workspace_.resizeContents();return a}; Blockly.Toolbox.prototype.syncTrees_=function(a,b,c){for(var d=null,e=null,f=0,g;g=a.childNodes[f];f++)if(g.tagName)switch(g.tagName.toUpperCase()){case "CATEGORY":e=Blockly.utils.replaceMessageReferences(g.getAttribute("name"));var h=this.tree_.createNode(e);h.blocks=[];b.add(h);var k=g.getAttribute("custom");k?h.blocks=k:(k=this.syncTrees_(g,h,c))&&(d=k);k=g.getAttribute("categorystyle");var l=g.getAttribute("colour");l&&k?(h.hexColour="",console.warn('Toolbox category "'+e+'" can not have both a style and a colour')): -k?this.setColourFromStyle_(k,h,e):this.setColour_(l,h,e);"true"==g.getAttribute("expanded")?(h.blocks.length&&(d=h),h.setExpanded(!0)):h.setExpanded(!1);e=g;break;case "SEP":e&&("CATEGORY"==e.tagName.toUpperCase()?b.add(new Blockly.Toolbox.TreeSeparator(this.treeSeparatorConfig_)):(g=parseFloat(g.getAttribute("gap")),!isNaN(g)&&e&&e.setAttribute("gap",g)));break;case "BLOCK":case "SHADOW":case "LABEL":case "BUTTON":b.blocks.push(g),e=g}return d}; -Blockly.Toolbox.prototype.setColour_=function(a,b,c){a=Blockly.utils.replaceMessageReferences(a);null===a||""===a?b.hexColour="":/^#[0-9a-fA-F]{6}$/.test(a)?(b.hexColour=a,this.hasColours_=!0):"number"===typeof a||"string"===typeof a&&!isNaN(Number(a))?(b.hexColour=Blockly.hueToRgb(Number(a)),this.hasColours_=!0):(b.hexColour="",console.warn('Toolbox category "'+c+'" has unrecognized colour attribute: '+a))}; +k?this.setColourFromStyle_(k,h,e):this.setColour_(l,h,e);"true"==g.getAttribute("expanded")?(h.blocks.length&&(d=h),h.setExpanded(!0)):h.setExpanded(!1);e=g;break;case "SEP":if(e&&"CATEGORY"==e.tagName.toUpperCase()){b.add(new Blockly.Toolbox.TreeSeparator(this.treeSeparatorConfig_));break}case "BLOCK":case "SHADOW":case "LABEL":case "BUTTON":b.blocks.push(g),e=g}return d}; +Blockly.Toolbox.prototype.setColour_=function(a,b,c){a=Blockly.utils.replaceMessageReferences(a);if(null===a||""===a)b.hexColour="";else{var d=Number(a);isNaN(d)?(d=Blockly.utils.colour.parse(a))?(b.hexColour=d,this.hasColours_=!0):(b.hexColour="",console.warn('Toolbox category "'+c+'" has unrecognized colour attribute: '+a)):(b.hexColour=Blockly.hueToHex(d),this.hasColours_=!0)}}; Blockly.Toolbox.prototype.setColourFromStyle_=function(a,b,c){if((b.styleName=a)&&Blockly.getTheme()){var d=Blockly.getTheme().getCategoryStyle(a);d&&d.colour?this.setColour_(d.colour,b,c):console.warn('Style "'+a+'" must exist and contain a colour value')}};Blockly.Toolbox.prototype.updateColourFromTheme_=function(a){if(a=a||this.tree_){a=a.getChildren(!1);for(var b=0,c;c=a[b];b++)c.styleName&&(this.setColourFromStyle_(c.styleName,c,""),this.addColour_()),this.updateColourFromTheme_(c)}}; Blockly.Toolbox.prototype.updateColourFromTheme=function(){var a=this.tree_;a&&(this.updateColourFromTheme_(a),this.updateSelectedItemColour_(a))};Blockly.Toolbox.prototype.updateSelectedItemColour_=function(a){var b=a.selectedItem_;if(b){var c=b.hexColour||"#57e";b.getRowElement().style.backgroundColor=c;a.toolbox_.addColour_(b)}}; -Blockly.Toolbox.prototype.addColour_=function(a){a=(a||this.tree_).getChildren(!1);for(var b=0,c;c=a[b];b++){var d=c.getRowElement();if(d){var e=this.hasColours_?"8px solid "+(c.hexColour||"#ddd"):"none";this.workspace_.RTL?d.style.borderRight=e:d.style.borderLeft=e}this.addColour_(c)}};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};Blockly.Toolbox.prototype.addStyle=function(a){Blockly.utils.addClass(this.HtmlDiv,a)}; -Blockly.Toolbox.prototype.removeStyle=function(a){Blockly.utils.removeClass(this.HtmlDiv,a)}; -Blockly.Toolbox.prototype.getClientRect=function(){if(!this.HtmlDiv)return null;var a=this.HtmlDiv.getBoundingClientRect(),b=a.left,c=a.top,d=a.width;a=a.height;return this.toolboxPosition==Blockly.TOOLBOX_AT_LEFT?new goog.math.Rect(-1E7,-1E7,1E7+b+d,2E7):this.toolboxPosition==Blockly.TOOLBOX_AT_RIGHT?new goog.math.Rect(b,-1E7,1E7+d,2E7):this.toolboxPosition==Blockly.TOOLBOX_AT_TOP?new goog.math.Rect(-1E7,-1E7,2E7,1E7+c+a):new goog.math.Rect(0,c,2E7,1E7+d)}; +Blockly.Toolbox.prototype.addColour_=function(a){a=(a||this.tree_).getChildren(!1);for(var b=0,c;c=a[b];b++){var d=c.getRowElement();if(d){var e=this.hasColours_?"8px solid "+(c.hexColour||"#ddd"):"none";this.workspace_.RTL?d.style.borderRight=e:d.style.borderLeft=e}this.addColour_(c)}};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};Blockly.Toolbox.prototype.addStyle=function(a){Blockly.utils.dom.addClass(this.HtmlDiv,a)}; +Blockly.Toolbox.prototype.removeStyle=function(a){Blockly.utils.dom.removeClass(this.HtmlDiv,a)}; +Blockly.Toolbox.prototype.getClientRect=function(){if(!this.HtmlDiv)return null;var a=this.HtmlDiv.getBoundingClientRect(),b=a.top,c=b+a.height,d=a.left;a=d+a.width;return this.toolboxPosition==Blockly.TOOLBOX_AT_TOP?new Blockly.utils.Rect(-1E7,c,-1E7,1E7):this.toolboxPosition==Blockly.TOOLBOX_AT_BOTTOM?new Blockly.utils.Rect(b,1E7,-1E7,1E7):this.toolboxPosition==Blockly.TOOLBOX_AT_LEFT?new Blockly.utils.Rect(-1E7,1E7,-1E7,a):new Blockly.utils.Rect(-1E7,1E7,d,1E7)}; Blockly.Toolbox.prototype.refreshSelection=function(){var a=this.tree_.getSelectedItem();a&&a.blocks&&this.flyout_.show(a.blocks)};Blockly.Toolbox.TreeControl=function(a,b){this.toolbox_=a;goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,b)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl); -Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);if(goog.events.BrowserFeature.TOUCH_ENABLED){var a=this.getElement();Blockly.bindEventWithChecks_(a,goog.events.EventType.TOUCHEND,this,this.handleTouchEvent_)}};Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(a){var b=this.getNodeFromEvent_(a);b&&a.type===goog.events.EventType.TOUCHEND&&setTimeout(function(){b.onClick_(a)},1)}; +Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);if(Blockly.Touch.TOUCH_ENABLED){var a=this.getElement();Blockly.bindEventWithChecks_(a,goog.events.EventType.TOUCHEND,this,this.handleTouchEvent_)}};Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(a){var b=this.getNodeFromEvent_(a);b&&a.type===goog.events.EventType.TOUCHEND&&setTimeout(function(){b.onClick_(a)},1)}; Blockly.Toolbox.TreeControl.prototype.createNode=function(a){a=a?goog.html.SafeHtml.htmlEscape(a):goog.html.SafeHtml.EMPTY;return new Blockly.Toolbox.TreeNode(this.toolbox_,a,this.getConfig())}; Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(a){var b=this.toolbox_;if(a!=this.selectedItem_&&a!=b.tree_){b.lastCategory_&&(b.lastCategory_.getRowElement().style.backgroundColor="");if(a){var c=a.hexColour||"#57e";a.getRowElement().style.backgroundColor=c;b.addColour_(a)}c=this.getSelectedItem();goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,a);a&&a.blocks&&a.blocks.length?(b.flyout_.show(a.blocks),b.lastCategory_!=a&&b.flyout_.scrollToStart()):b.flyout_.hide();c!= a&&c!=this&&(c=new Blockly.Events.Ui(null,"category",c&&c.getHtml(),a&&a.getHtml()),c.workspaceId=b.workspace_.id,Blockly.Events.fire(c));a&&(b.lastCategory_=a)}};Blockly.Toolbox.TreeNode=function(a,b,c){goog.ui.tree.TreeNode.call(this,b,c);a&&(b=function(){Blockly.svgResize(a.workspace_)},goog.events.listen(a.tree_,goog.ui.tree.BaseNode.EventType.EXPAND,b),goog.events.listen(a.tree_,goog.ui.tree.BaseNode.EventType.COLLAPSE,b))};goog.inherits(Blockly.Toolbox.TreeNode,goog.ui.tree.TreeNode); Blockly.Toolbox.TreeNode.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.create("span")};Blockly.Toolbox.TreeNode.prototype.onClick_=function(a){this.hasChildren()&&this.isUserCollapsible_?(this.toggle(),this.select()):this.isSelected()?this.getTree().setSelectedItem(null):this.select();this.updateRow()};Blockly.Toolbox.TreeNode.prototype.onMouseDown=function(a){};Blockly.Toolbox.TreeNode.prototype.onDoubleClick_=function(a){}; Blockly.Toolbox.TreeNode.prototype.onKeyDown=function(a){if(this.tree.toolbox_.horizontalLayout_){var b={},c=goog.events.KeyCodes.DOWN,d=goog.events.KeyCodes.UP;b[goog.events.KeyCodes.RIGHT]=this.rightToLeft_?d:c;b[goog.events.KeyCodes.LEFT]=this.rightToLeft_?c:d;b[goog.events.KeyCodes.UP]=goog.events.KeyCodes.LEFT;b[goog.events.KeyCodes.DOWN]=goog.events.KeyCodes.RIGHT;a.keyCode=b[a.keyCode]||a.keyCode}return Blockly.Toolbox.TreeNode.superClass_.onKeyDown.call(this,a)}; -Blockly.Toolbox.TreeSeparator=function(a){Blockly.Toolbox.TreeNode.call(this,null,goog.html.SafeHtml.EMPTY,a)};goog.inherits(Blockly.Toolbox.TreeSeparator,Blockly.Toolbox.TreeNode);Blockly.Css={};Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed",DELETE:"handdelete"};Blockly.Css.currentCursor_="";Blockly.Css.styleSheet_=null;Blockly.Css.mediaPath_=""; -Blockly.Css.inject=function(a,b){if(!Blockly.Css.styleSheet_){var c=".blocklyDraggable {}\n";a&&(c+=Blockly.Css.CONTENT.join("\n"),Blockly.FieldDate&&(c+=Blockly.FieldDate.CSS.join("\n")));Blockly.Css.mediaPath_=b.replace(/[\\\/]$/,"");c=c.replace(/<<>>/g,Blockly.Css.mediaPath_);var d=document.createElement("style");document.head.insertBefore(d,document.head.firstChild);c=document.createTextNode(c);d.appendChild(c);Blockly.Css.styleSheet_=d.sheet}};Blockly.Css.setCursor=function(a){console.warn("Deprecated call to Blockly.Css.setCursor. See https://github.com/google/blockly/issues/981 for context")}; +Blockly.Toolbox.TreeSeparator=function(a){Blockly.Toolbox.TreeNode.call(this,null,goog.html.SafeHtml.EMPTY,a)};goog.inherits(Blockly.Toolbox.TreeSeparator,Blockly.Toolbox.TreeNode);Blockly.Css={};Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed",DELETE:"handdelete"};Blockly.Css.currentCursor_="";Blockly.Css.injected_=!1;Blockly.Css.mediaPath_=""; +Blockly.Css.inject=function(a,b){if(!Blockly.Css.injected_){Blockly.Css.injected_=!0;var c=".blocklyDraggable {}\n";a&&(c+=Blockly.Css.CONTENT.join("\n"),Blockly.Css.CONTENT=null,Blockly.FieldDate&&(c+=Blockly.FieldDate.CSS.join("\n")));Blockly.Css.mediaPath_=b.replace(/[\\\/]$/,"");c=c.replace(/<<>>/g,Blockly.Css.mediaPath_);var d=document.createElement("style");c=document.createTextNode(c);d.appendChild(c);document.head.insertBefore(d,document.head.firstChild)}};Blockly.Css.setCursor=function(a){console.warn("Deprecated call to Blockly.Css.setCursor. See https://github.com/google/blockly/issues/981 for context")}; Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;","overflow: hidden;","position: absolute;","display: block;","}",".blocklyWidgetDiv {","display: none;","position: absolute;","z-index: 99999;","}",".injectionDiv {","height: 100%;","position: relative;","overflow: hidden;","touch-action: none","}",".blocklyNonSelectable {","user-select: none;","-moz-user-select: none;","-ms-user-select: none;","-webkit-user-select: none;","}",".blocklyWsDragSurface {","display: none;", "position: absolute;","top: 0;","left: 0;","}",".blocklyWsDragSurface.blocklyOverflowVisible {","overflow: visible;","}",".blocklyBlockDragSurface {","display: none;","position: absolute;","top: 0;","left: 0;","right: 0;","bottom: 0;","overflow: visible !important;","z-index: 50;","}",".blocklyBlockCanvas.blocklyCanvasTransitioning,",".blocklyBubbleCanvas.blocklyCanvasTransitioning {","transition: transform .5s;","}",".blocklyTooltipDiv {","background-color: #ffffc7;","border: 1px solid #ddc;","box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);", "color: #000;","display: none;","font-family: sans-serif;","font-size: 9pt;","opacity: .9;","padding: 2px;","position: absolute;","z-index: 100000;","}",".blocklyDropDownDiv {","position: fixed;","left: 0;","top: 0;","z-index: 1000;","display: none;","border: 1px solid;","border-radius: 2px;","padding: 4px;","-webkit-user-select: none;","}",".blocklyDropDownContent {","max-height: 300px;","overflow: auto;","overflow-x: hidden;","}",".blocklyDropDownArrow {","position: absolute;","left: 0;","top: 0;", @@ -1794,7 +1775,7 @@ Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;", "height: 100%;","margin: 0;","outline: none;","padding: 0 1px;","width: 100%","}",".blocklyMainBackground {","stroke-width: 1;","stroke: #c6c6c6;","}",".blocklyMutatorBackground {","fill: #fff;","stroke: #ddd;","stroke-width: 1;","}",".blocklyFlyoutBackground {","fill: #ddd;","fill-opacity: .8;","}",".blocklyTransparentBackground {","opacity: 0;","}",".blocklyMainWorkspaceScrollbar {","z-index: 20;","}",".blocklyFlyoutScrollbar {","z-index: 30;","}",".blocklyScrollbarHorizontal, .blocklyScrollbarVertical {", "position: absolute;","outline: none;","}",".blocklyScrollbarBackground {","opacity: 0;","}",".blocklyScrollbarHandle {","fill: #ccc;","}",".blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,",".blocklyScrollbarHandle:hover {","fill: #bbb;","}",".blocklyZoom>image, .blocklyZoom>svg>image {","opacity: .4;","}",".blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {","opacity: .6;","}",".blocklyZoom>image:active, .blocklyZoom>svg>image:active {","opacity: .8;","}",".blocklyFlyout .blocklyScrollbarHandle {", "fill: #bbb;","}",".blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,",".blocklyFlyout .blocklyScrollbarHandle:hover {","fill: #aaa;","}",".blocklyInvalidInput {","background: #faa;","}",".blocklyAngleCircle {","stroke: #444;","stroke-width: 1;","fill: #ddd;","fill-opacity: .8;","}",".blocklyAngleMarks {","stroke: #444;","stroke-width: 1;","}",".blocklyAngleGauge {","fill: #f88;","fill-opacity: .8;","}",".blocklyAngleLine {","stroke: #f00;","stroke-width: 2;","stroke-linecap: round;", -"pointer-events: none;","}",".blocklyContextMenu {","border-radius: 4px;","max-height: 100%;","}",".blocklyDropdownMenu {","padding: 0 !important;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {","background: url(<<>>/sprites.png) no-repeat -48px -16px !important;","}",".blocklyToolboxDiv {","background-color: #ddd;","overflow-x: visible;","overflow-y: auto;","position: absolute;","user-select: none;","-moz-user-select: none;", +"pointer-events: none;","}",".blocklyContextMenu {","border-radius: 4px;","max-height: 100%;","}",".blocklyDropdownMenu {","padding: 0 !important;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {","background: url(<<>>/sprites.png) no-repeat -48px -16px;","}",".blocklyToolboxDiv {","background-color: #ddd;","overflow-x: visible;","overflow-y: auto;","position: absolute;","user-select: none;","-moz-user-select: none;", "-ms-user-select: none;","-webkit-user-select: none;","z-index: 70;","-webkit-tap-highlight-color: transparent;","}",".blocklyTreeRoot {","padding: 4px 0;","}",".blocklyTreeRoot:focus {","outline: none;","}",".blocklyTreeRow {","height: 22px;","line-height: 22px;","margin-bottom: 3px;","padding-right: 8px;","white-space: nowrap;","}",".blocklyHorizontalTree {","float: left;","margin: 1px 5px 8px 0;","}",".blocklyHorizontalTreeRtl {","float: right;","margin: 1px 0 8px 5px;","}",'.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {', "margin-left: 8px;","}",".blocklyTreeRow:not(.blocklyTreeSelected):hover {","background-color: #e4e4e4;","}",".blocklyTreeSeparator {","border-bottom: solid #e5e5e5 1px;","height: 0;","margin: 5px 0;","}",".blocklyTreeSeparatorHorizontal {","border-right: solid #e5e5e5 1px;","width: 0;","padding: 5px 0;","margin: 0 5px;","}",".blocklyTreeIcon {","background-image: url(<<>>/sprites.png);","height: 16px;","vertical-align: middle;","width: 16px;","}",".blocklyTreeIconClosedLtr {","background-position: -32px -1px;", "}",".blocklyTreeIconClosedRtl {","background-position: 0 -1px;","}",".blocklyTreeIconOpen {","background-position: -16px -1px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedLtr {","background-position: -32px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedRtl {","background-position: 0 -17px;","}",".blocklyTreeSelected>.blocklyTreeIconOpen {","background-position: -16px -17px;","}",".blocklyTreeIconNone,",".blocklyTreeSelected>.blocklyTreeIconNone {","background-position: -48px -1px;", @@ -1805,42 +1786,42 @@ Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;", "color: #000;","font: normal 13px Arial, sans-serif;","}",".blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-accel, ",".blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-content, ",".blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-accel, ",".blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-content {","color: #ccc !important;","}",".blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-icon, ",".blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-icon {","opacity: 0.3;", "filter: alpha(opacity=30);","}",".blocklyWidgetDiv .goog-menuitem-highlight, ",".blocklyWidgetDiv .goog-menuitem-hover {","background-color: #d6e9f8;","border-color: #d6e9f8;","border-style: dotted;","border-width: 1px 0;","padding-bottom: 4px;","padding-top: 4px;","}",".blocklyDropDownDiv .goog-menuitem-highlight, ",".blocklyDropDownDiv .goog-menuitem-hover {","background-color: rgba(0, 0, 0, 0.2);","}",".blocklyWidgetDiv .goog-menuitem-checkbox, ",".blocklyWidgetDiv .goog-menuitem-icon, ",".blocklyDropDownDiv .goog-menuitem-checkbox, ", ".blocklyDropDownDiv .goog-menuitem-icon {","background-repeat: no-repeat;","height: 16px;","left: 6px;","position: absolute;","right: auto;","vertical-align: middle;","width: 16px;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox, ",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon, ",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-checkbox, ",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-icon {","left: auto;","right: 6px;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox, ", -".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon, ",".blocklyDropDownDiv .goog-option-selected .goog-menuitem-checkbox, ",".blocklyDropDownDiv .goog-option-selected .goog-menuitem-icon {","background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -512px 0;","position: static;","float: left;","margin-left: -24px;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox, ",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon, ",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-checkbox, ", -".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-icon {","float: right;","margin-right: -24px;","}",".blocklyWidgetDiv .goog-menuitem-accel, ",".blocklyDropDownDiv .goog-menuitem-accel {","color: #999;","direction: ltr;","left: auto;","padding: 0 6px;","position: absolute;","right: 0;","text-align: right;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-accel, ",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-accel {","left: 0;","right: auto;","text-align: left;","}",".blocklyWidgetDiv .goog-menuitem-mnemonic-hint, ", -".blocklyDropDownDiv .goog-menuitem-mnemonic-hint {","text-decoration: underline;","}",".blocklyWidgetDiv .goog-menuitem-mnemonic-separator, ",".blocklyDropDownDiv .goog-menuitem-mnemonic-separator {","color: #999;","font-size: 12px;","padding-left: 4px;","}",".blocklyWidgetDiv .goog-menuseparator, ",".blocklyDropDownDiv .goog-menuseparator {","border-top: 1px solid #ccc;","margin: 4px 0;","padding: 0;","}",""];Blockly.WidgetDiv={};Blockly.WidgetDiv.DIV=null;Blockly.WidgetDiv.owner_=null;Blockly.WidgetDiv.dispose_=null;Blockly.WidgetDiv.createDom=function(){Blockly.WidgetDiv.DIV||(Blockly.WidgetDiv.DIV=document.createElement("div"),Blockly.WidgetDiv.DIV.className="blocklyWidgetDiv",document.body.appendChild(Blockly.WidgetDiv.DIV))}; +".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon, ",".blocklyDropDownDiv .goog-option-selected .goog-menuitem-checkbox, ",".blocklyDropDownDiv .goog-option-selected .goog-menuitem-icon {","position: static;","float: left;","margin-left: -24px;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox, ",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon, ",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-checkbox, ",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-icon {", +"float: right;","margin-right: -24px;","}",".blocklyWidgetDiv .goog-menuitem-accel, ",".blocklyDropDownDiv .goog-menuitem-accel {","color: #999;","direction: ltr;","left: auto;","padding: 0 6px;","position: absolute;","right: 0;","text-align: right;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-accel, ",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-accel {","left: 0;","right: auto;","text-align: left;","}",".blocklyWidgetDiv .goog-menuitem-mnemonic-hint, ",".blocklyDropDownDiv .goog-menuitem-mnemonic-hint {", +"text-decoration: underline;","}",".blocklyWidgetDiv .goog-menuitem-mnemonic-separator, ",".blocklyDropDownDiv .goog-menuitem-mnemonic-separator {","color: #999;","font-size: 12px;","padding-left: 4px;","}",".blocklyWidgetDiv .goog-menuseparator, ",".blocklyDropDownDiv .goog-menuseparator {","border-top: 1px solid #ccc;","margin: 4px 0;","padding: 0;","}",""];Blockly.WidgetDiv={};Blockly.WidgetDiv.DIV=null;Blockly.WidgetDiv.owner_=null;Blockly.WidgetDiv.dispose_=null;Blockly.WidgetDiv.createDom=function(){Blockly.WidgetDiv.DIV||(Blockly.WidgetDiv.DIV=document.createElement("div"),Blockly.WidgetDiv.DIV.className="blocklyWidgetDiv",document.body.appendChild(Blockly.WidgetDiv.DIV))}; Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=goog.style.getViewportPageOffset(document);Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"}; Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.DIV.innerHTML="")};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()}; Blockly.WidgetDiv.positionInternal_=function(a,b,c){Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c+"px"};Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.calculateY_(a,b,c);a=Blockly.WidgetDiv.calculateX_(a,b,c,d);0>e?Blockly.WidgetDiv.positionInternal_(a,0,c.height+e):Blockly.WidgetDiv.positionInternal_(a,e,c.height)}; -Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.inject=function(a,b){Blockly.checkBlockColourConstants();"string"==typeof a&&(a=document.getElementById(a)||document.querySelector(a));if(!Blockly.utils.containsNode(document,a))throw Error("Error: container is not in current document.");var c=new Blockly.Options(b||{}),d=document.createElement("div");d.className="injectionDiv";a.appendChild(d);var e=Blockly.createDom_(d,c),f=new Blockly.BlockDragSurfaceSvg(d);d=new Blockly.WorkspaceDragSurfaceSvg(d);e=Blockly.createMainWorkspace_(e,c,f,d); -Blockly.setTheme(c.theme);Blockly.init_(e);Blockly.mainWorkspace=e;Blockly.svgResize(e);return e}; -Blockly.createDom_=function(a,b){a.setAttribute("dir","LTR");goog.ui.Component.setDefaultRightToLeft(b.RTL);Blockly.Css.inject(b.hasCss,b.pathToMedia);var c=Blockly.utils.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1","class":"blocklySvg"},a),d=Blockly.utils.createSvgElement("defs",{},c),e=String(Math.random()).substring(2),f=Blockly.utils.createSvgElement("filter",{id:"blocklyEmbossFilter"+ -e},d);Blockly.utils.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:1,result:"blur"},f);var g=Blockly.utils.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},f);Blockly.utils.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},g);Blockly.utils.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},f);Blockly.utils.createSvgElement("feComposite", -{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},f);b.embossFilterId=f.id;f=Blockly.utils.createSvgElement("pattern",{id:"blocklyDisabledPattern"+e,patternUnits:"userSpaceOnUse",width:10,height:10},d);Blockly.utils.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},f);Blockly.utils.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},f);b.disabledPatternId=f.id;b.gridPattern=Blockly.Grid.createDom(e,b.gridOptions,d);return c}; -Blockly.createMainWorkspace_=function(a,b,c,d){b.parentWorkspace=null;var e=new Blockly.WorkspaceSvg(b,c,d);e.scale=b.zoomOptions.startScale;a.appendChild(e.createDom("blocklyMainBackground"));!b.hasCategories&&b.languageTree&&(c=e.addFlyout_("svg"),Blockly.utils.insertAfter(c,a));b.hasTrashcan&&e.addTrashcan();b.zoomOptions&&b.zoomOptions.controls&&e.addZoomControls();e.translate(0,0);Blockly.mainWorkspace=e;b.readOnly||e.isMovable()||e.addChangeListener(function(a){if(!e.isDragging()&&!e.isMovable()&& --1!=Blockly.Events.BUMP_EVENTS.indexOf(a.type)){var b=Object.create(null),c=e.getMetrics(),d=e.scale;b.viewLeft=c.viewLeft/d;b.viewTop=c.viewTop/d;b.viewRight=(c.viewLeft+c.viewWidth)/d;b.viewBottom=(c.viewTop+c.viewHeight)/d;e.isContentBounded()?(c=e.getBlocksBoundingBox(),b.contentLeft=c.x,b.contentTop=c.y,b.contentRight=c.x+c.width,b.contentBottom=c.y+c.height):(b.contentLeft=c.contentLeft/d,b.contentTop=c.contentTop/d,b.contentRight=(c.contentLeft+c.contentWidth)/d,b.contentBottom=(c.contentTop+ -c.contentHeight)/d);if(b.contentTopb.viewBottom||b.contentLeftb.viewRight){c=null;a&&(c=Blockly.Events.getGroup(),Blockly.Events.setGroup(a.group));switch(a.type){case Blockly.Events.BLOCK_CREATE:case Blockly.Events.BLOCK_MOVE:var f=e.getBlockById(a.blockId);break;case Blockly.Events.COMMENT_CREATE:case Blockly.Events.COMMENT_MOVE:f=e.getCommentById(a.commentId)}if(f){d=f.getBoundingRectangle();var n=b.viewTop-d.topLeft.y;0n&&f.moveBy(0,n);n=b.viewLeft-d.topLeft.x;0b&&f.moveBy(b,0)}a&&(a.group||console.log("WARNING: Moved object in bounds but there was no event group. This may break undo."),Blockly.Events.setGroup(c))}}});Blockly.svgResize(e);Blockly.WidgetDiv.createDom();Blockly.DropDownDiv.createDom();Blockly.Tooltip.createDom();return e}; +Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.inject=function(a,b){Blockly.checkBlockColourConstants();"string"==typeof a&&(a=document.getElementById(a)||document.querySelector(a));if(!Blockly.utils.dom.containsNode(document,a))throw Error("Error: container is not in current document.");var c=new Blockly.Options(b||{}),d=document.createElement("div");d.className="injectionDiv";a.appendChild(d);var e=Blockly.createDom_(d,c),f=new Blockly.BlockDragSurfaceSvg(d);d=new Blockly.WorkspaceDragSurfaceSvg(d);e=Blockly.createMainWorkspace_(e,c, +f,d);Blockly.setTheme(c.theme);Blockly.init_(e);Blockly.mainWorkspace=e;Blockly.svgResize(e);return e}; +Blockly.createDom_=function(a,b){a.setAttribute("dir","LTR");goog.ui.Component.setDefaultRightToLeft(b.RTL);Blockly.Css.inject(b.hasCss,b.pathToMedia);var c=Blockly.utils.dom.createSvgElement("svg",{xmlns:Blockly.utils.dom.SVG_NS,"xmlns:html":Blockly.utils.dom.HTML_NS,"xmlns:xlink":Blockly.utils.dom.XLINK_NS,version:"1.1","class":"blocklySvg"},a),d=Blockly.utils.dom.createSvgElement("defs",{},c),e=String(Math.random()).substring(2),f=Blockly.utils.dom.createSvgElement("filter",{id:"blocklyEmbossFilter"+ +e},d);Blockly.utils.dom.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:1,result:"blur"},f);var g=Blockly.utils.dom.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},f);Blockly.utils.dom.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},g);Blockly.utils.dom.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},f);Blockly.utils.dom.createSvgElement("feComposite", +{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},f);b.embossFilterId=f.id;f=Blockly.utils.dom.createSvgElement("pattern",{id:"blocklyDisabledPattern"+e,patternUnits:"userSpaceOnUse",width:10,height:10},d);Blockly.utils.dom.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},f);Blockly.utils.dom.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},f);b.disabledPatternId=f.id;b.gridPattern=Blockly.Grid.createDom(e,b.gridOptions,d);return c}; +Blockly.createMainWorkspace_=function(a,b,c,d){b.parentWorkspace=null;var e=new Blockly.WorkspaceSvg(b,c,d);e.scale=b.zoomOptions.startScale;a.appendChild(e.createDom("blocklyMainBackground"));!b.hasCategories&&b.languageTree&&(c=e.addFlyout_("svg"),Blockly.utils.dom.insertAfter(c,a));b.hasTrashcan&&e.addTrashcan();b.zoomOptions&&b.zoomOptions.controls&&e.addZoomControls();e.translate(0,0);Blockly.mainWorkspace=e;b.readOnly||e.isMovable()||e.addChangeListener(function(a){if(!e.isDragging()&&!e.isMovable()&& +-1!=Blockly.Events.BUMP_EVENTS.indexOf(a.type)){var b=Object.create(null),c=e.getMetrics(),d=e.scale;b.viewLeft=c.viewLeft/d;b.viewTop=c.viewTop/d;b.viewRight=(c.viewLeft+c.viewWidth)/d;b.viewBottom=(c.viewTop+c.viewHeight)/d;e.isContentBounded()?(c=e.getBlocksBoundingBox(),b.contentLeft=c.left,b.contentTop=c.top,b.contentRight=c.right,b.contentBottom=c.bottom):(b.contentLeft=c.contentLeft/d,b.contentTop=c.contentTop/d,b.contentRight=(c.contentLeft+c.contentWidth)/d,b.contentBottom=(c.contentTop+ +c.contentHeight)/d);if(b.contentTopb.viewBottom||b.contentLeftb.viewRight){c=null;a&&(c=Blockly.Events.getGroup(),Blockly.Events.setGroup(a.group));switch(a.type){case Blockly.Events.BLOCK_CREATE:case Blockly.Events.BLOCK_MOVE:var f=e.getBlockById(a.blockId);f=f.getRootBlock();break;case Blockly.Events.COMMENT_CREATE:case Blockly.Events.COMMENT_MOVE:f=e.getCommentById(a.commentId)}if(f){d=f.getBoundingRectangle();var n=b.viewTop-d.top;0n&&f.moveBy(0,n);n=b.viewLeft-d.left;0b&&f.moveBy(b,0)}a&&(a.group||console.log("WARNING: Moved object in bounds but there was no event group. This may break undo."),Blockly.Events.setGroup(c))}}});Blockly.svgResize(e);Blockly.WidgetDiv.createDom();Blockly.DropDownDiv.createDom();Blockly.Tooltip.createDom();return e}; Blockly.init_=function(a){var b=a.options,c=a.getParentSvg();Blockly.bindEventWithChecks_(c.parentNode,"contextmenu",null,function(a){Blockly.utils.isTargetInput(a)||a.preventDefault()});c=Blockly.bindEventWithChecks_(window,"resize",null,function(){Blockly.hideChaff(!0);Blockly.svgResize(a)});a.setResizeHandlerWrapper(c);Blockly.inject.bindDocumentEvents_();b.languageTree&&(a.toolbox_?a.toolbox_.init(a):a.flyout_&&(a.flyout_.init(a),a.flyout_.show(b.languageTree.childNodes),a.flyout_.scrollToStart())); c=Blockly.Scrollbar.scrollbarThickness;b.hasTrashcan&&(c=a.trashcan.init(c));b.zoomOptions&&b.zoomOptions.controls&&a.zoomControls_.init(c);b.moveOptions&&b.moveOptions.scrollbars?(a.scrollbar=new Blockly.ScrollbarPair(a),a.scrollbar.resize()):a.setMetrics({x:.5,y:.5});b.hasSounds&&Blockly.inject.loadSounds_(b.pathToMedia,a)}; -Blockly.inject.bindDocumentEvents_=function(){Blockly.documentEventsBound_||(Blockly.bindEventWithChecks_(document,"scroll",null,function(){for(var a=Blockly.Workspace.getAll(),b=0,c;c=a[b];b++)c.updateInverseScreenCTM&&c.updateInverseScreenCTM()}),Blockly.bindEventWithChecks_(document,"keydown",null,Blockly.onKeyDown_),Blockly.bindEvent_(document,"touchend",null,Blockly.longStop_),Blockly.bindEvent_(document,"touchcancel",null,Blockly.longStop_),goog.userAgent.IPAD&&Blockly.bindEventWithChecks_(window, +Blockly.inject.bindDocumentEvents_=function(){Blockly.documentEventsBound_||(Blockly.bindEventWithChecks_(document,"scroll",null,function(){for(var a=Blockly.Workspace.getAll(),b=0,c;c=a[b];b++)c.updateInverseScreenCTM&&c.updateInverseScreenCTM()}),Blockly.bindEventWithChecks_(document,"keydown",null,Blockly.onKeyDown_),Blockly.bindEvent_(document,"touchend",null,Blockly.longStop_),Blockly.bindEvent_(document,"touchcancel",null,Blockly.longStop_),Blockly.utils.userAgent.IPAD&&Blockly.bindEventWithChecks_(window, "orientationchange",document,function(){Blockly.svgResize(Blockly.getMainWorkspace())}));Blockly.documentEventsBound_=!0}; Blockly.inject.loadSounds_=function(a,b){var c=b.getAudioManager();c.load([a+"click.mp3",a+"click.wav",a+"click.ogg"],"click");c.load([a+"disconnect.wav",a+"disconnect.mp3",a+"disconnect.ogg"],"disconnect");c.load([a+"delete.mp3",a+"delete.ogg",a+"delete.wav"],"delete");var d=[],e=function(){for(;d.length;)Blockly.unbindEvent_(d.pop());c.preload()};d.push(Blockly.bindEventWithChecks_(document,"mousemove",null,e,!0));d.push(Blockly.bindEventWithChecks_(document,"touchstart",null,e,!0))}; -Blockly.updateToolbox=function(a){console.warn("Deprecated call to Blockly.updateToolbox, use workspace.updateToolbox instead.");Blockly.getMainWorkspace().updateToolbox(a)};var CLOSURE_DEFINES={"goog.DEBUG":!1};Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.theme_=null;Blockly.hueToRgb=function(a){return goog.color.hsvToHex(a,Blockly.HSV_SATURATION,255*Blockly.HSV_VALUE)};Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; +Blockly.updateToolbox=function(a){console.warn("Deprecated call to Blockly.updateToolbox, use workspace.updateToolbox instead.");Blockly.getMainWorkspace().updateToolbox(a)};var CLOSURE_DEFINES={"goog.DEBUG":!1};Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.theme_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth;c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}}; Blockly.onKeyDown_=function(a){var b=Blockly.mainWorkspace;if(!(b.options.readOnly||Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible())){var c=!1;if(27==a.keyCode)Blockly.hideChaff();else if(8==a.keyCode||46==a.keyCode){a.preventDefault();if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&& -(67==a.keyCode?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):88!=a.keyCode||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));86==a.keyCode?Blockly.clipboardXml_&&(b=Blockly.clipboardSource_,b.isFlyout&&(b=b.targetWorkspace),Blockly.clipboardTypeCounts_&&b.isCapacityAvailable(Blockly.clipboardTypeCounts_)&&(Blockly.Events.setGroup(!0),b.paste(Blockly.clipboardXml_),Blockly.Events.setGroup(!1))):90==a.keyCode&&(Blockly.hideChaff(),b.undo(a.shiftKey))}c&&!Blockly.selected.workspace.isFlyout&& -(Blockly.Events.setGroup(!0),Blockly.hideChaff(),Blockly.selected.dispose(!0,!0),Blockly.Events.setGroup(!1))}};Blockly.copy_=function(a){if(a.isComment)var b=a.toXmlWithXY();else{b=Blockly.Xml.blockToDom(a);Blockly.Xml.deleteNext(b);var c=a.getRelativeToSurfaceXY();b.setAttribute("x",a.RTL?-c.x:c.x);b.setAttribute("y",c.y)}Blockly.clipboardXml_=b;Blockly.clipboardSource_=a.workspace;Blockly.clipboardTypeCounts_=a.isComment?null:Blockly.utils.getBlockTypeCounts(a,!0)}; +(67==a.keyCode?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):88!=a.keyCode||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));86==a.keyCode?Blockly.clipboardXml_&&(a=Blockly.clipboardSource_,a.isFlyout&&(a=a.targetWorkspace),Blockly.clipboardTypeCounts_&&a.isCapacityAvailable(Blockly.clipboardTypeCounts_)&&(Blockly.Events.setGroup(!0),a.paste(Blockly.clipboardXml_),Blockly.Events.setGroup(!1))):90==a.keyCode&&(Blockly.hideChaff(),b.undo(a.shiftKey))}c&&!Blockly.selected.workspace.isFlyout&& +(Blockly.Events.setGroup(!0),Blockly.hideChaff(),Blockly.selected.dispose(!0,!0),Blockly.Events.setGroup(!1))}};Blockly.copy_=function(a){if(a.isComment)var b=a.toXmlWithXY();else{b=Blockly.Xml.blockToDom(a,!0);Blockly.Xml.deleteNext(b);var c=a.getRelativeToSurfaceXY();b.setAttribute("x",a.RTL?-c.x:c.x);b.setAttribute("y",c.y)}Blockly.clipboardXml_=b;Blockly.clipboardSource_=a.workspace;Blockly.clipboardTypeCounts_=a.isComment?null:Blockly.utils.getBlockTypeCounts(a,!0)}; Blockly.duplicate_=function(a){var b=Blockly.clipboardXml_,c=Blockly.clipboardSource_;Blockly.copy_(a);a.workspace.paste(Blockly.clipboardXml_);Blockly.clipboardXml_=b;Blockly.clipboardSource_=c};Blockly.onContextMenu_=function(a){Blockly.utils.isTargetInput(a)||a.preventDefault()}; Blockly.hideChaff=function(a){Blockly.Tooltip.hide();Blockly.WidgetDiv.hide();Blockly.DropDownDiv.hideWithoutAnimation();var b=Blockly.getMainWorkspace();b.trashcan&&b.trashcan.flyout_&&b.trashcan.flyout_.hide();a||b.toolbox_&&b.toolbox_.flyout_&&b.toolbox_.flyout_.autoClose&&b.toolbox_.clearSelection()};Blockly.addChangeListener=function(a){console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead.");return Blockly.getMainWorkspace().addChangeListener(a)}; -Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace};Blockly.alert=function(a,b){window.alert(a);b&&b()};Blockly.confirm=function(a,b){b(window.confirm(a))};Blockly.prompt=function(a,b,c){c(window.prompt(a,b))};Blockly.jsonInitFactory_=function(a){return function(){this.jsonInit(a)}}; +Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace};Blockly.alert=function(a,b){alert(a);b&&b()};Blockly.confirm=function(a,b){b(confirm(a))};Blockly.prompt=function(a,b,c){c(prompt(a,b))};Blockly.jsonInitFactory_=function(a){return function(){this.jsonInit(a)}}; Blockly.defineBlocksWithJsonArray=function(a){for(var b=0;b + * + * + * arg1_name + * etc... + * + * + * + */ - // Check/uncheck the allow statement box. - if (this.getInput('RETURN')) { - containerBlock.setFieldValue( - this.hasStatements_ ? 'TRUE' : 'FALSE', 'STATEMENTS'); - } else { - containerBlock.getInput('STATEMENT_INPUT').setVisible(false); - } + var containerBlockNode = Blockly.utils.xml.createElement('block'); + containerBlockNode.setAttribute('type', 'procedures_mutatorcontainer'); + var statementNode = Blockly.utils.xml.createElement('statement'); + statementNode.setAttribute('name', 'STACK'); + containerBlockNode.appendChild(statementNode); - // Parameter list. - var connection = containerBlock.getInput('STACK').connection; + var node = statementNode; for (var i = 0; i < this.arguments_.length; i++) { - var paramBlock = workspace.newBlock('procedures_mutatorarg'); - paramBlock.initSvg(); - paramBlock.setFieldValue(this.arguments_[i], 'NAME'); - // Store the old location. - paramBlock.oldLocation = i; - connection.connect(paramBlock.previousConnection); - connection = paramBlock.nextConnection; + var argBlockNode = Blockly.utils.xml.createElement('block'); + argBlockNode.setAttribute('type', 'procedures_mutatorarg'); + var fieldNode = Blockly.utils.xml.createElement('field'); + fieldNode.setAttribute('name', 'NAME'); + var argumentName = Blockly.utils.xml.createTextNode(this.arguments_[i]); + fieldNode.appendChild(argumentName); + argBlockNode.appendChild(fieldNode); + var nextNode = Blockly.utils.xml.createElement('next'); + argBlockNode.appendChild(nextNode); + + node.appendChild(argBlockNode); + node = nextNode; + } + + var containerBlock = Blockly.Xml.domToBlock(containerBlockNode, workspace); + + if (this.type == 'procedures_defreturn') { + containerBlock.setFieldValue(this.hasStatements_, 'STATEMENTS'); + } else { + containerBlock.removeInput('STATEMENT_INPUT'); } + // Initialize procedure's callers with blank IDs. Blockly.Procedures.mutateCallers(this); return containerBlock; @@ -205,11 +225,7 @@ Blockly.Blocks['procedures_defnoreturn'] = { var varName = paramBlock.getFieldValue('NAME'); this.arguments_.push(varName); var variable = this.workspace.getVariable(varName, ''); - if (variable != null) { - this.argumentVarModels_.push(variable); - } else { - console.log('Failed to get variable named ' + varName + ', ignoring.'); - } + this.argumentVarModels_.push(variable); this.paramIds_.push(paramBlock.id); paramBlock = paramBlock.nextConnection && @@ -349,21 +365,21 @@ Blockly.Blocks['procedures_defnoreturn'] = { * @this Blockly.Block */ customContextMenu: function(options) { - if (this.isInFlyout){ + if (this.isInFlyout) { return; } // Add option to create caller. var option = {enabled: true}; var name = this.getFieldValue('NAME'); option.text = Blockly.Msg['PROCEDURES_CREATE_DO'].replace('%1', name); - var xmlMutation = document.createElement('mutation'); + var xmlMutation = Blockly.utils.xml.createElement('mutation'); xmlMutation.setAttribute('name', name); for (var i = 0; i < this.arguments_.length; i++) { - var xmlArg = document.createElement('arg'); + var xmlArg = Blockly.utils.xml.createElement('arg'); xmlArg.setAttribute('name', this.arguments_[i]); xmlMutation.appendChild(xmlArg); } - var xmlBlock = document.createElement('block'); + var xmlBlock = Blockly.utils.xml.createElement('block'); xmlBlock.setAttribute('type', this.callType_); xmlBlock.appendChild(xmlMutation); option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock); @@ -372,17 +388,18 @@ Blockly.Blocks['procedures_defnoreturn'] = { // Add options to create getters for each parameter. if (!this.isCollapsed()) { for (var i = 0; i < this.argumentVarModels_.length; i++) { - var option = {enabled: true}; + var argOption = {enabled: true}; var argVar = this.argumentVarModels_[i]; - var name = argVar.name; - option.text = Blockly.Msg['VARIABLES_SET_CREATE_GET'].replace('%1', name); + argOption.text = Blockly.Msg['VARIABLES_SET_CREATE_GET'] + .replace('%1', argVar.name); - var xmlField = Blockly.Variables.generateVariableFieldDom(argVar); - var xmlBlock = document.createElement('block'); - xmlBlock.setAttribute('type', 'variables_get'); - xmlBlock.appendChild(xmlField); - option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock); - options.push(option); + var argXmlField = Blockly.Variables.generateVariableFieldDom(argVar); + var argXmlBlock = Blockly.utils.xml.createElement('block'); + argXmlBlock.setAttribute('type', 'variables_get'); + argXmlBlock.appendChild(argXmlField); + argOption.callback = + Blockly.ContextMenu.callbackFactory(this, argXmlBlock); + options.push(argOption); } } }, @@ -489,7 +506,7 @@ Blockly.Blocks['procedures_mutatorcontainer'] = { } return; } - + if (event.type != Blockly.Events.BLOCK_CREATE) { return; } @@ -526,7 +543,6 @@ Blockly.Blocks['procedures_mutatorcontainer'] = { } }; - Blockly.Blocks['procedures_mutatorarg'] = { /** * Mutator block for procedure argument. @@ -572,15 +588,15 @@ Blockly.Blocks['procedures_mutatorarg'] = { * @this Blockly.FieldTextInput */ validator_: function(varName) { - var outerWs = Blockly.Mutator.findParentWs(this.sourceBlock_.workspace); + var outerWs = Blockly.Mutator.findParentWs(this.getSourceBlock().workspace); varName = varName.replace(/[\s\xa0]+/g, ' ').replace(/^ | $/g, ''); if (!varName) { return null; } // Prevents duplicate parameter names in functions - var blocks = this.sourceBlock_.workspace.getAllBlocks(); + var blocks = this.getSourceBlock().workspace.getAllBlocks(); for (var i = 0; i < blocks.length; i += 1) { - if (blocks[i].id == this.sourceBlock_.id) { + if (blocks[i].id == this.getSourceBlock().id) { continue; } if (blocks[i].getFieldValue('NAME') == varName) { @@ -590,6 +606,7 @@ Blockly.Blocks['procedures_mutatorarg'] = { var model = outerWs.getVariable(varName, ''); if (model && model.name != varName) { // Rename the variable (case change) + // TODO: This function doesn't exist on the workspace. outerWs.renameVarById(model.getId(), varName); } if (!model) { @@ -609,7 +626,7 @@ Blockly.Blocks['procedures_mutatorarg'] = { * @this Blockly.FieldTextInput */ deleteIntermediateVars_: function(newText) { - var outerWs = Blockly.Mutator.findParentWs(this.sourceBlock_.workspace); + var outerWs = Blockly.Mutator.findParentWs(this.getSourceBlock().workspace); if (!outerWs) { return; } @@ -639,7 +656,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { this.argumentVarModels_ = []; this.quarkConnections_ = {}; this.quarkIds_ = null; - this.previousDisabledState_ = false; + this.previousEnabledState_ = true; }, /** @@ -815,10 +832,10 @@ Blockly.Blocks['procedures_callnoreturn'] = { * @this Blockly.Block */ mutationToDom: function() { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('name', this.getProcedureCall()); for (var i = 0; i < this.arguments_.length; i++) { - var parameter = document.createElement('arg'); + var parameter = Blockly.utils.xml.createElement('arg'); parameter.setAttribute('name', this.arguments_[i]); container.appendChild(parameter); } @@ -881,7 +898,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { Blockly.Events.setGroup(event.group); /** * Create matching definition block. - * + * * * * @@ -890,8 +907,8 @@ Blockly.Blocks['procedures_callnoreturn'] = { * * */ - var xml = document.createElement('xml'); - var block = document.createElement('block'); + var xml = Blockly.utils.xml.createElement('xml'); + var block = Blockly.utils.xml.createElement('block'); block.setAttribute('type', this.defType_); var xy = this.getRelativeToSurfaceXY(); var x = xy.x + Blockly.SNAP_RADIUS * (this.RTL ? -1 : 1); @@ -900,9 +917,10 @@ Blockly.Blocks['procedures_callnoreturn'] = { block.setAttribute('y', y); var mutation = this.mutationToDom(); block.appendChild(mutation); - var field = document.createElement('field'); + var field = Blockly.utils.xml.createElement('field'); field.setAttribute('name', 'NAME'); - field.appendChild(document.createTextNode(this.getProcedureCall())); + field.appendChild(Blockly.utils.xml.createTextNode( + this.getProcedureCall())); block.appendChild(field); xml.appendChild(block); Blockly.Xml.domToWorkspace(xml, this.workspace); @@ -933,10 +951,10 @@ Blockly.Blocks['procedures_callnoreturn'] = { } Blockly.Events.setGroup(event.group); if (event.newValue) { - this.previousDisabledState_ = this.disabled; - this.setDisabled(true); + this.previousEnabledState_ = this.isEnabled(); + this.setEnabled(false); } else { - this.setDisabled(this.previousDisabledState_); + this.setEnabled(this.previousEnabledState_); } Blockly.Events.setGroup(oldGroup); } @@ -985,7 +1003,7 @@ Blockly.Blocks['procedures_callreturn'] = { this.arguments_ = []; this.quarkConnections_ = {}; this.quarkIds_ = null; - this.previousDisabledState_ = false; + this.previousEnabledState_ = true; }, getProcedureCall: Blockly.Blocks['procedures_callnoreturn'].getProcedureCall, @@ -1027,7 +1045,7 @@ Blockly.Blocks['procedures_ifreturn'] = { * @this Blockly.Block */ mutationToDom: function() { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('value', Number(this.hasReturnValue_)); return container; }, @@ -1048,10 +1066,10 @@ Blockly.Blocks['procedures_ifreturn'] = { /** * Called whenever anything on the workspace changes. * Add warning if this flow block is not nested inside a loop. - * @param {!Blockly.Events.Abstract} e Change event. + * @param {!Blockly.Events.Abstract} _e Change event. * @this Blockly.Block */ - onchange: function(/* e */) { + onchange: function(_e) { if (!this.workspace.isDragging || this.workspace.isDragging()) { return; // Don't change state at the start of a drag. } @@ -1081,12 +1099,12 @@ Blockly.Blocks['procedures_ifreturn'] = { } this.setWarningText(null); if (!this.isInFlyout) { - this.setDisabled(false); + this.setEnabled(true); } } else { this.setWarningText(Blockly.Msg['PROCEDURES_IFRETURN_WARNING']); if (!this.isInFlyout && !this.getInheritedDisabled()) { - this.setDisabled(true); + this.setEnabled(false); } } }, diff --git a/blocks/text.js b/blocks/text.js index b98bd54bef6..554c3e4dd47 100644 --- a/blocks/text.js +++ b/blocks/text.js @@ -243,7 +243,7 @@ Blockly.Blocks['text_getSubstring'] = { * @this Blockly.Block */ mutationToDom: function() { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); var isAt1 = this.getInput('AT1').type == Blockly.INPUT_VALUE; container.setAttribute('at1', isAt1); var isAt2 = this.getInput('AT2').type == Blockly.INPUT_VALUE; @@ -296,7 +296,7 @@ Blockly.Blocks['text_getSubstring'] = { // The 'isAt' variable is available due to this function being a // closure. if (newAt != isAt) { - var block = this.sourceBlock_; + var block = this.getSourceBlock(); block.updateAt_(n, newAt); // This menu has been destroyed and replaced. // Update the replacement. @@ -423,7 +423,7 @@ Blockly.Blocks['text_prompt_ext'] = { * @this Blockly.Block */ mutationToDom: function() { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('type', this.getFieldValue('TYPE')); return container; }, @@ -660,7 +660,7 @@ Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN = { * @this Blockly.Block */ mutationToDom: function() { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('items', this.itemCount_); return container; }, @@ -810,7 +810,7 @@ Blockly.Constants.Text.TEXT_CHARAT_MUTATOR_MIXIN = { * @this Blockly.Block */ mutationToDom: function() { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('at', !!this.isAt_); return container; }, @@ -862,13 +862,9 @@ Blockly.Constants.Text.TEXT_CHARAT_EXTENSION = function() { dropdown.setValidator(function(value) { var newAt = (value == 'FROM_START') || (value == 'FROM_END'); if (newAt != this.isAt_) { - var block = this.sourceBlock_; + var block = this.getSourceBlock(); block.updateAt_(newAt); - // This menu has been destroyed and replaced. Update the replacement. - block.setFieldValue(value, 'WHERE'); - return null; } - return undefined; }); this.updateAt_(true); // Assign 'this' to a variable for use in the tooltip closure below. diff --git a/blocks/variables.js b/blocks/variables.js index 4ea1d1b07e2..af040e7d132 100644 --- a/blocks/variables.js +++ b/blocks/variables.js @@ -100,7 +100,7 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = { * @this Blockly.Block */ customContextMenu: function(options) { - if (!this.isInFlyout){ + if (!this.isInFlyout) { // Getter blocks have the option to create a setter block, and vice versa. if (this.type == 'variables_get') { var opposite_type = 'variables_set'; @@ -113,17 +113,17 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = { var option = {enabled: this.workspace.remainingCapacity() > 0}; var name = this.getField('VAR').getText(); option.text = contextMenuMsg.replace('%1', name); - var xmlField = document.createElement('field'); + var xmlField = Blockly.utils.xml.createElement('field'); xmlField.setAttribute('name', 'VAR'); - xmlField.appendChild(document.createTextNode(name)); - var xmlBlock = document.createElement('block'); + xmlField.appendChild(Blockly.utils.xml.createTextNode(name)); + var xmlBlock = Blockly.utils.xml.createElement('block'); xmlBlock.setAttribute('type', opposite_type); xmlBlock.appendChild(xmlField); option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock); options.push(option); // Getter blocks have the option to rename or delete that variable. } else { - if (this.type == 'variables_get' || this.type == 'variables_get_reporter'){ + if (this.type == 'variables_get' || this.type == 'variables_get_reporter') { var renameOption = { text: Blockly.Msg.RENAME_VARIABLE, enabled: true, diff --git a/blocks/variables_dynamic.js b/blocks/variables_dynamic.js index 03b34c2cb34..80ec8d512ff 100644 --- a/blocks/variables_dynamic.js +++ b/blocks/variables_dynamic.js @@ -114,11 +114,11 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI var option = {enabled: this.workspace.remainingCapacity() > 0}; var name = this.getField('VAR').getText(); option.text = contextMenuMsg.replace('%1', name); - var xmlField = document.createElement('field'); + var xmlField = Blockly.utils.xml.createElement('field'); xmlField.setAttribute('name', 'VAR'); xmlField.setAttribute('variabletype', varType); - xmlField.appendChild(document.createTextNode(name)); - var xmlBlock = document.createElement('block'); + xmlField.appendChild(Blockly.utils.xml.createTextNode(name)); + var xmlBlock = Blockly.utils.xml.createElement('block'); xmlBlock.setAttribute('type', opposite_type); xmlBlock.appendChild(xmlField); option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock); @@ -142,9 +142,15 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI } } }, - onchange: function() { + /** + * Called whenever anything on the workspace changes. + * Set the connection type for this block. + * @param {!Blockly.Events.Abstract} _e Change event. + * @this Blockly.Block + */ + onchange: function(_e) { var id = this.getFieldValue('VAR'); - var variableModel = this.workspace.getVariableById(id); + var variableModel = Blockly.Variables.getVariable(this.workspace, id); if (this.type == 'variables_get_dynamic') { this.outputConnection.setCheck(variableModel.type); } else { diff --git a/blocks_compressed.js b/blocks_compressed.js index a91594e2a8b..8b463ab84e0 100644 --- a/blocks_compressed.js +++ b/blocks_compressed.js @@ -9,7 +9,7 @@ align:"RIGHT"},{type:"input_value",name:"COLOUR2",check:"Colour",align:"RIGHT"}, Blockly.defineBlocksWithJsonArray([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse", message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}", args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]); -Blockly.Blocks.lists_create_with={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);this.setStyle("list_blocks");this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new Blockly.Mutator(["lists_create_with_item"]));this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"), +Blockly.Blocks.lists_create_with={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);this.setStyle("list_blocks");this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new Blockly.Mutator(["lists_create_with_item"]));this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"), 10);this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d","GT"],["\u200f\u2265","GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare", @@ -48,12 +48,12 @@ args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",toolti Blockly.defineBlocksWithJsonArray([{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null, enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]);Blockly.Constants.Logic.TOOLTIPS_BY_OP={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"}; Blockly.Extensions.register("logic_op_tooltip",Blockly.Extensions.buildTooltipForDropdown("OP",Blockly.Constants.Logic.TOOLTIPS_BY_OP)); -Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var a=document.createElement("mutation");this.elseifCount_&&a.setAttribute("elseif",this.elseifCount_);this.elseCount_&&a.setAttribute("else",1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||0;this.rebuildShape_()},decompose:function(a){var b= -a.newBlock("controls_if_if");b.initSvg();for(var c=b.nextConnection,d=1;d<=this.elseifCount_;d++){var e=a.newBlock("controls_if_elseif");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},compose:function(a){a=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;for(var b=[null],c=[null],d=null;a;){switch(a.type){case "controls_if_elseif":this.elseifCount_++;b.push(a.valueConnection_); -c.push(a.statementConnection_);break;case "controls_if_else":this.elseCount_++;d=a.statementConnection_;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}this.updateShape_();this.reconnectChildBlocks_(b,c,d)},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;a.statementConnection_= -d&&d.connection.targetConnection;b++;break;case "controls_if_else":d=this.getInput("ELSE");a.statementConnection_=d&&d.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}},rebuildShape_:function(){var a=[null],b=[null],c=null;this.getInput("ELSE")&&(c=this.getInput("ELSE").connection.targetConnection);for(var d=1;this.getInput("IF"+d);){var e=this.getInput("IF"+d),f=this.getInput("DO"+d);a.push(e.connection.targetConnection); -b.push(f.connection.targetConnection);d++}this.updateShape_();this.reconnectChildBlocks_(a,b,c)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);)this.removeInput("IF"+a),this.removeInput("DO"+a),a++;for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)}, -reconnectChildBlocks_:function(a,b,c){for(var d=1;d<=this.elseifCount_;d++)Blockly.Mutator.reconnect(a[d],this,"IF"+d),Blockly.Mutator.reconnect(b[d],this,"DO"+d);Blockly.Mutator.reconnect(c,this,"ELSE")}};Blockly.Extensions.registerMutator("controls_if_mutator",Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,null,["controls_if_elseif","controls_if_else"]); +Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN={elseifCount_:0,elseCount_:0,suppressPrefixSuffix:!0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var a=Blockly.utils.xml.createElement("mutation");this.elseifCount_&&a.setAttribute("elseif",this.elseifCount_);this.elseCount_&&a.setAttribute("else",1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||0;this.rebuildShape_()}, +decompose:function(a){var b=a.newBlock("controls_if_if");b.initSvg();for(var c=b.nextConnection,d=1;d<=this.elseifCount_;d++){var e=a.newBlock("controls_if_elseif");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},compose:function(a){a=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;for(var b=[null],c=[null],d=null;a;){switch(a.type){case "controls_if_elseif":this.elseifCount_++; +b.push(a.valueConnection_);c.push(a.statementConnection_);break;case "controls_if_else":this.elseCount_++;d=a.statementConnection_;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}this.updateShape_();this.reconnectChildBlocks_(b,c,d)},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection; +a.statementConnection_=d&&d.connection.targetConnection;b++;break;case "controls_if_else":d=this.getInput("ELSE");a.statementConnection_=d&&d.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}},rebuildShape_:function(){var a=[null],b=[null],c=null;this.getInput("ELSE")&&(c=this.getInput("ELSE").connection.targetConnection);for(var d=1;this.getInput("IF"+d);){var e=this.getInput("IF"+d),f=this.getInput("DO"+ +d);a.push(e.connection.targetConnection);b.push(f.connection.targetConnection);d++}this.updateShape_();this.reconnectChildBlocks_(a,b,c)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);)this.removeInput("IF"+a),this.removeInput("DO"+a),a++;for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN); +this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(a,b,c){for(var d=1;d<=this.elseifCount_;d++)Blockly.Mutator.reconnect(a[d],this,"IF"+d),Blockly.Mutator.reconnect(b[d],this,"DO"+d);Blockly.Mutator.reconnect(c,this,"ELSE")}};Blockly.Extensions.registerMutator("controls_if_mutator",Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,null,["controls_if_elseif","controls_if_else"]); Blockly.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION=function(){this.setTooltip(function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_4}else return Blockly.Msg.CONTROLS_IF_TOOLTIP_1;return""}.bind(this))};Blockly.Extensions.register("controls_if_tooltip",Blockly.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION); Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN={onchange:function(a){this.prevBlocks_||(this.prevBlocks_=[null,null]);var b=this.getInputTargetBlock("A"),c=this.getInputTargetBlock("B");b&&c&&!b.outputConnection.checkType_(c.outputConnection)&&(Blockly.Events.setGroup(a.group),a=this.prevBlocks_[0],a!==b&&(b.unplug(),a&&!a.isShadow()&&this.getInput("A").connection.connect(a.outputConnection)),b=this.prevBlocks_[1],b!==c&&(c.unplug(),b&&!b.isShadow()&&this.getInput("B").connection.connect(b.outputConnection)), this.bumpNeighbours_(),Blockly.Events.setGroup(!1));this.prevBlocks_[0]=this.getInputTargetBlock("A");this.prevBlocks_[1]=this.getInputTargetBlock("B")}};Blockly.Constants.Logic.LOGIC_COMPARE_EXTENSION=function(){this.mixin(Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN)};Blockly.Extensions.register("logic_compare",Blockly.Constants.Logic.LOGIC_COMPARE_EXTENSION); @@ -66,10 +66,10 @@ check:"Number",align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",arg args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOREACH_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_forEach_tooltip"]},{type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}","CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}", extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]);Blockly.Constants.Loops.WHILE_UNTIL_TOOLTIPS={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};Blockly.Extensions.register("controls_whileUntil_tooltip",Blockly.Extensions.buildTooltipForDropdown("MODE",Blockly.Constants.Loops.WHILE_UNTIL_TOOLTIPS));Blockly.Constants.Loops.BREAK_CONTINUE_TOOLTIPS={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"}; Blockly.Extensions.register("controls_flow_tooltip",Blockly.Extensions.buildTooltipForDropdown("FLOW",Blockly.Constants.Loops.BREAK_CONTINUE_TOOLTIPS)); -Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getField("VAR").getVariable(),c=b.name;if(!this.isCollapsed()&&null!=c){var d={enabled:!0};d.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);b=Blockly.Variables.generateVariableFieldDom(b);c=document.createElement("block");c.setAttribute("type","variables_get");c.appendChild(b);d.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(d)}}}}; +Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getField("VAR").getVariable(),c=b.name;if(!this.isCollapsed()&&null!=c){var d={enabled:!0};d.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);b=Blockly.Variables.generateVariableFieldDom(b);c=Blockly.utils.xml.createElement("block");c.setAttribute("type","variables_get");c.appendChild(b);d.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(d)}}}}; Blockly.Extensions.registerMixin("contextMenu_newGetVariableBlock",Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN);Blockly.Extensions.register("controls_for_tooltip",Blockly.Extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR"));Blockly.Extensions.register("controls_forEach_tooltip",Blockly.Extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR")); -Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN={LOOP_TYPES:["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"],onchange:function(){if(this.workspace.isDragging&&!this.workspace.isDragging()){var a=!1,b=this;do{if(-1!=this.LOOP_TYPES.indexOf(b.type)){a=!0;break}b=b.getSurroundParent()}while(b);a?(this.setWarningText(null),this.isInFlyout||this.setDisabled(!1)):(this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING),this.isInFlyout|| -this.getInheritedDisabled()||this.setDisabled(!0))}}};Blockly.Extensions.registerMixin("controls_flow_in_loop_check",Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN);Blockly.Blocks.math={};Blockly.Constants.Math={};Blockly.Constants.Math.HUE=230; +Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN={LOOP_TYPES:["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"],suppressPrefixSuffix:!0,getSurroundLoop:function(a){do{if(-1!=Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.LOOP_TYPES.indexOf(a.type))return a;a=a.getSurroundParent()}while(a);return null},onchange:function(a){this.workspace.isDragging&&!this.workspace.isDragging()&&(Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.getSurroundLoop(this)? +(this.setWarningText(null),this.isInFlyout||this.setEnabled(!0)):(this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING),this.isInFlyout||this.getInheritedDisabled()||this.setEnabled(!1)))}};Blockly.Extensions.registerMixin("controls_flow_in_loop_check",Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN);Blockly.Blocks.math={};Blockly.Constants.Math={};Blockly.Constants.Math.HUE=230; Blockly.defineBlocksWithJsonArray([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD"],["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}", "MULTIPLY"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE"],["%{BKY_MATH_POWER_SYMBOL}","POWER"]]},{type:"input_value",name:"B",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}","ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]}, {type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN"],["%{BKY_MATH_TRIG_COS}","COS"],["%{BKY_MATH_TRIG_TAN}","TAN"],["%{BKY_MATH_TRIG_ASIN}","ASIN"],["%{BKY_MATH_TRIG_ACOS}","ACOS"],["%{BKY_MATH_TRIG_ATAN}","ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks", @@ -84,21 +84,22 @@ name:"Y",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",to Blockly.Constants.Math.TOOLTIPS_BY_OP={ADD:"%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",MINUS:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}",MULTIPLY:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}",DIVIDE:"%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}",POWER:"%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}",ROOT:"%{BKY_MATH_SINGLE_TOOLTIP_ROOT}",ABS:"%{BKY_MATH_SINGLE_TOOLTIP_ABS}",NEG:"%{BKY_MATH_SINGLE_TOOLTIP_NEG}",LN:"%{BKY_MATH_SINGLE_TOOLTIP_LN}",LOG10:"%{BKY_MATH_SINGLE_TOOLTIP_LOG10}",EXP:"%{BKY_MATH_SINGLE_TOOLTIP_EXP}",POW10:"%{BKY_MATH_SINGLE_TOOLTIP_POW10}", SIN:"%{BKY_MATH_TRIG_TOOLTIP_SIN}",COS:"%{BKY_MATH_TRIG_TOOLTIP_COS}",TAN:"%{BKY_MATH_TRIG_TOOLTIP_TAN}",ASIN:"%{BKY_MATH_TRIG_TOOLTIP_ASIN}",ACOS:"%{BKY_MATH_TRIG_TOOLTIP_ACOS}",ATAN:"%{BKY_MATH_TRIG_TOOLTIP_ATAN}",SUM:"%{BKY_MATH_ONLIST_TOOLTIP_SUM}",MIN:"%{BKY_MATH_ONLIST_TOOLTIP_MIN}",MAX:"%{BKY_MATH_ONLIST_TOOLTIP_MAX}",AVERAGE:"%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",MEDIAN:"%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",MODE:"%{BKY_MATH_ONLIST_TOOLTIP_MODE}",STD_DEV:"%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"}; Blockly.Extensions.register("math_op_tooltip",Blockly.Extensions.buildTooltipForDropdown("OP",Blockly.Constants.Math.TOOLTIPS_BY_OP)); -Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN={mutationToDom:function(){var a=document.createElement("mutation"),b="DIVISIBLE_BY"==this.getFieldValue("PROPERTY");a.setAttribute("divisor_input",b);return a},domToMutation:function(a){a="true"==a.getAttribute("divisor_input");this.updateShape_(a)},updateShape_:function(a){var b=this.getInput("DIVISOR");a?b||this.appendValueInput("DIVISOR").setCheck("Number"):b&&this.removeInput("DIVISOR")}}; -Blockly.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION=function(){this.getField("PROPERTY").setValidator(function(a){this.sourceBlock_.updateShape_("DIVISIBLE_BY"==a)})};Blockly.Extensions.registerMutator("math_is_divisibleby_mutator",Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN,Blockly.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION);Blockly.Extensions.register("math_change_tooltip",Blockly.Extensions.buildTooltipWithFieldText("%{BKY_MATH_CHANGE_TOOLTIP}","VAR")); -Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN={updateType_:function(a){"MODE"==a?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("op",this.getFieldValue("OP"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("op"))}};Blockly.Constants.Math.LIST_MODES_MUTATOR_EXTENSION=function(){this.getField("OP").setValidator(function(a){this.updateType_(a)}.bind(this))}; +Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN={mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation"),b="DIVISIBLE_BY"==this.getFieldValue("PROPERTY");a.setAttribute("divisor_input",b);return a},domToMutation:function(a){a="true"==a.getAttribute("divisor_input");this.updateShape_(a)},updateShape_:function(a){var b=this.getInput("DIVISOR");a?b||this.appendValueInput("DIVISOR").setCheck("Number"):b&&this.removeInput("DIVISOR")}}; +Blockly.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION=function(){this.getField("PROPERTY").setValidator(function(a){a="DIVISIBLE_BY"==a;this.getSourceBlock().updateShape_(a)})};Blockly.Extensions.registerMutator("math_is_divisibleby_mutator",Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN,Blockly.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION);Blockly.Extensions.register("math_change_tooltip",Blockly.Extensions.buildTooltipWithFieldText("%{BKY_MATH_CHANGE_TOOLTIP}","VAR")); +Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN={updateType_:function(a){"MODE"==a?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("op",this.getFieldValue("OP"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("op"))}};Blockly.Constants.Math.LIST_MODES_MUTATOR_EXTENSION=function(){this.getField("OP").setValidator(function(a){this.updateType_(a)}.bind(this))}; Blockly.Extensions.registerMutator("math_modes_of_list_mutator",Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN,Blockly.Constants.Math.LIST_MODES_MUTATOR_EXTENSION);Blockly.Blocks.procedures={}; Blockly.Blocks.procedures_defnoreturn={init:function(){var a=new Blockly.FieldTextInput("",Blockly.Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT); this.setStyle("procedure_blocks");this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_= -a)},updateParams_:function(){var a="";this.arguments_.length&&(a=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));Blockly.Events.disable();try{this.setFieldValue(a,"PARAMS")}finally{Blockly.Events.enable()}},mutationToDom:function(a){var b=document.createElement("mutation");a&&b.setAttribute("name",this.getFieldValue("NAME"));for(var c=0;c +# Usage: build.py <0 or more of core, generators, langfiles> # build.py with no parameters builds all files. # core builds blockly_compressed, blockly_uncompressed, and blocks_compressed. -# accessible builds blockly_accessible_compressed, -# blockly_accessible_uncompressed, and blocks_compressed. # generators builds every _compressed.js. # langfiles builds every msg/js/.js file. -# This script generates four versions of Blockly's core files. The first pair -# are: +# This script generates two versions of Blockly's core files: # blockly_compressed.js # blockly_uncompressed.js # The compressed file is a concatenation of all of Blockly's core files which @@ -37,11 +34,6 @@ # been renamed. The uncompressed file also allows for a faster development # cycle since there is no need to rebuild or recompile, just reload. # -# The second pair are: -# blockly_accessible_compressed.js -# blockly_accessible_uncompressed.js -# These files are analogous to blockly_compressed and blockly_uncompressed, -# but also include the visually-impaired module for Blockly. # # This script also generates: # blocks_compressed.js: The compressed Blockly language blocks. @@ -60,7 +52,7 @@ arg != 'generators' and arg != 'langfiles'): raise Exception("Invalid argument: \"" + arg + "\". Usage: build.py " - "<0 or more of accessible, core, generators, langfiles>") + "<0 or more of core, generators, langfiles>") import errno, glob, json, os, re, subprocess, threading, codecs @@ -153,7 +145,7 @@ def run(self): # used on another, even if the directory name differs. m = re.search('[\\/]([^\\/]+)[\\/]core[\\/]blockly.js', add_dependency) add_dependency = re.sub('([\\/])' + re.escape(m.group(1)) + - '([\\/](core|accessible)[\\/])', '\\1" + dir + "\\2', add_dependency) + '([\\/](core)[\\/])', '\\1" + dir + "\\2', add_dependency) f.write(add_dependency + '\n') provides = [] @@ -204,9 +196,10 @@ def run(self): self.gen_core() if ('accessible' in self.bundles): - self.gen_accessible() + print("The Blockly accessibility demo has moved to https://github.com/google/blockly-experimental") + return - if ('core' in self.bundles or 'accessible' in self.bundles): + if ('core' in self.bundles): self.gen_blocks() if ('generators' in self.bundles): @@ -244,35 +237,6 @@ def gen_core(self): self.do_compile(params, target_filename, filenames, "") - def gen_accessible(self): - target_filename = "blockly_accessible_compressed.js" - # Define the parameters for the POST request. - params = [ - ("compilation_level", "SIMPLE_OPTIMIZATIONS"), - ("use_closure_library", "true"), - ("language_out", "ES5"), - ("output_format", "json"), - ("output_info", "compiled_code"), - ("output_info", "warnings"), - ("output_info", "errors"), - ("output_info", "statistics"), - ("warning_level", "DEFAULT"), - ] - - # Read in all the source files. - filenames = calcdeps.CalculateDependencies(self.search_paths, - [os.path.join("accessible", "app.component.js")]) - filenames.sort() # Deterministic build. - for filename in filenames: - # Filter out the Closure files (the compiler will add them). - if filename.startswith(os.pardir + os.sep): # '../' - continue - f = codecs.open(filename, encoding="utf-8") - params.append(("js_code", "".join(f.readlines()).encode("utf-8"))) - f.close() - - self.do_compile(params, target_filename, filenames, "") - def gen_blocks(self): target_filename = "blocks_compressed.js" # Define the parameters for the POST request. @@ -314,8 +278,9 @@ def gen_generator(self, language): ] # Read in all the source files. - # Add Blockly.Generator to be compatible with the compiler. - params.append(("js_code", "goog.provide('Blockly.Generator');")) + # Add Blockly.Generator and Blockly.utils.string to be compatible + # with the compiler. + params.append(("js_code", "goog.provide('Blockly.Generator');goog.provide('Blockly.utils.string');")) filenames = glob.glob( os.path.join("generators", language, "*.js")) filenames.sort() # Deterministic build. @@ -326,8 +291,9 @@ def gen_generator(self, language): f.close() filenames.insert(0, "[goog.provide]") - # Remove Blockly.Generator to be compatible with Blockly. - remove = "var Blockly={Generator:{}};" + # Remove Blockly.Generator and Blockly.utils.string to be compatible + # with Blockly. + remove = "var Blockly={Generator:{},utils:{}};Blockly.utils.string={};" self.do_compile(params, target_filename, filenames, remove) def do_compile(self, params, target_filename, filenames, remove): @@ -390,29 +356,7 @@ def file_lookup(name): code = HEADER + "\n" + json_data["compiledCode"] code = code.replace(remove, "") - - # Trim down Google's (and only Google's) Apache licences. - # The Closure Compiler preserves these. - LICENSE = re.compile("""/\\* - - [\w ]+ - - Copyright \\d+ Google Inc. - https://developers.google.com/blockly/ - - Licensed under the Apache License, Version 2.0 \(the "License"\); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -\\*/""") - code = re.sub(LICENSE, "", code) + code = self.trim_licence(code) stats = json_data["statistics"] original_b = stats["originalSize"] @@ -431,6 +375,40 @@ def file_lookup(name): else: print("UNKNOWN ERROR") + def trim_licence(self, code): + """Strip out Google's and MIT's Apache licences. + + JS Compiler preserves dozens of Apache licences in the Blockly code. + Remove these if they belong to Google or MIT. + MIT's permission to do this is logged in Blockly issue 2412. + + Args: + code: Large blob of compiled source code. + + Returns: + Code with Google's and MIT's Apache licences trimmed. + """ + apache2 = re.compile("""/\\* + + [\\w: ]+ + + (Copyright \\d+ (Google Inc.|Massachusetts Institute of Technology)) + (https://developers.google.com/blockly/|All rights reserved.) + + Licensed under the Apache License, Version 2.0 \\(the "License"\\); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +\\*/""") + return re.sub(apache2, "", code) + class Gen_langfiles(threading.Thread): """Generate JavaScript file for each natural language supported. @@ -538,11 +516,11 @@ def run(self): ["core", os.path.join(os.path.pardir, "closure-library")]) core_search_paths = sorted(core_search_paths) # Deterministic build. full_search_paths = calcdeps.ExpandDirectories( - ["accessible", "core", os.path.join(os.path.pardir, "closure-library")]) + ["core", os.path.join(os.path.pardir, "closure-library")]) full_search_paths = sorted(full_search_paths) # Deterministic build. if (len(sys.argv) == 1): - args = ['core', 'accessible', 'generators', 'defaultlangfiles'] + args = ['core', 'generators', 'defaultlangfiles'] else: args = sys.argv @@ -551,9 +529,6 @@ def run(self): if ('core' in args): Gen_uncompressed(core_search_paths, 'blockly_uncompressed.js').start() - if ('accessible' in args): - Gen_uncompressed(full_search_paths, 'blockly_accessible_uncompressed.js').start() - # Compressed is limited by network and server speed. Gen_compressed(full_search_paths, args).start() diff --git a/core/block.js b/core/block.js index 53587615cc0..35b5443def5 100644 --- a/core/block.js +++ b/core/block.js @@ -29,6 +29,7 @@ goog.provide('Blockly.Block'); goog.require('Blockly.Blocks'); goog.require('Blockly.Comment'); goog.require('Blockly.Connection'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Events.BlockCreate'); goog.require('Blockly.Events.BlockDelete'); @@ -37,11 +38,11 @@ goog.require('Blockly.Extensions'); goog.require('Blockly.Input'); goog.require('Blockly.Mutator'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.string'); goog.require('Blockly.Warning'); goog.require('Blockly.Workspace'); -goog.require('goog.math.Coordinate'); - /** * Class for one block. @@ -75,7 +76,10 @@ Blockly.Block = function(workspace, prototypeName, opt_id) { this.inputList = []; /** @type {boolean|undefined} */ this.inputsInline = undefined; - /** @type {boolean} */ + /** + * @type {boolean} + * @private + */ this.disabled = false; /** @type {string|!Function} */ this.tooltip = ''; @@ -130,10 +134,10 @@ Blockly.Block = function(workspace, prototypeName, opt_id) { /** * The block's position in workspace units. (0, 0) is at the workspace's * origin; scale does not change this value. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @private */ - this.xy_ = new goog.math.Coordinate(0, 0); + this.xy_ = new Blockly.utils.Coordinate(0, 0); /** @type {!Blockly.Workspace} */ this.workspace = workspace; @@ -260,7 +264,6 @@ Blockly.Block.prototype.colourTertiary_ = null; */ Blockly.Block.prototype.styleName_ = null; - /** * Dispose of this block. * @param {boolean} healStack If true, then try to heal any gap by connecting @@ -878,6 +881,44 @@ Blockly.Block.prototype.getColourTertiary = function() { return this.colourTertiary_; }; +/** + * Get the shadow colour of a block. + * @return {?string} #RRGGBB string. + */ +Blockly.Block.prototype.getColourShadow = function() { + var colourSecondary = this.getColourSecondary(); + if (colourSecondary) { + return colourSecondary; + } + return Blockly.utils.colour.blend('white', this.getColour(), 0.6); +}; + +/** + * Get the border colour(s) of a block. + * @return {{colourDark, colourLight, colourBorder}} An object containing + * colour values for the border(s) of the block. If the block is using a + * style the colourBorder will be defined and equal to the tertiary colour + * of the style (#RRGGBB string). Otherwise the colourDark and colourLight + * attributes will be defined (#RRGGBB strings). + * @package + */ +Blockly.Block.prototype.getColourBorder = function() { + var colourTertiary = this.getColourTertiary(); + if (colourTertiary) { + return { + colourBorder: colourTertiary, + colourLight: null, + colourDark: null + }; + } + var colour = this.getColour(); + return { + colourBorder: null, + colourLight: Blockly.utils.colour.blend('white',colour, 0.3), + colourDark: Blockly.utils.colour.blend('black', colour, 0.2) + }; +}; + /** * Get the name of the block style. * @return {?string} Name of the block style. @@ -887,8 +928,8 @@ Blockly.Block.prototype.getStyleName = function() { }; /** - * Get the HSV hue value of a block. Null if hue not set. - * @return {?number} Hue value (0-360) + * Get the HSV hue value of a block. Null if hue not set. + * @return {?number} Hue value (0-360). */ Blockly.Block.prototype.getHue = function() { return this.hue_; @@ -906,18 +947,20 @@ Blockly.Block.prototype.setColour = function(colour) { var hue = Number(dereferenced); if (!isNaN(hue) && 0 <= hue && hue <= 360) { this.hue_ = hue; - this.colour_ = Blockly.hueToRgb(hue); - } else if ((typeof dereferenced == 'string') && - /^#[0-9a-fA-F]{6}$/.test(dereferenced)) { - this.colour_ = dereferenced; - // Only store hue if colour is set as a hue. - this.hue_ = null; + this.colour_ = Blockly.hueToHex(hue); } else { - var errorMsg = 'Invalid colour: "' + dereferenced + '"'; - if (colour != dereferenced) { - errorMsg += ' (from "' + colour + '")'; + var hex = Blockly.utils.colour.parse(dereferenced); + if (hex) { + this.colour_ = hex; + // Only store hue if colour is set as a hue. + this.hue_ = null; + } else { + var errorMsg = 'Invalid colour: "' + dereferenced + '"'; + if (colour != dereferenced) { + errorMsg += ' (from "' + colour + '")'; + } + throw Error(errorMsg); } - throw Error(errorMsg); } }; @@ -1217,12 +1260,31 @@ Blockly.Block.prototype.getInputsInline = function() { /** * Set whether the block is disabled or not. * @param {boolean} disabled True if disabled. + * @deprecated May 2019 */ Blockly.Block.prototype.setDisabled = function(disabled) { - if (this.disabled != disabled) { + console.warn('Deprecated call to Blockly.Block.prototype.setDisabled, ' + + 'use Blockly.Block.prototype.setEnabled instead.'); + this.setEnabled(!disabled); +}; + +/** + * Get whether this block is enabled or not. + * @return {boolean} True if enabled. + */ +Blockly.Block.prototype.isEnabled = function() { + return !this.disabled; +}; + +/** + * Set whether the block is enabled or not. + * @param {boolean} enabled True if enabled. + */ +Blockly.Block.prototype.setEnabled = function(enabled) { + if (this.isEnabled() != enabled) { Blockly.Events.fire(new Blockly.Events.BlockChange( - this, 'disabled', null, this.disabled, disabled)); - this.disabled = disabled; + this, 'disabled', null, this.disabled, !enabled)); + this.disabled = !enabled; } }; @@ -1529,7 +1591,7 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) { } // Add last dummy input if needed. if (elements.length && (typeof elements[elements.length - 1] == 'string' || - Blockly.utils.startsWith( + Blockly.utils.string.startsWith( elements[elements.length - 1]['type'], 'field_'))) { var dummyInput = {type: 'input_dummy'}; if (lastDummyAlign) { @@ -1784,7 +1846,7 @@ Blockly.Block.prototype.setMutator = function(_mutator) { /** * Return the coordinates of the top-left corner of this block relative to the * drawing surface's origin (0,0), in workspace units. - * @return {!goog.math.Coordinate} Object with .x and .y properties. + * @return {!Blockly.utils.Coordinate} Object with .x and .y properties. */ Blockly.Block.prototype.getRelativeToSurfaceXY = function() { return this.xy_; diff --git a/core/block_animations.js b/core/block_animations.js index d4ad8048f29..e6006f9d3de 100644 --- a/core/block_animations.js +++ b/core/block_animations.js @@ -24,9 +24,9 @@ */ 'use strict'; -goog.provide('Blockly.BlockAnimations'); +goog.provide('Blockly.blockAnimations'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); /** @@ -34,21 +34,21 @@ goog.require('Blockly.utils'); * @type {number} * @private */ -Blockly.BlockAnimations.disconnectPid_ = 0; +Blockly.blockAnimations.disconnectPid_ = 0; /** * SVG group of wobbling block. There can only be one at a time. * @type {Element} * @private */ -Blockly.BlockAnimations.disconnectGroup_ = null; +Blockly.blockAnimations.disconnectGroup_ = null; /** * Play some UI effects (sound, animation) when disposing of a block. * @param {!Blockly.BlockSvg} block The block being disposed of. * @package */ -Blockly.BlockAnimations.disposeUiEffect = function(block) { +Blockly.blockAnimations.disposeUiEffect = function(block) { var workspace = block.workspace; var svgGroup = block.getSvgRoot(); workspace.getAudioManager().play('delete'); @@ -62,7 +62,7 @@ Blockly.BlockAnimations.disposeUiEffect = function(block) { workspace.getParentSvg().appendChild(clone); clone.bBox_ = clone.getBBox(); // Start the animation. - Blockly.BlockAnimations.disposeUiStep_(clone, workspace.RTL, new Date, + Blockly.blockAnimations.disposeUiStep_(clone, workspace.RTL, new Date, workspace.scale); }; @@ -76,12 +76,12 @@ Blockly.BlockAnimations.disposeUiEffect = function(block) { * @param {number} workspaceScale Scale of workspace. * @private */ -Blockly.BlockAnimations.disposeUiStep_ = function(clone, rtl, start, +Blockly.blockAnimations.disposeUiStep_ = function(clone, rtl, start, workspaceScale) { var ms = new Date - start; var percent = ms / 150; if (percent > 1) { - Blockly.utils.removeNode(clone); + Blockly.utils.dom.removeNode(clone); } else { var x = clone.translateX_ + (rtl ? -1 : 1) * clone.bBox_.width * workspaceScale / 2 * percent; @@ -89,7 +89,7 @@ Blockly.BlockAnimations.disposeUiStep_ = function(clone, rtl, start, var scale = (1 - percent) * workspaceScale; clone.setAttribute('transform', 'translate(' + x + ',' + y + ')' + ' scale(' + scale + ')'); - setTimeout(Blockly.BlockAnimations.disposeUiStep_, 10, clone, rtl, start, + setTimeout(Blockly.blockAnimations.disposeUiStep_, 10, clone, rtl, start, workspaceScale); } }; @@ -99,7 +99,7 @@ Blockly.BlockAnimations.disposeUiStep_ = function(clone, rtl, start, * @param {!Blockly.BlockSvg} block The block being connected. * @package */ -Blockly.BlockAnimations.connectionUiEffect = function(block) { +Blockly.blockAnimations.connectionUiEffect = function(block) { var workspace = block.workspace; var scale = workspace.scale; workspace.getAudioManager().play('click'); @@ -116,7 +116,7 @@ Blockly.BlockAnimations.connectionUiEffect = function(block) { xy.x += (block.RTL ? -23 : 23) * scale; xy.y += 3 * scale; } - var ripple = Blockly.utils.createSvgElement('circle', + var ripple = Blockly.utils.dom.createSvgElement('circle', { 'cx': xy.x, 'cy': xy.y, @@ -127,7 +127,7 @@ Blockly.BlockAnimations.connectionUiEffect = function(block) { }, workspace.getParentSvg()); // Start the animation. - Blockly.BlockAnimations.connectionUiStep_(ripple, new Date, scale); + Blockly.blockAnimations.connectionUiStep_(ripple, new Date, scale); }; /** @@ -137,16 +137,16 @@ Blockly.BlockAnimations.connectionUiEffect = function(block) { * @param {number} scale Scale of workspace. * @private */ -Blockly.BlockAnimations.connectionUiStep_ = function(ripple, start, scale) { +Blockly.blockAnimations.connectionUiStep_ = function(ripple, start, scale) { var ms = new Date - start; var percent = ms / 150; if (percent > 1) { - Blockly.utils.removeNode(ripple); + Blockly.utils.dom.removeNode(ripple); } else { ripple.setAttribute('r', percent * 25 * scale); ripple.style.opacity = 1 - percent; - Blockly.BlockAnimations.disconnectPid_ = setTimeout( - Blockly.BlockAnimations.connectionUiStep_, 10, ripple, start, scale); + Blockly.blockAnimations.disconnectPid_ = setTimeout( + Blockly.blockAnimations.connectionUiStep_, 10, ripple, start, scale); } }; @@ -155,7 +155,7 @@ Blockly.BlockAnimations.connectionUiStep_ = function(ripple, start, scale) { * @param {!Blockly.BlockSvg} block The block being disconnected. * @package */ -Blockly.BlockAnimations.disconnectUiEffect = function(block) { +Blockly.blockAnimations.disconnectUiEffect = function(block) { block.workspace.getAudioManager().play('disconnect'); if (block.workspace.scale < 1) { return; // Too small to care about visual effects. @@ -169,7 +169,7 @@ Blockly.BlockAnimations.disconnectUiEffect = function(block) { magnitude *= -1; } // Start the animation. - Blockly.BlockAnimations.disconnectUiStep_( + Blockly.blockAnimations.disconnectUiStep_( block.getSvgRoot(), magnitude, new Date); }; /** @@ -179,7 +179,7 @@ Blockly.BlockAnimations.disconnectUiEffect = function(block) { * @param {!Date} start Date of animation's start. * @private */ -Blockly.BlockAnimations.disconnectUiStep_ = function(group, magnitude, start) { +Blockly.blockAnimations.disconnectUiStep_ = function(group, magnitude, start) { var DURATION = 200; // Milliseconds. var WIGGLES = 3; // Half oscillations. @@ -192,9 +192,9 @@ Blockly.BlockAnimations.disconnectUiStep_ = function(group, magnitude, start) { var skew = Math.round( Math.sin(percent * Math.PI * WIGGLES) * (1 - percent) * magnitude); group.skew_ = 'skewX(' + skew + ')'; - Blockly.BlockAnimations.disconnectGroup_ = group; - Blockly.BlockAnimations.disconnectPid_ = - setTimeout(Blockly.BlockAnimations.disconnectUiStep_, 10, group, + Blockly.blockAnimations.disconnectGroup_ = group; + Blockly.blockAnimations.disconnectPid_ = + setTimeout(Blockly.blockAnimations.disconnectUiStep_, 10, group, magnitude, start); } group.setAttribute('transform', group.translate_ + group.skew_); @@ -204,12 +204,12 @@ Blockly.BlockAnimations.disconnectUiStep_ = function(group, magnitude, start) { * Stop the disconnect UI animation immediately. * @package */ -Blockly.BlockAnimations.disconnectUiStop = function() { - if (Blockly.BlockAnimations.disconnectGroup_) { - clearTimeout(Blockly.BlockAnimations.disconnectPid_); - var group = Blockly.BlockAnimations.disconnectGroup_; +Blockly.blockAnimations.disconnectUiStop = function() { + if (Blockly.blockAnimations.disconnectGroup_) { + clearTimeout(Blockly.blockAnimations.disconnectPid_); + var group = Blockly.blockAnimations.disconnectGroup_; group.skew_ = ''; group.setAttribute('transform', group.translate_); - Blockly.BlockAnimations.disconnectGroup_ = null; + Blockly.blockAnimations.disconnectGroup_ = null; } }; diff --git a/core/block_drag_surface.js b/core/block_drag_surface.js index 0592e92cfc2..d80924d9024 100644 --- a/core/block_drag_surface.js +++ b/core/block_drag_surface.js @@ -31,7 +31,8 @@ goog.provide('Blockly.BlockDragSurfaceSvg'); goog.require('Blockly.utils'); -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); /** @@ -83,7 +84,7 @@ Blockly.BlockDragSurfaceSvg.prototype.scale_ = 1; * Cached value for the translation of the drag surface. * This translation is in pixel units, because the scale is applied to the * drag group rather than the top-level SVG. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @private */ Blockly.BlockDragSurfaceSvg.prototype.surfaceXY_ = null; @@ -95,14 +96,14 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom = function() { if (this.SVG_) { return; // Already created. } - this.SVG_ = Blockly.utils.createSvgElement('svg', { - 'xmlns': Blockly.SVG_NS, - 'xmlns:html': Blockly.HTML_NS, - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + this.SVG_ = Blockly.utils.dom.createSvgElement('svg', { + 'xmlns': Blockly.utils.dom.SVG_NS, + 'xmlns:html': Blockly.utils.dom.HTML_NS, + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'class': 'blocklyBlockDragSurface' }, this.container_); - this.dragGroup_ = Blockly.utils.createSvgElement('g', {}, this.SVG_); + this.dragGroup_ = Blockly.utils.dom.createSvgElement('g', {}, this.SVG_); }; /** @@ -118,7 +119,7 @@ Blockly.BlockDragSurfaceSvg.prototype.setBlocksAndShow = function(blocks) { // appendChild removes the blocks from the previous parent this.dragGroup_.appendChild(blocks); this.SVG_.style.display = 'block'; - this.surfaceXY_ = new goog.math.Coordinate(0, 0); + this.surfaceXY_ = new Blockly.utils.Coordinate(0, 0); }; /** @@ -152,7 +153,7 @@ Blockly.BlockDragSurfaceSvg.prototype.translateSurfaceInternal_ = function() { y = y.toFixed(0); this.SVG_.style.display = 'block'; - Blockly.utils.setCssTransform(this.SVG_, + Blockly.utils.dom.setCssTransform(this.SVG_, 'translate3d(' + x + 'px, ' + y + 'px, 0px)'); }; @@ -165,18 +166,18 @@ Blockly.BlockDragSurfaceSvg.prototype.translateSurfaceInternal_ = function() { * @param {number} y Y translation for the entire surface. */ Blockly.BlockDragSurfaceSvg.prototype.translateSurface = function(x, y) { - this.surfaceXY_ = new goog.math.Coordinate(x * this.scale_, y * this.scale_); + this.surfaceXY_ = new Blockly.utils.Coordinate(x * this.scale_, y * this.scale_); this.translateSurfaceInternal_(); }; /** * Reports the surface translation in scaled workspace coordinates. * Use this when finishing a drag to return blocks to the correct position. - * @return {!goog.math.Coordinate} Current translation of the surface. + * @return {!Blockly.utils.Coordinate} Current translation of the surface. */ Blockly.BlockDragSurfaceSvg.prototype.getSurfaceTranslation = function() { var xy = Blockly.utils.getRelativeXY(this.SVG_); - return new goog.math.Coordinate(xy.x / this.scale_, xy.y / this.scale_); + return new Blockly.utils.Coordinate(xy.x / this.scale_, xy.y / this.scale_); }; /** diff --git a/core/block_dragger.js b/core/block_dragger.js index 9ba2e63ebc2..fa6bc723d29 100644 --- a/core/block_dragger.js +++ b/core/block_dragger.js @@ -26,11 +26,11 @@ goog.provide('Blockly.BlockDragger'); -goog.require('Blockly.BlockAnimations'); -goog.require('Blockly.InsertionMarkerManager'); +goog.require('Blockly.blockAnimations'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockMove'); - -goog.require('goog.math.Coordinate'); +goog.require('Blockly.InsertionMarkerManager'); +goog.require('Blockly.utils.Coordinate'); /** @@ -82,7 +82,7 @@ Blockly.BlockDragger = function(block, workspace) { /** * The location of the top left corner of the dragging block at the beginning * of the drag in workspace coordinates. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @private */ this.startXY_ = this.draggingBlock_.getRelativeToSurfaceXY(); @@ -129,7 +129,7 @@ Blockly.BlockDragger.initIconData_ = function(block) { var icons = descendant.getIcons(); for (var j = 0; j < icons.length; j++) { var data = { - // goog.math.Coordinate with x and y properties (workspace coordinates). + // Blockly.utils.Coordinate with x and y properties (workspace coordinates). location: icons[j].getIconLocation(), // Blockly.Icon icon: icons[j] @@ -142,7 +142,7 @@ Blockly.BlockDragger.initIconData_ = function(block) { /** * Start dragging a block. This includes moving it to the drag surface. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at mouse down, in pixel units. * @param {boolean} healStack Whether or not to heal the stack after * disconnecting. @@ -166,17 +166,17 @@ Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY, // Turn the cache on so we don't do spurious remeasures during the drag. Blockly.Field.startCache(); this.workspace_.setResizesEnabled(false); - Blockly.BlockAnimations.disconnectUiStop(); + Blockly.blockAnimations.disconnectUiStop(); if (this.draggingBlock_.getParent() || (healStack && this.draggingBlock_.nextConnection && this.draggingBlock_.nextConnection.targetBlock())) { this.draggingBlock_.unplug(healStack); var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); - var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); + var newLoc = Blockly.utils.Coordinate.sum(this.startXY_, delta); this.draggingBlock_.translate(newLoc.x, newLoc.y); - Blockly.BlockAnimations.disconnectUiEffect(this.draggingBlock_); + Blockly.blockAnimations.disconnectUiEffect(this.draggingBlock_); } this.draggingBlock_.setDragging(true); // For future consideration: we may be able to put moveToDragSurface inside @@ -196,13 +196,13 @@ Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY, * Execute a step of block dragging, based on the given event. Update the * display accordingly. * @param {!Event} e The most recent move event. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at the start of the drag, in pixel units. * @package */ Blockly.BlockDragger.prototype.dragBlock = function(e, currentDragDeltaXY) { var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); - var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); + var newLoc = Blockly.utils.Coordinate.sum(this.startXY_, delta); this.draggingBlock_.moveDuringDrag(newLoc); this.dragIcons_(delta); @@ -216,7 +216,7 @@ Blockly.BlockDragger.prototype.dragBlock = function(e, currentDragDeltaXY) { /** * Finish a block drag and put the block back on the workspace. * @param {!Event} e The mouseup/touchend event. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at the start of the drag, in pixel units. * @package */ @@ -227,10 +227,10 @@ Blockly.BlockDragger.prototype.endBlockDrag = function(e, currentDragDeltaXY) { Blockly.Field.stopCache(); - Blockly.BlockAnimations.disconnectUiStop(); + Blockly.blockAnimations.disconnectUiStop(); var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); - var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); + var newLoc = Blockly.utils.Coordinate.sum(this.startXY_, delta); this.draggingBlock_.moveOffDragSurface_(newLoc); var deleted = this.maybeDeleteBlock_(); @@ -318,14 +318,15 @@ Blockly.BlockDragger.prototype.updateCursorDuringBlockDrag_ = function() { * correction for mutator workspaces. * This function does not consider differing origins. It simply scales the * input's x and y values. - * @param {!goog.math.Coordinate} pixelCoord A coordinate with x and y values - * in css pixel units. - * @return {!goog.math.Coordinate} The input coordinate divided by the workspace + * @param {!Blockly.utils.Coordinate} pixelCoord A coordinate with x and y values + * in CSS pixel units. + * @return {!Blockly.utils.Coordinate} The input coordinate divided by the workspace * scale. * @private */ Blockly.BlockDragger.prototype.pixelsToWorkspaceUnits_ = function(pixelCoord) { - var result = new goog.math.Coordinate(pixelCoord.x / this.workspace_.scale, + var result = new Blockly.utils.Coordinate( + pixelCoord.x / this.workspace_.scale, pixelCoord.y / this.workspace_.scale); if (this.workspace_.isMutator) { // If we're in a mutator, its scale is always 1, purely because of some @@ -333,14 +334,14 @@ Blockly.BlockDragger.prototype.pixelsToWorkspaceUnits_ = function(pixelCoord) { // the scale on the parent workspace. // Fix that for dragging. var mainScale = this.workspace_.options.parentWorkspace.scale; - result = result.scale(1 / mainScale); + result.scale(1 / mainScale); } return result; }; /** * Move all of the icons connected to this drag. - * @param {!goog.math.Coordinate} dxy How far to move the icons from their + * @param {!Blockly.utils.Coordinate} dxy How far to move the icons from their * original positions, in workspace units. * @private */ @@ -348,7 +349,7 @@ Blockly.BlockDragger.prototype.dragIcons_ = function(dxy) { // Moving icons moves their associated bubbles. for (var i = 0; i < this.dragIconData_.length; i++) { var data = this.dragIconData_[i]; - data.icon.setIconLocation(goog.math.Coordinate.sum(data.location, dxy)); + data.icon.setIconLocation(Blockly.utils.Coordinate.sum(data.location, dxy)); } }; diff --git a/core/block_events.js b/core/block_events.js index 0c3ad6cbc0e..c016bca46ba 100644 --- a/core/block_events.js +++ b/core/block_events.js @@ -36,9 +36,8 @@ goog.provide('Blockly.Events.Move'); // Deprecated. goog.require('Blockly.Events'); goog.require('Blockly.Events.Abstract'); -goog.require('Blockly.Xml.utils'); - -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.xml'); /** @@ -186,7 +185,7 @@ Blockly.Events.Change.prototype.run = function(forward) { block.setCollapsed(value); break; case 'disabled': - block.setDisabled(value); + block.setEnabled(!value); break; case 'inline': block.setInputsInline(value); @@ -198,9 +197,8 @@ Blockly.Events.Change.prototype.run = function(forward) { oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom); } if (block.domToMutation) { - value = value || ''; - var dom = Blockly.Xml.textToDom('' + value + ''); - block.domToMutation(dom.firstChild); + var dom = Blockly.Xml.textToDom(value || ''); + block.domToMutation(dom); } Blockly.Events.fire(new Blockly.Events.Change( block, 'mutation', null, oldMutation, value)); @@ -262,7 +260,7 @@ Blockly.Events.Create.prototype.toJson = function() { */ Blockly.Events.Create.prototype.fromJson = function(json) { Blockly.Events.Create.superClass_.fromJson.call(this, json); - this.xml = Blockly.Xml.textToDom('' + json['xml'] + '').firstChild; + this.xml = Blockly.Xml.textToDom(json['xml']); this.ids = json['ids']; }; @@ -273,7 +271,7 @@ Blockly.Events.Create.prototype.fromJson = function(json) { Blockly.Events.Create.prototype.run = function(forward) { var workspace = this.getEventWorkspace_(); if (forward) { - var xml = Blockly.Xml.utils.createElement('xml'); + var xml = Blockly.utils.xml.createElement('xml'); xml.appendChild(this.xml); Blockly.Xml.domToWorkspace(xml, workspace); } else { @@ -363,7 +361,7 @@ Blockly.Events.Delete.prototype.run = function(forward) { } } } else { - var xml = Blockly.Xml.utils.createElement('xml'); + var xml = Blockly.utils.xml.createElement('xml'); xml.appendChild(this.oldXml); Blockly.Xml.domToWorkspace(xml, workspace); } @@ -431,7 +429,7 @@ Blockly.Events.Move.prototype.fromJson = function(json) { if (json['newCoordinate']) { var xy = json['newCoordinate'].split(','); this.newCoordinate = - new goog.math.Coordinate(parseFloat(xy[0]), parseFloat(xy[1])); + new Blockly.utils.Coordinate(parseFloat(xy[0]), parseFloat(xy[1])); } }; @@ -475,7 +473,7 @@ Blockly.Events.Move.prototype.currentLocation_ = function() { Blockly.Events.Move.prototype.isNull = function() { return this.oldParentId == this.newParentId && this.oldInputName == this.newInputName && - goog.math.Coordinate.equals(this.oldCoordinate, this.newCoordinate); + Blockly.utils.Coordinate.equals(this.oldCoordinate, this.newCoordinate); }; /** diff --git a/core/block_render_svg.js b/core/block_render_svg.js index 53719b8e36b..6987b45d633 100644 --- a/core/block_render_svg.js +++ b/core/block_render_svg.js @@ -28,6 +28,7 @@ goog.provide('Blockly.BlockSvg.render'); goog.require('Blockly.BlockSvg'); +goog.require('Blockly.utils.dom'); /** @@ -903,7 +904,7 @@ Blockly.BlockSvg.prototype.renderInlineRow_ = function(pathObject, row, cursor, var steps = pathObject.steps; var highlightSteps = pathObject.highlightSteps; - for (var x = 0, input; input = row[x]; x++) { + for (var i = 0, input; input = row[i]; i++) { var fieldX = cursor.x; var fieldY = cursor.y; if (row.thicker) { @@ -1194,10 +1195,10 @@ Blockly.BlockSvg.prototype.positionNewBlock = function(newBlock, newConnection, */ Blockly.BlockSvg.prototype.highlightForReplacement = function(add) { if (add) { - Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_), + Blockly.utils.dom.addClass(/** @type {!Element} */ (this.svgGroup_), 'blocklyReplaceable'); } else { - Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_), + Blockly.utils.dom.removeClass(/** @type {!Element} */ (this.svgGroup_), 'blocklyReplaceable'); } }; diff --git a/core/block_svg.js b/core/block_svg.js index 0fff3eda2f5..ed93fc845b5 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -27,18 +27,20 @@ goog.provide('Blockly.BlockSvg'); goog.require('Blockly.Block'); -goog.require('Blockly.BlockAnimations'); +goog.require('Blockly.blockAnimations'); goog.require('Blockly.ContextMenu'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.Events.BlockMove'); goog.require('Blockly.Grid'); +goog.require('Blockly.Msg'); goog.require('Blockly.RenderedConnection'); goog.require('Blockly.Tooltip'); goog.require('Blockly.Touch'); goog.require('Blockly.utils'); - -goog.require('goog.color'); -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.Rect'); /** @@ -58,14 +60,14 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) { * @type {SVGElement} * @private */ - this.svgGroup_ = Blockly.utils.createSvgElement('g', {}, null); + this.svgGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null); this.svgGroup_.translate_ = ''; /** * @type {SVGElement} * @private */ - this.svgPathDark_ = Blockly.utils.createSvgElement('path', + this.svgPathDark_ = Blockly.utils.dom.createSvgElement('path', {'class': 'blocklyPathDark', 'transform': 'translate(1,1)'}, this.svgGroup_); @@ -73,14 +75,14 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) { * @type {SVGElement} * @private */ - this.svgPath_ = Blockly.utils.createSvgElement('path', + this.svgPath_ = Blockly.utils.dom.createSvgElement('path', {'class': 'blocklyPath'}, this.svgGroup_); /** * @type {SVGElement} * @private */ - this.svgPathLight_ = Blockly.utils.createSvgElement('path', + this.svgPathLight_ = Blockly.utils.dom.createSvgElement('path', {'class': 'blocklyPathLight'}, this.svgGroup_); this.svgPath_.tooltip = this; @@ -120,7 +122,7 @@ Blockly.BlockSvg.prototype.width = 0; /** * Original location of block being dragged. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @private */ Blockly.BlockSvg.prototype.dragStartXY_ = null; @@ -300,7 +302,7 @@ Blockly.BlockSvg.prototype.setParent = function(newParent) { * If the block is on the workspace, (0, 0) is the origin of the workspace * coordinate system. * This does not change with workspace scale. - * @return {!goog.math.Coordinate} Object with .x and .y properties in + * @return {!Blockly.utils.Coordinate} Object with .x and .y properties in * workspace coordinates. */ Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() { @@ -330,7 +332,7 @@ Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() { } while (element && element != this.workspace.getCanvas() && element != dragSurfaceGroup); } - return new goog.math.Coordinate(x, y); + return new Blockly.utils.Coordinate(x, y); }; /** @@ -392,7 +394,7 @@ Blockly.BlockSvg.prototype.moveToDragSurface_ = function() { * Move this block back to the workspace block canvas. * Generally should be called at the same time as setDragging_(false). * Does nothing if useDragSurface_ is false. - * @param {!goog.math.Coordinate} newXY The position the block should take on + * @param {!Blockly.utils.Coordinate} newXY The position the block should take on * on the workspace canvas, in workspace coordinates. * @private */ @@ -409,7 +411,7 @@ Blockly.BlockSvg.prototype.moveOffDragSurface_ = function(newXY) { * Move this block during a drag, taking into account whether we are using a * drag surface to translate blocks. * This block must be a top-level block. - * @param {!goog.math.Coordinate} newLoc The location to translate to, in + * @param {!Blockly.utils.Coordinate} newLoc The location to translate to, in * workspace coordinates. * @package */ @@ -429,7 +431,7 @@ Blockly.BlockSvg.prototype.moveDuringDrag = function(newLoc) { * @private */ Blockly.BlockSvg.prototype.clearTransformAttributes_ = function() { - Blockly.utils.removeAttribute(this.getSvgRoot(), 'transform'); + this.getSvgRoot().removeAttribute('transform'); }; /** @@ -468,32 +470,29 @@ Blockly.BlockSvg.prototype.snapToGrid = function() { * Returns the coordinates of a bounding box describing the dimensions of this * block and any blocks stacked below it. * Coordinate system: workspace coordinates. - * @return {!{topLeft: goog.math.Coordinate, bottomRight: goog.math.Coordinate}} - * Object with top left and bottom right coordinates of the bounding box. + * @return {!Blockly.utils.Rect} Object with coordinates of the bounding box. */ Blockly.BlockSvg.prototype.getBoundingRectangle = function() { var blockXY = this.getRelativeToSurfaceXY(this); var tab = this.outputConnection ? Blockly.BlockSvg.TAB_WIDTH : 0; var blockBounds = this.getHeightWidth(); - var topLeft; - var bottomRight; + var top = blockXY.y; + var bottom = blockXY.y + blockBounds.height; + var left, right; if (this.RTL) { // Width has the tab built into it already so subtract it here. - topLeft = new goog.math.Coordinate(blockXY.x - (blockBounds.width - tab), - blockXY.y); + left = blockXY.x - (blockBounds.width - tab); // Add the width of the tab/puzzle piece knob to the x coordinate // since X is the corner of the rectangle, not the whole puzzle piece. - bottomRight = new goog.math.Coordinate(blockXY.x + tab, - blockXY.y + blockBounds.height); + right = blockXY.x + tab; } else { // Subtract the width of the tab/puzzle piece knob to the x coordinate // since X is the corner of the rectangle, not the whole puzzle piece. - topLeft = new goog.math.Coordinate(blockXY.x - tab, blockXY.y); + left = blockXY.x - tab; // Width has the tab built into it already so subtract it here. - bottomRight = new goog.math.Coordinate(blockXY.x + blockBounds.width - tab, - blockXY.y + blockBounds.height); + right = blockXY.x + blockBounds.width - tab; } - return {topLeft: topLeft, bottomRight: bottomRight}; + return new Blockly.utils.Rect(top, bottom, left, right); }; /** @@ -635,76 +634,81 @@ Blockly.BlockSvg.prototype.showHelp_ = function() { }; /** - * Show the context menu for this block. - * @param {!Event} e Mouse event. - * @private + * Generate the context menu for this block. + * @protected + * @returns {Array.} Context menu options */ -Blockly.BlockSvg.prototype.showContextMenu_ = function(e) { +Blockly.BlockSvg.prototype.generateContextMenu = function() { if (this.workspace.options.readOnly || !this.contextMenu) { - return; + return null; } // Save the current block in a variable for use in closures. var block = this; var menuOptions = []; - if (this.isDeletable() && this.isMovable() && !block.isInFlyout) { - menuOptions.push(Blockly.ContextMenu.blockDuplicateOption(block)); - if (this.isEditable() && !this.collapsed_ && - this.workspace.options.comments) { + if (!this.isInFlyout) { + if (this.isDeletable() && this.isMovable()) { + menuOptions.push(Blockly.ContextMenu.blockDuplicateOption(block)); + } + + if (this.workspace.options.comments && !this.collapsed_ && + this.isEditable()) { menuOptions.push(Blockly.ContextMenu.blockCommentOption(block)); } - // Option to make block inline. - if (!this.collapsed_) { - for (var i = 1; i < this.inputList.length; i++) { - if (this.inputList[i - 1].type != Blockly.NEXT_STATEMENT && - this.inputList[i].type != Blockly.NEXT_STATEMENT) { - // Only display this option if there are two value or dummy inputs - // next to each other. - var inlineOption = {enabled: true}; - var isInline = this.getInputsInline(); - inlineOption.text = isInline ? - Blockly.Msg['EXTERNAL_INPUTS'] : Blockly.Msg['INLINE_INPUTS']; - inlineOption.callback = function() { - block.setInputsInline(!isInline); + if (this.isMovable()) { + if (!this.collapsed_) { + // Option to make block inline. + for (var i = 1; i < this.inputList.length; i++) { + if (this.inputList[i - 1].type != Blockly.NEXT_STATEMENT && + this.inputList[i].type != Blockly.NEXT_STATEMENT) { + // Only display this option if there are two value or dummy inputs + // next to each other. + var inlineOption = {enabled: true}; + var isInline = this.getInputsInline(); + inlineOption.text = isInline ? + Blockly.Msg['EXTERNAL_INPUTS'] : Blockly.Msg['INLINE_INPUTS']; + inlineOption.callback = function() { + block.setInputsInline(!isInline); + }; + menuOptions.push(inlineOption); + break; + } + } + // Option to collapse block + if (this.workspace.options.collapse) { + var collapseOption = {enabled: true}; + collapseOption.text = Blockly.Msg['COLLAPSE_BLOCK']; + collapseOption.callback = function() { + block.setCollapsed(true); }; - menuOptions.push(inlineOption); - break; + menuOptions.push(collapseOption); } - } - } - - if (this.workspace.options.collapse) { - // Option to collapse/expand block. - if (this.collapsed_) { - var expandOption = {enabled: true}; - expandOption.text = Blockly.Msg['EXPAND_BLOCK']; - expandOption.callback = function() { - block.setCollapsed(false); - }; - menuOptions.push(expandOption); } else { - var collapseOption = {enabled: true}; - collapseOption.text = Blockly.Msg['COLLAPSE_BLOCK']; - collapseOption.callback = function() { - block.setCollapsed(true); - }; - menuOptions.push(collapseOption); + // Option to expand block. + if (this.workspace.options.collapse) { + var expandOption = {enabled: true}; + expandOption.text = Blockly.Msg['EXPAND_BLOCK']; + expandOption.callback = function() { + block.setCollapsed(false); + }; + menuOptions.push(expandOption); + } } } - if (this.workspace.options.disable) { + if (this.workspace.options.disable && this.isEditable()) { // Option to disable/enable block. var disableOption = { - text: this.disabled ? - Blockly.Msg['ENABLE_BLOCK'] : Blockly.Msg['DISABLE_BLOCK'], + text: this.isEnabled() ? + Blockly.Msg['DISABLE_BLOCK'] : Blockly.Msg['ENABLE_BLOCK'], enabled: !this.getInheritedDisabled(), callback: function() { var group = Blockly.Events.getGroup(); if (!group) { Blockly.Events.setGroup(true); } - block.setDisabled(!block.disabled); + block.setEnabled(!block.isEnabled()); if (!group) { Blockly.Events.setGroup(false); } @@ -713,7 +717,9 @@ Blockly.BlockSvg.prototype.showContextMenu_ = function(e) { menuOptions.push(disableOption); } - menuOptions.push(Blockly.ContextMenu.blockDeleteOption(block)); + if (this.isDeletable()) { + menuOptions.push(Blockly.ContextMenu.blockDeleteOption(block)); + } } menuOptions.push(Blockly.ContextMenu.blockHelpOption(block)); @@ -723,8 +729,21 @@ Blockly.BlockSvg.prototype.showContextMenu_ = function(e) { this.customContextMenu(menuOptions); } - Blockly.ContextMenu.show(e, menuOptions, this.RTL); - Blockly.ContextMenu.currentBlock = this; + return menuOptions; +}; + +/** + * Show the context menu for this block. + * @param {!Event} e Mouse event. + * @private + */ +Blockly.BlockSvg.prototype.showContextMenu_ = function(e) { + var menuOptions = this.generateContextMenu(); + + if (menuOptions && menuOptions.length) { + Blockly.ContextMenu.show(e, menuOptions, this.RTL); + Blockly.ContextMenu.currentBlock = this; + } }; /** @@ -769,11 +788,11 @@ Blockly.BlockSvg.prototype.setDragging = function(adding) { group.skew_ = ''; Blockly.draggingConnections_ = Blockly.draggingConnections_.concat(this.getConnections_(true)); - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDragging'); } else { Blockly.draggingConnections_ = []; - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDragging'); } // Recurse through all blocks attached under this one. @@ -787,10 +806,10 @@ Blockly.BlockSvg.prototype.setDragging = function(adding) { */ Blockly.BlockSvg.prototype.updateMovable = function() { if (this.isMovable()) { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable'); } else { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable'); } }; @@ -838,7 +857,7 @@ Blockly.BlockSvg.prototype.setInsertionMarker = function(insertionMarker) { this.isInsertionMarker_ = insertionMarker; if (this.isInsertionMarker_) { this.setColour(Blockly.INSERTION_MARKER_COLOUR); - Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_), + Blockly.utils.dom.addClass(/** @type {!Element} */ (this.svgGroup_), 'blocklyInsertionMarker'); } }; @@ -880,7 +899,7 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { if (animate && this.rendered) { this.unplug(healStack); - Blockly.BlockAnimations.disposeUiEffect(this); + Blockly.blockAnimations.disposeUiEffect(this); } // Stop rerendering. this.rendered = false; @@ -916,7 +935,7 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { Blockly.Events.fire(deleteEvent); } - Blockly.utils.removeNode(this.svgGroup_); + Blockly.utils.dom.removeNode(this.svgGroup_); blockWorkspace.resizeContents(); // Sever JavaScript to DOM connections. this.svgGroup_ = null; @@ -930,93 +949,78 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { * Change the colour of a block. */ Blockly.BlockSvg.prototype.updateColour = function() { - if (this.disabled) { + if (!this.isEnabled()) { // Disabled blocks don't have colour. return; } - var hexColour = this.getColour(); - var colourSecondary = this.getColourSecondary(); - var colourTertiary = this.getColourTertiary(); - var rgb = goog.color.hexToRgb(hexColour); if (this.isShadow()) { - hexColour = this.setShadowColour_(rgb, colourSecondary); + this.setShadowColour_(); } else { - this.setBorderColour_(rgb, colourTertiary); + this.setBorderColour_(); + this.svgPath_.setAttribute('fill', this.getColour()); } - this.svgPath_.setAttribute('fill', hexColour); var icons = this.getIcons(); for (var i = 0; i < icons.length; i++) { icons[i].updateColour(); } - // Bump every dropdown to change its colour. - // TODO (#1456) for (var x = 0, input; input = this.inputList[x]; x++) { for (var y = 0, field; field = input.fieldRow[y]; y++) { - field.forceRerender(); + field.updateColour(); } } }; /** * Sets the colour of the border. - * Removes the light and dark paths if a tertiary colour is defined. - * @param {!string} rgb Colour of the block. - * @param {?string} colourTertiary Colour of the border. - */ -Blockly.BlockSvg.prototype.setBorderColour_ = function(rgb, colourTertiary) { - if (colourTertiary) { - this.svgPathLight_.setAttribute('stroke', 'none'); - this.svgPathDark_.setAttribute('fill', 'none'); - this.svgPath_.setAttribute('stroke', colourTertiary); + * Removes the light and dark paths if a border colour is defined. + */ +Blockly.BlockSvg.prototype.setBorderColour_ = function() { + var borderColours = this.getColourBorder(); + if (borderColours.colourBorder) { + this.svgPathLight_.style.display = 'none'; + this.svgPathDark_.style.display = 'none'; + + this.svgPath_.setAttribute('stroke', borderColours.colourBorder); } else { this.svgPathLight_.style.display = ''; - var hexLight = goog.color.rgbArrayToHex(goog.color.lighten(rgb, 0.3)); - var hexDark = goog.color.rgbArrayToHex(goog.color.darken(rgb, 0.2)); - this.svgPathLight_.setAttribute('stroke', hexLight); - this.svgPathDark_.setAttribute('fill', hexDark); + this.svgPathDark_.style.display = ''; this.svgPath_.setAttribute('stroke', 'none'); + this.svgPathLight_.setAttribute('stroke', borderColours.colourLight); + this.svgPathDark_.setAttribute('fill', borderColours.colourDark); } }; /** * Sets the colour of shadow blocks. - * @param {!string} rgb Primary colour of the block. - * @param {?string} colourSecondary Colour for shadow block. - * @return {!string} The background colour of the block. + * @return {?string} The background colour of the block. */ -Blockly.BlockSvg.prototype.setShadowColour_ = function(rgb, colourSecondary) { - var hexColour; - if (colourSecondary) { - this.svgPathLight_.style.display = 'none'; - this.svgPathDark_.style.display = 'none'; - this.svgPath_.setAttribute('fill', colourSecondary); - hexColour = colourSecondary; - } else { - rgb = goog.color.lighten(rgb, 0.6); - hexColour = goog.color.rgbArrayToHex(rgb); - this.svgPathLight_.style.display = 'none'; - this.svgPathDark_.setAttribute('fill', hexColour); - } - return hexColour; +Blockly.BlockSvg.prototype.setShadowColour_ = function() { + var shadowColour = this.getColourShadow(); + + this.svgPathLight_.style.display = 'none'; + this.svgPathDark_.setAttribute('fill', shadowColour); + this.svgPath_.setAttribute('stroke', 'none'); + this.svgPath_.setAttribute('fill', shadowColour); + return shadowColour; }; /** * Enable or disable a block. */ Blockly.BlockSvg.prototype.updateDisabled = function() { - if (this.disabled || this.getInheritedDisabled()) { - var added = Blockly.utils.addClass( + if (!this.isEnabled() || this.getInheritedDisabled()) { + var added = Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDisabled'); if (added) { this.svgPath_.setAttribute('fill', 'url(#' + this.workspace.options.disabledPatternId + ')'); } } else { - var removed = Blockly.utils.removeClass( + var removed = Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDisabled'); if (removed) { this.updateColour(); @@ -1167,10 +1171,21 @@ Blockly.BlockSvg.prototype.setMutator = function(mutator) { /** * Set whether the block is disabled or not. * @param {boolean} disabled True if disabled. + * @deprecated May 2019 */ Blockly.BlockSvg.prototype.setDisabled = function(disabled) { - if (this.disabled != disabled) { - Blockly.BlockSvg.superClass_.setDisabled.call(this, disabled); + console.warn('Deprecated call to Blockly.BlockSvg.prototype.setDisabled, ' + + 'use Blockly.BlockSvg.prototype.setEnabled instead.'); + this.setEnabled(!disabled); +}; + +/** + * Set whether the block is enabled or not. + * @param {boolean} enabled True if enabled. + */ +Blockly.BlockSvg.prototype.setEnabled = function(enabled) { + if (this.isEnabled() != enabled) { + Blockly.BlockSvg.superClass_.setEnabled.call(this, enabled); if (this.rendered) { this.updateDisabled(); } @@ -1191,8 +1206,8 @@ Blockly.BlockSvg.prototype.setHighlighted = function(highlighted) { 'url(#' + this.workspace.options.embossFilterId + ')'); this.svgPathLight_.style.display = 'none'; } else { - Blockly.utils.removeAttribute(this.svgPath_, 'filter'); - delete this.svgPathLight_.style.display; + this.svgPath_.setAttribute('filter', 'none'); + this.svgPathLight_.style.display = 'inline'; } }; @@ -1200,7 +1215,7 @@ Blockly.BlockSvg.prototype.setHighlighted = function(highlighted) { * Select this block. Highlight it visually. */ Blockly.BlockSvg.prototype.addSelect = function() { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklySelected'); }; @@ -1208,7 +1223,7 @@ Blockly.BlockSvg.prototype.addSelect = function() { * Unselect this block. Remove its highlighting. */ Blockly.BlockSvg.prototype.removeSelect = function() { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklySelected'); }; @@ -1220,10 +1235,10 @@ Blockly.BlockSvg.prototype.removeSelect = function() { */ Blockly.BlockSvg.prototype.setDeleteStyle = function(enable) { if (enable) { - Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_), + Blockly.utils.dom.addClass(/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete'); } else { - Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_), + Blockly.utils.dom.removeClass(/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete'); } }; diff --git a/core/blockly.js b/core/blockly.js index 0b948ff678c..e42ad533ee1 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -32,6 +32,7 @@ goog.provide('Blockly'); goog.require('Blockly.BlockSvg.render'); goog.require('Blockly.Events'); +goog.require('Blockly.Events.Ui'); goog.require('Blockly.FieldAngle'); goog.require('Blockly.FieldCheckbox'); goog.require('Blockly.FieldColour'); @@ -39,14 +40,15 @@ goog.require('Blockly.FieldColour'); // Add it only if you need it. //goog.require('Blockly.FieldDate'); goog.require('Blockly.FieldDropdown'); +goog.require('Blockly.FieldLabelSerializable'); goog.require('Blockly.FieldImage'); goog.require('Blockly.FieldTextInput'); goog.require('Blockly.FieldNumber'); goog.require('Blockly.FieldVariable'); goog.require('Blockly.Generator'); -goog.require('Blockly.Msg'); goog.require('Blockly.Procedures'); goog.require('Blockly.Toolbox'); +goog.require('Blockly.Tooltip'); goog.require('Blockly.Touch'); goog.require('Blockly.WidgetDiv'); goog.require('Blockly.WorkspaceSvg'); @@ -55,8 +57,6 @@ goog.require('Blockly.inject'); goog.require('Blockly.utils'); goog.require('Blockly.Xml'); -goog.require('goog.color'); - // Turn off debugging when compiled. // Unused within the Blockly library, but used in Closure. @@ -107,7 +107,7 @@ Blockly.clipboardTypeCounts_ = null; /** * Cached value for whether 3D is supported. - * @type {!boolean} + * @type {?boolean} * @private */ Blockly.cache3dSupported_ = null; @@ -119,16 +119,6 @@ Blockly.cache3dSupported_ = null; */ Blockly.theme_ = null; -/** - * Convert a hue (HSV model) into an RGB hex triplet. - * @param {number} hue Hue on a colour wheel (0-360). - * @return {string} RGB code, e.g. '#5ba65b'. - */ -Blockly.hueToRgb = function(hue) { - return goog.color.hsvToHex(hue, Blockly.HSV_SATURATION, - Blockly.HSV_VALUE * 255); -}; - /** * Returns the dimensions of the specified SVG image. * @param {!Element} svg SVG image. @@ -191,9 +181,9 @@ Blockly.svgResize = function(workspace) { // TODO (https://github.com/google/blockly/issues/1998) handle cases where there // are multiple workspaces and non-main workspaces are able to accept input. Blockly.onKeyDown_ = function(e) { - var workspace = Blockly.mainWorkspace; - if (workspace.options.readOnly || Blockly.utils.isTargetInput(e) || - (workspace.rendered && !workspace.isVisible())) { + var mainWorkspace = Blockly.mainWorkspace; + if (mainWorkspace.options.readOnly || Blockly.utils.isTargetInput(e) || + (mainWorkspace.rendered && !mainWorkspace.isVisible())) { // No key actions on readonly workspaces. // When focused on an HTML text input widget, don't trap any keys. // Ignore keypresses on rendered workspaces that have been explicitly @@ -257,7 +247,7 @@ Blockly.onKeyDown_ = function(e) { } else if (e.keyCode == 90) { // 'z' for undo 'Z' is for redo. Blockly.hideChaff(); - workspace.undo(e.shiftKey); + mainWorkspace.undo(e.shiftKey); } } // Common code for delete and cut. @@ -280,7 +270,7 @@ Blockly.copy_ = function(toCopy) { if (toCopy.isComment) { var xml = toCopy.toXmlWithXY(); } else { - var xml = Blockly.Xml.blockToDom(toCopy); + var xml = Blockly.Xml.blockToDom(toCopy, true); // Copy only the selected block and internal blocks. Blockly.Xml.deleteNext(xml); // Encode start position in XML. @@ -382,7 +372,7 @@ Blockly.getMainWorkspace = function() { * @param {function()=} opt_callback The callback when the alert is dismissed. */ Blockly.alert = function(message, opt_callback) { - window.alert(message); + alert(message); if (opt_callback) { opt_callback(); } @@ -395,7 +385,7 @@ Blockly.alert = function(message, opt_callback) { * @param {!function(boolean)} callback The callback for handling user response. */ Blockly.confirm = function(message, callback) { - callback(window.confirm(message)); + callback(confirm(message)); }; /** @@ -408,7 +398,7 @@ Blockly.confirm = function(message, callback) { * @param {!function(string)} callback The callback for handling user response. */ Blockly.prompt = function(message, defaultValue, callback) { - callback(window.prompt(message, defaultValue)); + callback(prompt(message, defaultValue)); }; /** @@ -497,7 +487,8 @@ Blockly.bindEventWithChecks_ = function(node, name, thisObject, func, }; var bindData = []; - if (goog.global.PointerEvent && (name in Blockly.Touch.TOUCH_MAP)) { + if (Blockly.utils.global['PointerEvent'] && + (name in Blockly.Touch.TOUCH_MAP)) { for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) { node.addEventListener(type, wrapFunc, false); bindData.push([node, type, wrapFunc]); @@ -549,8 +540,8 @@ Blockly.bindEvent_ = function(node, name, thisObject, func) { }; var bindData = []; - var window = goog.global['window']; - if (window && window.PointerEvent && (name in Blockly.Touch.TOUCH_MAP)) { + if (Blockly.utils.global['PointerEvent'] && + (name in Blockly.Touch.TOUCH_MAP)) { for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) { node.addEventListener(type, wrapFunc, false); bindData.push([node, type, wrapFunc]); @@ -609,6 +600,16 @@ Blockly.isNumber = function(str) { return /^\s*-?\d+(\.\d+)?\s*$/.test(str); }; +/** + * Convert a hue (HSV model) into an RGB hex triplet. + * @param {number} hue Hue on a colour wheel (0-360). + * @return {string} RGB code, e.g. '#5ba65b'. + */ +Blockly.hueToHex = function(hue) { + return Blockly.utils.colour.hsvToHex(hue, Blockly.HSV_SATURATION, + Blockly.HSV_VALUE * 255); +}; + /** * Checks old colour constants are not overwritten by the host application. * If a constant is overwritten, it prints a console warning directing the @@ -688,11 +689,11 @@ Blockly.checkBlockColourConstant_ = function( * @param {!Blockly.Theme} theme Theme for Blockly. */ Blockly.setTheme = function(theme) { - this.theme_ = theme; + Blockly.theme_ = theme; var ws = Blockly.getMainWorkspace(); if (ws) { - this.refreshTheme_(ws); + Blockly.refreshTheme_(ws); } }; @@ -703,15 +704,15 @@ Blockly.setTheme = function(theme) { */ Blockly.refreshTheme_ = function(ws) { // Update all blocks in workspace that have a style name. - this.updateBlockStyles_(ws.getAllBlocks().filter( - function(block){ + Blockly.updateBlockStyles_(ws.getAllBlocks().filter( + function(block) { return block.getStyleName() !== undefined; } )); // Update blocks in the flyout. if (!ws.toolbox_ && ws.flyout_ && ws.flyout_.workspace_) { - this.updateBlockStyles_(ws.flyout_.workspace_.getAllBlocks()); + Blockly.updateBlockStyles_(ws.flyout_.workspace_.getAllBlocks()); } else { ws.refreshToolboxSelection(); } @@ -735,7 +736,6 @@ Blockly.refreshTheme_ = function(ws) { Blockly.updateBlockStyles_ = function(blocks) { for (var i = 0, block; block = blocks[i]; i++) { var blockStyleName = block.getStyleName(); - block.setStyle(blockStyleName); if (block.mutator) { block.mutator.updateBlockStyle(blockStyleName); @@ -748,12 +748,13 @@ Blockly.updateBlockStyles_ = function(blocks) { * @return {Blockly.Theme} Theme for Blockly. */ Blockly.getTheme = function() { - return this.theme_; + return Blockly.theme_; }; // Export symbols that would otherwise be renamed by Closure compiler. -if (!goog.global['Blockly']) { - goog.global['Blockly'] = {}; +if (!Blockly.utils.global['Blockly']) { + Blockly.utils.global['Blockly'] = {}; } -goog.global['Blockly']['getMainWorkspace'] = Blockly.getMainWorkspace; -goog.global['Blockly']['addChangeListener'] = Blockly.addChangeListener; +Blockly.utils.global['Blockly']['getMainWorkspace'] = Blockly.getMainWorkspace; +Blockly.utils.global['Blockly']['addChangeListener'] = + Blockly.addChangeListener; diff --git a/core/blocks.js b/core/blocks.js index c27be1d40d5..f3ad06826eb 100644 --- a/core/blocks.js +++ b/core/blocks.js @@ -34,4 +34,4 @@ goog.provide('Blockly.Blocks'); * A mapping of block type names to block prototype objects. * @type {!Object.} */ -Blockly.Blocks = new Object(null); +Blockly.Blocks = Object.create(null); diff --git a/core/bubble.js b/core/bubble.js index 7befb33ccaf..fe72b2c64ae 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -27,9 +27,12 @@ goog.provide('Blockly.Bubble'); goog.require('Blockly.Touch'); +goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.math'); +goog.require('Blockly.utils.userAgent'); goog.require('Blockly.Workspace'); -goog.require('goog.math.Coordinate'); -goog.require('goog.userAgent'); /** @@ -38,8 +41,8 @@ goog.require('goog.userAgent'); * bubble. * @param {!Element} content SVG content for the bubble. * @param {Element} shape SVG element to avoid eclipsing. - * @param {!goog.math.Coordinate} anchorXY Absolute position of bubble's anchor - * point. + * @param {!Blockly.utils.Coordinate} anchorXY Absolute position of bubble's + * anchor point. * @param {?number} bubbleWidth Width of bubble, or null if not resizable. * @param {?number} bubbleHeight Height of bubble, or null if not resizable. * @constructor @@ -54,7 +57,7 @@ Blockly.Bubble = function(workspace, content, shape, anchorXY, if (this.workspace_.RTL) { angle = -angle; } - this.arrow_radians_ = Blockly.utils.toRadians(angle); + this.arrow_radians_ = Blockly.utils.math.toRadians(angle); var canvas = workspace.getBubbleCanvas(); canvas.appendChild(this.createDom_(content, !!(bubbleWidth && bubbleHeight))); @@ -161,7 +164,7 @@ Blockly.Bubble.prototype.rendered_ = false; /** * Absolute coordinate of anchor point, in workspace coordinates. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @private */ Blockly.Bubble.prototype.anchorXY_ = null; @@ -221,20 +224,18 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) { [...content goes here...] */ - this.bubbleGroup_ = Blockly.utils.createSvgElement('g', {}, null); + this.bubbleGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null); var filter = {'filter': 'url(#' + this.workspace_.options.embossFilterId + ')'}; - if (goog.userAgent.getUserAgentString().indexOf('JavaFX') != -1) { - // Multiple reports that JavaFX can't handle filters. UserAgent: - // Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.44 - // (KHTML, like Gecko) JavaFX/8.0 Safari/537.44 + if (Blockly.utils.userAgent.JAVA_FX) { + // Multiple reports that JavaFX can't handle filters. // https://github.com/google/blockly/issues/99 filter = {}; } - var bubbleEmboss = Blockly.utils.createSvgElement('g', + var bubbleEmboss = Blockly.utils.dom.createSvgElement('g', filter, this.bubbleGroup_); - this.bubbleArrow_ = Blockly.utils.createSvgElement('path', {}, bubbleEmboss); - this.bubbleBack_ = Blockly.utils.createSvgElement('rect', + this.bubbleArrow_ = Blockly.utils.dom.createSvgElement('path', {}, bubbleEmboss); + this.bubbleBack_ = Blockly.utils.dom.createSvgElement('rect', { 'class': 'blocklyDraggable', 'x': 0, @@ -244,21 +245,21 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) { }, bubbleEmboss); if (hasResize) { - this.resizeGroup_ = Blockly.utils.createSvgElement('g', + this.resizeGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': this.workspace_.RTL ? 'blocklyResizeSW' : 'blocklyResizeSE'}, this.bubbleGroup_); var resizeSize = 2 * Blockly.Bubble.BORDER_WIDTH; - Blockly.utils.createSvgElement('polygon', + Blockly.utils.dom.createSvgElement('polygon', {'points': '0,x x,x x,0'.replace(/x/g, resizeSize.toString())}, this.resizeGroup_); - Blockly.utils.createSvgElement('line', + Blockly.utils.dom.createSvgElement('line', { 'class': 'blocklyResizeLine', 'x1': resizeSize / 3, 'y1': resizeSize - 1, 'x2': resizeSize - 1, 'y2': resizeSize / 3 }, this.resizeGroup_); - Blockly.utils.createSvgElement('line', + Blockly.utils.dom.createSvgElement('line', { 'class': 'blocklyResizeLine', 'x1': resizeSize * 2 / 3, @@ -336,7 +337,7 @@ Blockly.Bubble.prototype.resizeMouseDown_ = function(e) { return; } // Left-click (or middle click) - this.workspace_.startDrag(e, new goog.math.Coordinate( + this.workspace_.startDrag(e, new Blockly.utils.Coordinate( this.workspace_.RTL ? -this.width_ : this.width_, this.height_)); Blockly.Bubble.onMouseUpWrapper_ = Blockly.bindEventWithChecks_(document, @@ -373,7 +374,7 @@ Blockly.Bubble.prototype.registerResizeEvent = function(callback) { /** * Move this bubble to the top of the stack. - * @return {!boolean} Whether or not the bubble has been moved. + * @return {boolean} Whether or not the bubble has been moved. * @private */ Blockly.Bubble.prototype.promote_ = function() { @@ -388,7 +389,7 @@ Blockly.Bubble.prototype.promote_ = function() { /** * Notification that the anchor has moved. * Update the arrow and bubble accordingly. - * @param {!goog.math.Coordinate} xy Absolute location. + * @param {!Blockly.utils.Coordinate} xy Absolute location. */ Blockly.Bubble.prototype.setAnchorLocation = function(xy) { this.anchorXY_ = xy; @@ -759,7 +760,7 @@ Blockly.Bubble.prototype.setColour = function(hexColour) { Blockly.Bubble.prototype.dispose = function() { Blockly.Bubble.unbindDragEvents_(); // Dispose of and unlink the bubble. - Blockly.utils.removeNode(this.bubbleGroup_); + Blockly.utils.dom.removeNode(this.bubbleGroup_); this.bubbleGroup_ = null; this.bubbleArrow_ = null; this.bubbleBack_ = null; @@ -774,7 +775,7 @@ Blockly.Bubble.prototype.dispose = function() { * a drag surface. * @param {Blockly.BlockDragSurfaceSvg} dragSurface The surface that carries * rendered items during a drag, or null if no drag surface is in use. - * @param {!goog.math.Coordinate} newLoc The location to translate to, in + * @param {!Blockly.utils.Coordinate} newLoc The location to translate to, in * workspace coordinates. * @package */ @@ -796,10 +797,10 @@ Blockly.Bubble.prototype.moveDuringDrag = function(dragSurface, newLoc) { /** * Return the coordinates of the top-left corner of this bubble's body relative * to the drawing surface's origin (0,0), in workspace units. - * @return {!goog.math.Coordinate} Object with .x and .y properties. + * @return {!Blockly.utils.Coordinate} Object with .x and .y properties. */ Blockly.Bubble.prototype.getRelativeToSurfaceXY = function() { - return new goog.math.Coordinate( + return new Blockly.utils.Coordinate( this.anchorXY_.x + this.relativeLeft_, this.anchorXY_.y + this.relativeTop_); }; diff --git a/core/bubble_dragger.js b/core/bubble_dragger.js index 3665d9fd193..c8eed71d945 100644 --- a/core/bubble_dragger.js +++ b/core/bubble_dragger.js @@ -27,12 +27,12 @@ goog.provide('Blockly.BubbleDragger'); goog.require('Blockly.Bubble'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.CommentMove'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); goog.require('Blockly.WorkspaceCommentSvg'); -goog.require('goog.math.Coordinate'); - /** * Class for a bubble dragger. It moves things on the bubble canvas around the @@ -77,7 +77,7 @@ Blockly.BubbleDragger = function(bubble, workspace) { /** * The location of the top left corner of the dragging bubble's body at the * beginning of the drag, in workspace coordinates. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @private */ this.startXY_ = this.draggingBubble_.getRelativeToSurfaceXY(); @@ -132,13 +132,13 @@ Blockly.BubbleDragger.prototype.startBubbleDrag = function() { * Execute a step of bubble dragging, based on the given event. Update the * display accordingly. * @param {!Event} e The most recent move event. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at the start of the drag, in pixel units. * @package */ Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) { var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); - var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); + var newLoc = Blockly.utils.Coordinate.sum(this.startXY_, delta); this.draggingBubble_.moveDuringDrag(this.dragSurface_, newLoc); @@ -195,7 +195,7 @@ Blockly.BubbleDragger.prototype.updateCursorDuringBubbleDrag_ = function() { /** * Finish a bubble drag and put the bubble back on the workspace. * @param {!Event} e The mouseup/touchend event. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at the start of the drag, in pixel units. * @package */ @@ -205,7 +205,7 @@ Blockly.BubbleDragger.prototype.endBubbleDrag = function( this.dragBubble(e, currentDragDeltaXY); var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); - var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); + var newLoc = Blockly.utils.Coordinate.sum(this.startXY_, delta); // Move the bubble to its final location. this.draggingBubble_.moveTo(newLoc.x, newLoc.y); @@ -250,14 +250,14 @@ Blockly.BubbleDragger.prototype.fireMoveEvent_ = function() { * correction for mutator workspaces. * This function does not consider differing origins. It simply scales the * input's x and y values. - * @param {!goog.math.Coordinate} pixelCoord A coordinate with x and y values - * in css pixel units. - * @return {!goog.math.Coordinate} The input coordinate divided by the workspace + * @param {!Blockly.utils.Coordinate} pixelCoord A coordinate with x and y values + * in CSS pixel units. + * @return {!Blockly.utils.Coordinate} The input coordinate divided by the workspace * scale. * @private */ Blockly.BubbleDragger.prototype.pixelsToWorkspaceUnits_ = function(pixelCoord) { - var result = new goog.math.Coordinate(pixelCoord.x / this.workspace_.scale, + var result = new Blockly.utils.Coordinate(pixelCoord.x / this.workspace_.scale, pixelCoord.y / this.workspace_.scale); if (this.workspace_.isMutator) { // If we're in a mutator, its scale is always 1, purely because of some @@ -265,7 +265,7 @@ Blockly.BubbleDragger.prototype.pixelsToWorkspaceUnits_ = function(pixelCoord) { // the scale on the parent workspace. // Fix that for dragging. var mainScale = this.workspace_.options.parentWorkspace.scale; - result = result.scale(1 / mainScale); + result.scale(1 / mainScale); } return result; }; diff --git a/core/comment.js b/core/comment.js index a1d7fbc0248..80e4ed1d1af 100644 --- a/core/comment.js +++ b/core/comment.js @@ -27,12 +27,12 @@ goog.provide('Blockly.Comment'); goog.require('Blockly.Bubble'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.Icon'); -goog.require('Blockly.utils'); - -goog.require('goog.userAgent'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.userAgent'); /** @@ -72,13 +72,13 @@ Blockly.Comment.prototype.height_ = 80; */ Blockly.Comment.prototype.drawIcon_ = function(group) { // Circle. - Blockly.utils.createSvgElement('circle', + Blockly.utils.dom.createSvgElement('circle', {'class': 'blocklyIconShape', 'r': '8', 'cx': '8', 'cy': '8'}, group); // Can't use a real '?' text character since different browsers and operating // systems render it differently. // Body of question mark. - Blockly.utils.createSvgElement('path', + Blockly.utils.dom.createSvgElement('path', { 'class': 'blocklyIconSymbol', 'd': 'm6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.405' + @@ -86,7 +86,7 @@ Blockly.Comment.prototype.drawIcon_ = function(group) { '-1.201,0.998 -1.201,1.528 -1.204,2.19z'}, group); // Dot of question mark. - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', { 'class': 'blocklyIconSymbol', 'x': '6.8', @@ -112,13 +112,13 @@ Blockly.Comment.prototype.createEditor_ = function() { */ - this.foreignObject_ = Blockly.utils.createSvgElement('foreignObject', + this.foreignObject_ = Blockly.utils.dom.createSvgElement('foreignObject', {'x': Blockly.Bubble.BORDER_WIDTH, 'y': Blockly.Bubble.BORDER_WIDTH}, null); - var body = document.createElementNS(Blockly.HTML_NS, 'body'); - body.setAttribute('xmlns', Blockly.HTML_NS); + var body = document.createElementNS(Blockly.utils.dom.HTML_NS, 'body'); + body.setAttribute('xmlns', Blockly.utils.dom.HTML_NS); body.className = 'blocklyMinimalBody'; - var textarea = document.createElementNS(Blockly.HTML_NS, 'textarea'); + var textarea = document.createElementNS(Blockly.utils.dom.HTML_NS, 'textarea'); textarea.className = 'blocklyCommentTextarea'; textarea.setAttribute('dir', this.block_.RTL ? 'RTL' : 'LTR'); body.appendChild(textarea); @@ -184,7 +184,8 @@ Blockly.Comment.prototype.setVisible = function(visible) { } Blockly.Events.fire( new Blockly.Events.Ui(this.block_, 'commentOpen', !visible, visible)); - if ((!this.block_.isEditable() && !this.textarea_) || goog.userAgent.IE) { + if ((!this.block_.isEditable() && !this.textarea_) || + Blockly.utils.userAgent.IE) { // Steal the code from warnings to make an uneditable text bubble. // MSIE does not support foreignobject; textareas are impossible. // https://docs.microsoft.com/en-us/openspecs/ie_standards/ms-svg/56e6e04c-7c8c-44dd-8100-bd745ee42034 diff --git a/core/connection.js b/core/connection.js index f61d0e7927e..082cfc4416b 100644 --- a/core/connection.js +++ b/core/connection.js @@ -26,6 +26,7 @@ goog.provide('Blockly.Connection'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockMove'); goog.require('Blockly.Xml'); @@ -241,8 +242,6 @@ Blockly.Connection.prototype.dispose = function() { if (this.inDB_) { this.db_.removeConnection_(this); } - this.db_ = null; - this.dbOpposite_ = null; }; /** @@ -445,6 +444,10 @@ Blockly.Connection.prototype.connect = function(otherConnection) { return; } this.checkConnection_(otherConnection); + var eventGroup = Blockly.Events.getGroup(); + if (!eventGroup) { + Blockly.Events.setGroup(true); + } // Determine which block is superior (higher in the source stack). if (this.isSuperior()) { // Superior block. @@ -453,6 +456,9 @@ Blockly.Connection.prototype.connect = function(otherConnection) { // Inferior block. otherConnection.connect_(this); } + if (!eventGroup) { + Blockly.Events.setGroup(false); + } }; /** @@ -542,8 +548,16 @@ Blockly.Connection.prototype.disconnect = function() { childBlock = this.sourceBlock_; parentConnection = otherConnection; } + + var eventGroup = Blockly.Events.getGroup(); + if (!eventGroup) { + Blockly.Events.setGroup(true); + } this.disconnectInternal_(parentBlock, childBlock); parentConnection.respawnShadow_(); + if (!eventGroup) { + Blockly.Events.setGroup(false); + } }; /** @@ -656,8 +670,8 @@ Blockly.Connection.prototype.setCheck = function(check) { /** * Get a connection's compatibility. - * @return {Array} List of compatible value types. Null if - * all types are compatible. + * @return {Array} List of compatible value types. + * Null if all types are compatible. * @public */ Blockly.Connection.prototype.getCheck = function() { @@ -688,11 +702,11 @@ Blockly.Connection.prototype.getShadowDom = function() { * and always return an empty list (the default). * {@link Blockly.RenderedConnection} overrides this behavior with a list * computed from the rendered positioning. - * @param {number} maxLimit The maximum radius to another connection. + * @param {number} _maxLimit The maximum radius to another connection. * @return {!Array.} List of connections. * @private */ -Blockly.Connection.prototype.neighbours_ = function(/* maxLimit */) { +Blockly.Connection.prototype.neighbours_ = function(_maxLimit) { return []; }; diff --git a/core/connection_db.js b/core/connection_db.js index c538fad7561..ce7e9487bdb 100644 --- a/core/connection_db.js +++ b/core/connection_db.js @@ -226,16 +226,17 @@ Blockly.ConnectionDB.prototype.isInYRange_ = function(index, baseY, maxRadius) { * @param {!Blockly.Connection} conn The connection searching for a compatible * mate. * @param {number} maxRadius The maximum radius to another connection. - * @param {!goog.math.Coordinate} dxy Offset between this connection's location - * in the database and the current location (as a result of dragging). + * @param {!Blockly.utils.Coordinate} dxy Offset between this connection's + * location in the database and the current location (as a result of + * dragging). * @return {!{connection: ?Blockly.Connection, radius: number}} Contains two * properties:' connection' which is either another connection or null, * and 'radius' which is the distance. */ Blockly.ConnectionDB.prototype.searchForClosest = function(conn, maxRadius, dxy) { - // Don't bother. if (!this.connections_.length) { + // Don't bother. return {connection: null, radius: maxRadius}; } @@ -286,15 +287,15 @@ Blockly.ConnectionDB.prototype.searchForClosest = function(conn, maxRadius, }; /** - * Initialize a set of connection DBs for a specified workspace. - * @param {!Blockly.Workspace} workspace The workspace this DB is for. + * Initialize a set of connection DBs for a workspace. + * @return {!Array.} Array of databases. */ -Blockly.ConnectionDB.init = function(workspace) { +Blockly.ConnectionDB.init = function() { // Create four databases, one for each connection type. var dbList = []; dbList[Blockly.INPUT_VALUE] = new Blockly.ConnectionDB(); dbList[Blockly.OUTPUT_VALUE] = new Blockly.ConnectionDB(); dbList[Blockly.NEXT_STATEMENT] = new Blockly.ConnectionDB(); dbList[Blockly.PREVIOUS_STATEMENT] = new Blockly.ConnectionDB(); - workspace.connectionDBList = dbList; + return dbList; }; diff --git a/core/constants.js b/core/constants.js index f310f1385ff..7d2111e690d 100644 --- a/core/constants.js +++ b/core/constants.js @@ -129,18 +129,6 @@ Blockly.SPRITE = { // Constants below this point are not intended to be changed. -/** - * Required name space for SVG elements. - * @const - */ -Blockly.SVG_NS = 'http://www.w3.org/2000/svg'; - -/** - * Required name space for HTML elements. - * @const - */ -Blockly.HTML_NS = 'http://www.w3.org/1999/xhtml'; - /** * ENUM for a right-facing value input. E.g. 'set item to' or 'return'. * @const diff --git a/core/contextmenu.js b/core/contextmenu.js index bd8b38f8e06..489a25b5829 100644 --- a/core/contextmenu.js +++ b/core/contextmenu.js @@ -30,16 +30,19 @@ */ goog.provide('Blockly.ContextMenu'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockCreate'); +goog.require('Blockly.Msg'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.uiMenu'); +goog.require('Blockly.utils.userAgent'); goog.require('Blockly.Xml'); goog.require('goog.events'); -goog.require('goog.math.Coordinate'); goog.require('goog.ui.Menu'); goog.require('goog.ui.MenuItem'); -goog.require('goog.userAgent'); /** @@ -154,7 +157,7 @@ Blockly.ContextMenu.createWidget_ = function(menu) { var div = Blockly.WidgetDiv.DIV; menu.render(div); var menuDom = menu.getElement(); - Blockly.utils.addClass(menuDom, 'blocklyContextMenu'); + Blockly.utils.dom.addClass(menuDom, 'blocklyContextMenu'); // Prevent system context menu when right-clicking a Blockly context menu. Blockly.bindEventWithChecks_( menuDom, 'contextmenu', null, Blockly.utils.noEvent); @@ -280,7 +283,7 @@ Blockly.ContextMenu.blockDuplicateOption = function(block) { */ Blockly.ContextMenu.blockCommentOption = function(block) { var commentOption = { - enabled: !goog.userAgent.IE + enabled: !Blockly.utils.userAgent.IE }; // If there's already a comment, add an option to delete it. if (block.comment) { @@ -360,7 +363,7 @@ Blockly.ContextMenu.workspaceCommentOption = function(ws, e) { var boundingRect = injectionDiv.getBoundingClientRect(); // The client coordinates offset by the injection div's upper left corner. - var clientOffsetPixels = new goog.math.Coordinate( + var clientOffsetPixels = new Blockly.utils.Coordinate( e.clientX - boundingRect.left, e.clientY - boundingRect.top); // The offset in pixels between the main workspace's origin and the upper @@ -369,14 +372,13 @@ Blockly.ContextMenu.workspaceCommentOption = function(ws, e) { // The position of the new comment in pixels relative to the origin of the // main workspace. - var finalOffsetPixels = goog.math.Coordinate.difference(clientOffsetPixels, + var finalOffset = Blockly.utils.Coordinate.difference(clientOffsetPixels, mainOffsetPixels); - // The position of the new comment in main workspace coordinates. - var finalOffsetMainWs = finalOffsetPixels.scale(1 / ws.scale); + finalOffset.scale(1 / ws.scale); - var commentX = finalOffsetMainWs.x; - var commentY = finalOffsetMainWs.y; + var commentX = finalOffset.x; + var commentY = finalOffset.y; comment.moveBy(commentX, commentY); if (ws.rendered) { comment.initSvg(); @@ -388,7 +390,7 @@ Blockly.ContextMenu.workspaceCommentOption = function(ws, e) { var wsCommentOption = { // Foreign objects don't work in IE. Don't let the user create comments // that they won't be able to edit. - enabled: !goog.userAgent.IE + enabled: !Blockly.utils.userAgent.IE }; wsCommentOption.text = Blockly.Msg.ADD_COMMENT; wsCommentOption.callback = function() { diff --git a/core/css.js b/core/css.js index da9648c4d8c..1fa07501195 100644 --- a/core/css.js +++ b/core/css.js @@ -49,11 +49,11 @@ Blockly.Css.Cursor = { Blockly.Css.currentCursor_ = ''; /** - * Large stylesheet added by Blockly.Css.inject. - * @type {Element} + * Has CSS already been injected? + * @type {boolean} * @private */ -Blockly.Css.styleSheet_ = null; +Blockly.Css.injected_ = false; /** * Path to media directory, with any trailing slash removed. @@ -74,13 +74,15 @@ Blockly.Css.mediaPath_ = ''; */ Blockly.Css.inject = function(hasCss, pathToMedia) { // Only inject the CSS once. - if (Blockly.Css.styleSheet_) { + if (Blockly.Css.injected_) { return; } + Blockly.Css.injected_ = true; // Placeholder for cursor rule. Must be first rule (index 0). var text = '.blocklyDraggable {}\n'; if (hasCss) { text += Blockly.Css.CONTENT.join('\n'); + Blockly.Css.CONTENT = null; // Garbage collect 13 KB. if (Blockly.FieldDate) { text += Blockly.FieldDate.CSS.join('\n'); } @@ -88,13 +90,12 @@ Blockly.Css.inject = function(hasCss, pathToMedia) { // Strip off any trailing slash (either Unix or Windows). Blockly.Css.mediaPath_ = pathToMedia.replace(/[\\\/]$/, ''); text = text.replace(/<<>>/g, Blockly.Css.mediaPath_); + // Inject CSS tag at start of head. var cssNode = document.createElement('style'); - document.head.insertBefore(cssNode, document.head.firstChild); - var cssTextNode = document.createTextNode(text); cssNode.appendChild(cssTextNode); - Blockly.Css.styleSheet_ = cssNode.sheet; + document.head.insertBefore(cssNode, document.head.firstChild); }; /** @@ -281,7 +282,7 @@ Blockly.Css.CONTENT = [ 'cursor: -webkit-grab;', '}', - '.blocklyDragging {', + '.blocklyDragging {', /* backup for browsers (e.g. IE11) that don't support grabbing */ 'cursor: url("<<>>/handclosed.cur"), auto;', 'cursor: grabbing;', @@ -646,10 +647,9 @@ Blockly.Css.CONTENT = [ 'padding: 0 !important;', '}', - /* Override the default Closure URL. */ '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,', '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {', - 'background: url(<<>>/sprites.png) no-repeat -48px -16px !important;', + 'background: url(<<>>/sprites.png) no-repeat -48px -16px;', '}', /* Category tree in Toolbox. */ @@ -963,8 +963,6 @@ Blockly.Css.CONTENT = [ '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon, ', '.blocklyDropDownDiv .goog-option-selected .goog-menuitem-checkbox, ', '.blocklyDropDownDiv .goog-option-selected .goog-menuitem-icon {', - /* Client apps may override the URL at which they serve the sprite. */ - 'background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -512px 0;', 'position: static;', /* Scroll with the menu. */ 'float: left;', 'margin-left: -24px;', diff --git a/core/dragged_connection_manager.js b/core/dragged_connection_manager.js index 7b7947a43f6..4b260c24f5e 100644 --- a/core/dragged_connection_manager.js +++ b/core/dragged_connection_manager.js @@ -26,11 +26,9 @@ goog.provide('Blockly.DraggedConnectionManager'); -goog.require('Blockly.BlockAnimations'); +goog.require('Blockly.blockAnimations'); goog.require('Blockly.RenderedConnection'); -goog.require('goog.math.Coordinate'); - /** * Class that controls updates to connections during drags. It is primarily @@ -151,7 +149,7 @@ Blockly.DraggedConnectionManager.prototype.applyConnections = function() { // Determine which connection is inferior (lower in the source stack). var inferiorConnection = this.localConnection_.isSuperior() ? this.closestConnection_ : this.localConnection_; - Blockly.BlockAnimations.connectionUiEffect( + Blockly.blockAnimations.connectionUiEffect( inferiorConnection.getSourceBlock()); // Bring the just-edited stack to the front. var rootBlock = this.topBlock_.getRootBlock(); @@ -163,7 +161,7 @@ Blockly.DraggedConnectionManager.prototype.applyConnections = function() { /** * Update highlighted connections based on the most recent move location. - * @param {!goog.math.Coordinate} dxy Position relative to drag start, + * @param {!Blockly.utils.Coordinate} dxy Position relative to drag start, * in workspace units. * @param {?number} deleteArea One of {@link Blockly.DELETE_AREA_TRASH}, * {@link Blockly.DELETE_AREA_TOOLBOX}, or {@link Blockly.DELETE_AREA_NONE}. @@ -236,7 +234,7 @@ Blockly.DraggedConnectionManager.prototype.initAvailableConnections_ = function( /** * Find the new closest connection, and update internal state in response. - * @param {!goog.math.Coordinate} dxy Position relative to the drag start, + * @param {!Blockly.utils.Coordinate} dxy Position relative to the drag start, * in workspace units. * @return {boolean} Whether the closest connection has changed. * @private diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 1836214dc02..62e31079478 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -28,11 +28,11 @@ goog.provide('Blockly.DropDownDiv'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.math'); -goog.require('goog.dom'); goog.require('goog.style'); + /** * Class for drop-down div. * @constructor @@ -139,6 +139,8 @@ Blockly.DropDownDiv.createDom = function() { div.appendChild(arrow); Blockly.DropDownDiv.arrow_ = arrow; + Blockly.DropDownDiv.DIV_.style.opacity = 0; + // Transition animation for transform: translate() and opacity. Blockly.DropDownDiv.DIV_.style.transition = 'transform ' + Blockly.DropDownDiv.ANIMATION_TIME + 's, ' + @@ -228,10 +230,10 @@ Blockly.DropDownDiv.showPositionedByBlock = function(field, block, * by a particular field. The primary position will be below the field, * and the secondary position above the field. Drop-down will be * constrained to the block's workspace. - * @param {Object} owner The object showing the drop-down. + * @param {!Object} owner The object showing the drop-down. * @param {Function=} opt_onHide Optional callback for when the drop-down is * hidden. - * @param {number} opt_secondaryYOffset Optional Y offset for above-block + * @param {number=} opt_secondaryYOffset Optional Y offset for above-block * positioning. * @return {boolean} True if the menu rendered below block; false if above. */ @@ -250,7 +252,7 @@ Blockly.DropDownDiv.showPositionedByField = function(owner, // Set bounds to workspace; show the drop-down. Blockly.DropDownDiv.positionToField_ = true; Blockly.DropDownDiv.setBoundsElement( - owner.sourceBlock_.workspace.getParentSvg().parentNode); + owner.getSourceBlock().workspace.getParentSvg().parentNode); return Blockly.DropDownDiv.show( owner, primaryX, primaryY, secondaryX, secondaryY, opt_onHide); }; @@ -272,17 +274,18 @@ Blockly.DropDownDiv.showPositionedByField = function(owner, * @param {Function=} opt_onHide Optional callback for when the drop-down is hidden * @return {boolean} True if the menu rendered at the primary origin point. */ -Blockly.DropDownDiv.show = function(owner, primaryX, primaryY, secondaryX, secondaryY, opt_onHide) { +Blockly.DropDownDiv.show = function(owner, primaryX, primaryY, + secondaryX, secondaryY, opt_onHide) { Blockly.DropDownDiv.owner_ = owner; Blockly.DropDownDiv.onHide_ = opt_onHide; - var metrics = Blockly.DropDownDiv.getPositionMetrics(primaryX, primaryY, secondaryX, secondaryY); - // Update arrow CSS + var metrics = Blockly.DropDownDiv.getPositionMetrics(primaryX, primaryY, + secondaryX, secondaryY); + // Update arrow CSS. Blockly.DropDownDiv.arrow_.style.transform = 'translate(' + - metrics.arrowX + 'px,' + metrics.arrowY + 'px) rotate(45deg)'; - Blockly.DropDownDiv.arrow_.setAttribute('class', - metrics.arrowAtTop ? 'blocklyDropDownArrow arrowTop' : 'blocklyDropDownArrow arrowBottom'); - Blockly.DropDownDiv.arrow_.style.display = - metrics.arrowVisible ? '' : 'none'; + metrics.arrowX + 'px,' + metrics.arrowY + 'px) rotate(45deg)'; + Blockly.DropDownDiv.arrow_.setAttribute('class', metrics.arrowAtTop ? + 'blocklyDropDownArrow arrowTop' : 'blocklyDropDownArrow arrowBottom'); + Blockly.DropDownDiv.arrow_.style.display = metrics.arrowVisible ? '' : 'none'; // When we change `translate` multiple times in close succession, // Chrome may choose to wait and apply them all at once. @@ -328,7 +331,8 @@ Blockly.DropDownDiv.getBoundsInfo_ = function() { * @param {number} secondaryY Secondary/alternative origin point y, in absolute px * @return {Object} Various final metrics, including rendered positions for drop-down and arrow. */ -Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, secondaryX, secondaryY) { +Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, + secondaryX, secondaryY) { var boundsInfo = Blockly.DropDownDiv.getBoundsInfo_(); var div = Blockly.DropDownDiv.DIV_; var divSize = goog.style.getSize(div); @@ -364,14 +368,14 @@ Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, secondaryX // dropdown should appear centered relative to the desired origin point. renderX -= divSize.width / 2; // Fit horizontally in the bounds. - renderX = Blockly.utils.clampNumber( + renderX = Blockly.utils.math.clamp( boundsInfo.left, renderX, boundsInfo.right - divSize.width); // Calculate the absolute arrow X. The arrow wants to be as close to the // origin point as possible. The arrow may not be centered in the dropdown div. var absoluteArrowX = centerX - Blockly.DropDownDiv.ARROW_SIZE / 2; // Keep in overall bounds - absoluteArrowX = Blockly.utils.clampNumber( + absoluteArrowX = Blockly.utils.math.clamp( boundsInfo.left, absoluteArrowX, boundsInfo.right); // Convert the arrow position to be relative to the top left corner of the div. @@ -379,7 +383,7 @@ Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, secondaryX // Pad the arrow by some pixels, primarily so that it doesn't render on top // of a rounded border. - relativeArrowX = Blockly.utils.clampNumber( + relativeArrowX = Blockly.utils.math.clamp( Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING, relativeArrowX, divSize.width - Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING - @@ -456,8 +460,19 @@ Blockly.DropDownDiv.hideWithoutAnimation = function() { if (!Blockly.DropDownDiv.isVisible()) { return; } - Blockly.DropDownDiv.animateOutTimer_ && window.clearTimeout(Blockly.DropDownDiv.animateOutTimer_); - Blockly.DropDownDiv.positionInternal_(); + if (Blockly.DropDownDiv.animateOutTimer_) { + clearTimeout(Blockly.DropDownDiv.animateOutTimer_); + } + + // Reset style properties in case this gets called directly + // instead of hide() - see discussion on #2551. + var div = Blockly.DropDownDiv.DIV_; + div.style.transform = ''; + div.style.left = ''; + div.style.top = ''; + div.style.opacity = 0; + div.style.display = 'none'; + Blockly.DropDownDiv.clearContent(); Blockly.DropDownDiv.owner_ = null; if (Blockly.DropDownDiv.onHide_) { @@ -469,37 +484,36 @@ Blockly.DropDownDiv.hideWithoutAnimation = function() { /** * Set the dropdown div's position. - * @param {number} initialX Initial Horizontal location (window coordinates, not body). - * @param {number} initialY Initial Vertical location (window coordinates, not body). - * @param {number} finalX Final Horizontal location (window coordinates, not body). - * @param {number} finalY Final Vertical location (window coordinates, not body). + * @param {number} initialX Initial Horizontal location + * (window coordinates, not body). + * @param {number} initialY Initial Vertical location + * (window coordinates, not body). + * @param {number} finalX Final Horizontal location + * (window coordinates, not body). + * @param {number} finalY Final Vertical location + * (window coordinates, not body). * @private */ Blockly.DropDownDiv.positionInternal_ = function(initialX, initialY, finalX, finalY) { - initialX = initialX == null ? initialX : Math.floor(initialX); - initialY = initialY == null ? initialY : Math.floor(initialY); - finalX = finalX == null ? finalX : Math.floor(finalX); - finalY = finalY == null ? finalY : Math.floor(finalY); + initialX = Math.floor(initialX); + initialY = Math.floor(initialY); + finalX = Math.floor(finalX); + finalY = Math.floor(finalY); var div = Blockly.DropDownDiv.DIV_; // First apply initial translation. - div.style.left = initialX != null ? initialX + 'px' : ''; - div.style.top = initialY != null ? initialY + 'px' : ''; - if (finalX != null) { - // Show the div. - div.style.display = 'block'; - div.style.opacity = 1; - // Add final translate, animated through `transition`. - // Coordinates are relative to (initialX, initialY), - // where the drop-down is absolutely positioned. - var dx = (finalX - initialX); - var dy = (finalY - initialY); - div.style.transform = 'translate(' + dx + 'px,' + dy + 'px)'; - } else { - // Hide the div. - div.style.display = 'none'; - div.style.transform = ''; - } + div.style.left = initialX + 'px'; + div.style.top = initialY + 'px'; + + // Show the div. + div.style.display = 'block'; + div.style.opacity = 1; + // Add final translate, animated through `transition`. + // Coordinates are relative to (initialX, initialY), + // where the drop-down is absolutely positioned. + var dx = finalX - initialX; + var dy = finalY - initialY; + div.style.transform = 'translate(' + dx + 'px,' + dy + 'px)'; }; /** @@ -512,7 +526,7 @@ Blockly.DropDownDiv.repositionForWindowResize = function() { // when a field is focused, the soft keyboard opens triggering a window resize // event and we want the dropdown div to stick around so users can type into it. if (Blockly.DropDownDiv.owner_) { - var block = Blockly.DropDownDiv.owner_.sourceBlock_; + var block = Blockly.DropDownDiv.owner_.getSourceBlock(); var scale = block.workspace.scale; var bBox = { width: Blockly.DropDownDiv.positionToField_ ? diff --git a/core/events.js b/core/events.js index be0612c66cc..178a922d690 100644 --- a/core/events.js +++ b/core/events.js @@ -402,7 +402,7 @@ Blockly.Events.fromJson = function(json, workspace) { * Enable/disable a block depending on whether it is properly connected. * Use this on applications where all blocks should be connected to a top block. * Recommend setting the 'disable' option to 'false' in the config so that - * users don't try to reenable disabled orphan blocks. + * users don't try to re-enable disabled orphan blocks. * @param {!Blockly.Events.Abstract} event Custom data for event. */ Blockly.Events.disableOrphans = function(event) { @@ -411,15 +411,16 @@ Blockly.Events.disableOrphans = function(event) { var workspace = Blockly.Workspace.getById(event.workspaceId); var block = workspace.getBlockById(event.blockId); if (block) { - if (block.getParent() && !block.getParent().disabled) { + var parent = block.getParent(); + if (parent && parent.isEnabled()) { var children = block.getDescendants(false); for (var i = 0, child; child = children[i]; i++) { - child.setDisabled(false); + child.setEnabled(true); } } else if ((block.outputConnection || block.previousConnection) && !workspace.isDragging()) { do { - block.setDisabled(true); + block.setEnabled(false); block = block.getNextBlock(); } while (block); } diff --git a/core/events_abstract.js b/core/events_abstract.js index 4fa10c82c2c..387276cf8d9 100644 --- a/core/events_abstract.js +++ b/core/events_abstract.js @@ -29,6 +29,7 @@ goog.provide('Blockly.Events.Abstract'); goog.require('Blockly.Events'); + /** * Abstract class for an event. * @constructor diff --git a/core/extensions.js b/core/extensions.js index 7b0b3672d96..c15329559ca 100644 --- a/core/extensions.js +++ b/core/extensions.js @@ -36,6 +36,7 @@ goog.provide('Blockly.Extensions'); goog.require('Blockly.Mutator'); goog.require('Blockly.utils'); + /** * The set of all registered extensions, keyed by extension name/id. * @private @@ -73,7 +74,7 @@ Blockly.Extensions.register = function(name, initFn) { * registered. */ Blockly.Extensions.registerMixin = function(name, mixinObj) { - if (!mixinObj || typeof mixinObj != 'object'){ + if (!mixinObj || typeof mixinObj != 'object') { throw Error('Error: Mixin "' + name + '" must be a object'); } Blockly.Extensions.register(name, function() { diff --git a/core/field.js b/core/field.js index 45083993a04..e0d20035edc 100644 --- a/core/field.js +++ b/core/field.js @@ -28,25 +28,27 @@ goog.provide('Blockly.Field'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Gesture'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.userAgent'); goog.require('goog.math.Size'); goog.require('goog.style'); -goog.require('goog.userAgent'); /** * Abstract class for an editable field. - * @param {string} text The initial content of the field. - * @param {function(string):(string|null|undefined)=} opt_validator An optional - * function that is called to validate user input. See setValidator(). + * @param {*} value The initial value of the field. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a value & returns a validated + * value, or null to abort the change. * @constructor */ -Blockly.Field = function(text, opt_validator) { +Blockly.Field = function(value, opt_validator) { this.size_ = new goog.math.Size(0, Blockly.BlockSvg.MIN_BLOCK_Y); - this.setValue(text); + this.setValue(value); this.setValidator(opt_validator); }; @@ -109,7 +111,6 @@ Blockly.Field.cacheWidths_ = null; */ Blockly.Field.cacheReference_ = 0; - /** * Name of field. Unique within each block. * Static labels are usually unnamed. @@ -124,12 +125,30 @@ Blockly.Field.prototype.name = undefined; Blockly.Field.prototype.maxDisplayLength = 50; /** - * Visible text to display. + * A generic value possessed by the field. + * Should generally be non-null, only null when the field is created. + * @type {*} + * @protected + */ +Blockly.Field.prototype.value_ = null; + +/** + * Text representation of the field's value. Maintained for backwards + * compatibility reasons. * @type {string} * @protected + * @deprecated Use or override getText instead. */ Blockly.Field.prototype.text_ = ''; +/** + * Used to cache the field's tooltip value if setTooltip is called when the + * field is not yet initialized. Is *not* guaranteed to be accurate. + * @type {?string} + * @private + */ +Blockly.Field.prototype.tooltip_ = null; + /** * Block this field is attached to. Starts as null, then set in init. * @type {Blockly.Block} @@ -137,6 +156,13 @@ Blockly.Field.prototype.text_ = ''; */ Blockly.Field.prototype.sourceBlock_ = null; +/** + * Does this block need to be re-rendered? + * @type {boolean} + * @private + */ +Blockly.Field.prototype.isDirty_ = true; + /** * Is the field visible, or hidden due to the block being collapsed? * @type {boolean} @@ -165,10 +191,24 @@ Blockly.Field.prototype.clickTarget_ = null; Blockly.Field.NBSP = '\u00A0'; /** - * Editable fields are saved by the XML renderer, non-editable fields are not. + * Editable fields usually show some sort of UI indicating they are editable. + * They will also be saved by the XML renderer. + * @type {boolean} + * @const + * @default */ Blockly.Field.prototype.EDITABLE = true; +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. This is not the + * case by default so that SERIALIZABLE is backwards compatible. + * @type {boolean} + * @const + * @default + */ +Blockly.Field.prototype.SERIALIZABLE = false; + /** * Attach this field to a block. * @param {!Blockly.Block} block The block containing this field. @@ -181,63 +221,136 @@ Blockly.Field.prototype.setSourceBlock = function(block) { }; /** - * Install this field on a block. + * Get the block this field is attached to. + * @return {Blockly.Block} The block containing this field. + */ +Blockly.Field.prototype.getSourceBlock = function() { + return this.sourceBlock_; +}; + +/** + * Initialize everything to render this field. Override + * methods initModel and initView rather than this method. + * @package */ Blockly.Field.prototype.init = function() { if (this.fieldGroup_) { // Field has already been initialized once. return; } - // Build the DOM. - this.fieldGroup_ = Blockly.utils.createSvgElement('g', {}, null); - if (!this.visible_) { + this.fieldGroup_ = Blockly.utils.dom.createSvgElement('g', {}, null); + if (!this.isVisible()) { this.fieldGroup_.style.display = 'none'; } - this.borderRect_ = Blockly.utils.createSvgElement('rect', + this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_); + this.initView(); + this.updateEditable(); + this.setTooltip(this.tooltip_); + this.bindEvents_(); + this.initModel(); +}; + +/** + * Create the block UI for this field. + * @package + */ +Blockly.Field.prototype.initView = function() { + this.createBorderRect_(); + this.createTextElement_(); +}; + +/** + * Create a field border rect element. Not to be overridden by subclasses. + * Instead modify the result of the function inside initView, or create a + * separate function to call. + * @protected + */ +Blockly.Field.prototype.createBorderRect_ = function() { + this.borderRect_ = Blockly.utils.dom.createSvgElement('rect', { 'rx': 4, 'ry': 4, 'x': -Blockly.BlockSvg.SEP_SPACE_X / 2, 'y': 0, - 'height': 16 + 'height': 16, + 'width': this.size_.width + Blockly.BlockSvg.SEP_SPACE_X }, this.fieldGroup_); - /** @type {!Element} */ - this.textElement_ = Blockly.utils.createSvgElement('text', - {'class': 'blocklyText', 'y': this.size_.height - 12.5}, - this.fieldGroup_); +}; - this.updateEditable(); +/** + * Create a field text element. Not to be overridden by subclasses. Instead + * modify the result of the function inside initView, or create a separate + * function to call. + * @protected + */ +Blockly.Field.prototype.createTextElement_ = function() { + this.textElement_ = Blockly.utils.dom.createSvgElement('text', + { + 'class': 'blocklyText', + 'y': this.size_.height - 12.5 + }, this.fieldGroup_); + this.textContent_ = document.createTextNode(''); + this.textElement_.appendChild(this.textContent_); +}; - this.clickTarget_ = this.getSvgRoot(); - this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_); +/** + * Bind events to the field. Can be overridden by subclasses if they need to do + * custom input handling. + * @protected + */ +Blockly.Field.prototype.bindEvents_ = function() { + Blockly.Tooltip.bindMouseEvents(this.getClickTarget_()); this.mouseDownWrapper_ = Blockly.bindEventWithChecks_( - this.clickTarget_, 'mousedown', this, this.onMouseDown_); + this.getClickTarget_(), 'mousedown', this, this.onMouseDown_); }; /** * Initializes the model of the field after it has been installed on a block. * No-op by default. + * @package */ Blockly.Field.prototype.initModel = function() { }; /** - * Dispose of all DOM objects belonging to this editable field. + * Sets the field's value based on the given XML element. Should only be + * called by Blockly.Xml. + * @param {!Element} fieldElement The element containing info about the + * field's state. + * @package + */ +Blockly.Field.prototype.fromXml = function(fieldElement) { + this.setValue(fieldElement.textContent); +}; + +/** + * Serializes this field's value to XML. Should only be called by Blockly.Xml. + * @param {!Element} fieldElement The element to populate with info about the + * field's state. + * @return {!Element} The element containing info about the field's state. + * @package + */ +Blockly.Field.prototype.toXml = function(fieldElement) { + fieldElement.textContent = this.getValue(); + return fieldElement; +}; + +/** + * Dispose of all DOM objects and events belonging to this editable field. + * @package */ Blockly.Field.prototype.dispose = function() { + Blockly.DropDownDiv.hideIfOwner(this); + Blockly.WidgetDiv.hideIfOwner(this); + if (this.mouseDownWrapper_) { Blockly.unbindEvent_(this.mouseDownWrapper_); - this.mouseDownWrapper_ = null; - } - this.sourceBlock_ = null; - if (this.fieldGroup_) { - Blockly.utils.removeNode(this.fieldGroup_); - this.fieldGroup_ = null; } - this.textElement_ = null; - this.borderRect_ = null; - this.validator_ = null; + + Blockly.utils.dom.removeNode(this.fieldGroup_); + + this.disposed = true; }; /** @@ -249,20 +362,28 @@ Blockly.Field.prototype.updateEditable = function() { return; } if (this.sourceBlock_.isEditable()) { - Blockly.utils.addClass(group, 'blocklyEditableText'); - Blockly.utils.removeClass(group, 'blocklyNonEditableText'); + Blockly.utils.dom.addClass(group, 'blocklyEditableText'); + Blockly.utils.dom.removeClass(group, 'blocklyNonEditableText'); group.style.cursor = this.CURSOR; } else { - Blockly.utils.addClass(group, 'blocklyNonEditableText'); - Blockly.utils.removeClass(group, 'blocklyEditableText'); + Blockly.utils.dom.addClass(group, 'blocklyNonEditableText'); + Blockly.utils.dom.removeClass(group, 'blocklyEditableText'); group.style.cursor = ''; } }; +/** + * Check whether this field defines the showEditor_ function. + * @return {boolean} Whether this field is clickable. + */ +Blockly.Field.prototype.isClickable = function() { + return !!this.sourceBlock_ && this.sourceBlock_.isEditable() && + !!this.showEditor_ && (typeof this.showEditor_ === 'function'); +}; + /** * Check whether this field is currently editable. Some fields are never - * editable (e.g. text labels). Those fields are not serialized to XML. Other - * fields may be editable, and therefore serialized, but may exist on + * EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on * non-editable blocks. * @return {boolean} Whether this field is editable and on an editable block */ @@ -270,6 +391,26 @@ Blockly.Field.prototype.isCurrentlyEditable = function() { return this.EDITABLE && !!this.sourceBlock_ && this.sourceBlock_.isEditable(); }; +/** + * Check whether this field should be serialized by the XML renderer. + * Handles the logic for backwards compatibility and incongruous states. + * @return {boolean} Whether this field should be serialized or not. + */ +Blockly.Field.prototype.isSerializable = function() { + var isSerializable = false; + if (this.name) { + if (this.SERIALIZABLE) { + isSerializable = true; + } else if (this.EDITABLE) { + console.warn('Detected an editable field that was not serializable.' + + ' Please define SERIALIZABLE property as true on all editable custom' + + ' fields. Proceeding with serialization.'); + isSerializable = true; + } + } + return isSerializable; +}; + /** * Gets whether this editable field is visible or not. * @return {boolean} True if visible. @@ -279,8 +420,10 @@ Blockly.Field.prototype.isVisible = function() { }; /** - * Sets whether this editable field is visible or not. + * Sets whether this editable field is visible or not. Should only be called + * by input.setVisible. * @param {boolean} visible True if visible. + * @package */ Blockly.Field.prototype.setVisible = function(visible) { if (this.visible_ == visible) { @@ -290,7 +433,6 @@ Blockly.Field.prototype.setVisible = function(visible) { var root = this.getSvgRoot(); if (root) { root.style.display = visible ? 'block' : 'none'; - this.render_(); } }; @@ -298,14 +440,15 @@ Blockly.Field.prototype.setVisible = function(visible) { * Sets a new validation function for editable fields, or clears a previously * set validator. * - * The validator function takes in the text form of the users input, and - * optionally returns the accepted field text. Alternatively, if the function - * returns null, the field value change aborts. If the function does not return - * anything (or returns undefined), the input value is accepted as valid. This - * is a shorthand for fields using the validator function call as a field-level - * change event notification. + * The validator function takes in the new field value, and returns + * validated value. The validated value could be the input value, a modified + * version of the input value, or null to abort the change. + * + * If the function does not return anything (or returns undefined) the new + * value is accepted as valid. This is to allow for fields using the + * validated founction as a field-level change event notification. * - * @param {?function(string):(string|null|undefined)} handler The validator + * @param {Function=} handler The validator * function or null to clear a previous validator. */ Blockly.Field.prototype.setValidator = function(handler) { @@ -324,6 +467,8 @@ Blockly.Field.prototype.getValidator = function() { * Validates a change. Does nothing. Subclasses may override this. * @param {string} text The user's text. * @return {string} No change needed. + * @deprecated May 2019. Override doClassValidation and other relevant 'do' + * functions instead. */ Blockly.Field.prototype.classValidator = function(text) { return text; @@ -334,6 +479,7 @@ Blockly.Field.prototype.classValidator = function(text) { * function for the field's class and its parents. * @param {string} text Proposed text. * @return {?string} Revised text, or null if invalid. + * @deprecated May 2019. setValue now contains all relevant logic. */ Blockly.Field.prototype.callValidator = function(text) { var classResult = this.classValidator(text); @@ -366,27 +512,45 @@ Blockly.Field.prototype.getSvgRoot = function() { }; /** - * Draws the border with the correct width. - * Saves the computed width in a property. + * Updates the field to match the colour/style of the block. Should only be + * called by BlockSvg.updateColour(). + * @package + */ +Blockly.Field.prototype.updateColour = function() { + // Non-abstract sub-classes may wish to implement this. See FieldDropdown. +}; + +/** + * Used by getSize() to move/resize any dom elements, and get the new size. + * + * All rendering that has an effect on the size/shape of the block should be + * done here, and should be triggered by getSize(). * @protected */ Blockly.Field.prototype.render_ = function() { - if (!this.visible_) { - this.size_.width = 0; - return; - } - - // Replace the text. - this.textElement_.textContent = this.getDisplayText_(); - this.updateWidth(); + this.textContent_.nodeValue = this.getDisplayText_(); + this.updateSize_(); }; /** - * Updates the width of the field. This calls getCachedWidth which won't cache - * the approximated width on IE/Edge when `getComputedTextLength` fails. Once - * it eventually does succeed, the result will be cached. + * Updates the width of the field. Redirects to updateSize_(). + * @deprecated May 2019 Use Blockly.Field.updateSize_() to force an update + * to the size of the field, or Blockly.Field.getCachedWidth() to check the + * size of the field.. */ Blockly.Field.prototype.updateWidth = function() { + console.warn('Deprecated call to updateWidth, call' + + ' Blockly.Field.updateSize_ to force an update to the size of the' + + ' field, or Blockly.Field.getCachedWidth() to check the size of the' + + ' field.'); + this.updateSize_(); +}; + +/** + * Updates the size of the field based on the text. + * @protected + */ +Blockly.Field.prototype.updateSize_ = function() { var width = Blockly.Field.getCachedWidth(this.textElement_); if (this.borderRect_) { this.borderRect_.setAttribute('width', @@ -414,7 +578,7 @@ Blockly.Field.getCachedWidth = function(textElement) { // Attempt to compute fetch the width of the SVG text element. try { - if (goog.userAgent.IE || goog.userAgent.EDGE) { + if (Blockly.utils.userAgent.IE || Blockly.utils.userAgent.EDGE) { width = textElement.getBBox().width; } else { width = textElement.getComputedTextLength(); @@ -458,10 +622,23 @@ Blockly.Field.stopCache = function() { /** * Returns the height and width of the field. + * + * This should *in general* be the only place render_ gets called from. * @return {!goog.math.Size} Height and width. */ Blockly.Field.prototype.getSize = function() { - if (!this.size_.width) { + if (!this.isVisible()) { + return new goog.math.Size(0, 0); + } + + if (this.isDirty_) { + this.render_(); + this.isDirty_ = false; + } else if (this.visible_ && this.size_.width == 0) { + // If the field is not visible the width will be 0 as well, one of the + // problems with the old system. + console.warn('Deprecated use of setting size_.width to 0 to rerender a' + + ' field. Set field.isDirty_ to true instead.'); this.render_(); } return this.size_; @@ -546,9 +723,7 @@ Blockly.Field.prototype.setText = function(newText) { * @package */ Blockly.Field.prototype.forceRerender = function() { - // Set width to 0 to force a rerender of this field. - this.size_.width = 0; - + this.isDirty_ = true; if (this.sourceBlock_ && this.sourceBlock_.rendered) { this.sourceBlock_.render(); this.sourceBlock_.bumpNeighbours_(); @@ -556,33 +731,120 @@ Blockly.Field.prototype.forceRerender = function() { }; /** - * By default there is no difference between the human-readable text and - * the language-neutral values. Subclasses (such as dropdown) may define this. - * @return {string} Current value. - */ -Blockly.Field.prototype.getValue = function() { - return this.getText(); -}; - -/** - * By default there is no difference between the human-readable text and - * the language-neutral values. Subclasses (such as dropdown) may define this. - * @param {string} newValue New value. + * Used to change the value of the field. Handles validation and events. + * Subclasses should override doClassValidation_ and doValueUpdate_ rather + * than this method. + * @param {*} newValue New value. */ Blockly.Field.prototype.setValue = function(newValue) { + var doLogging = false; if (newValue === null) { - // No change if null. + doLogging && console.log('null, return'); + // Not a valid value to check. + return; + } + + var validatedValue = this.doClassValidation_(newValue); + // Class validators might accidentally forget to return, we'll ignore that. + newValue = this.processValidation_(newValue, validatedValue); + if (newValue instanceof Error) { + doLogging && console.log('invalid class validation, return'); return; } + + var localValidator = this.getValidator(); + if (localValidator) { + validatedValue = localValidator.call(this, newValue); + // Local validators might accidentally forget to return, we'll ignore that. + newValue = this.processValidation_(newValue, validatedValue); + if (newValue instanceof Error) { + doLogging && console.log('invalid local validation, return'); + return; + } + } var oldValue = this.getValue(); - if (oldValue == newValue) { + if (oldValue === newValue) { + doLogging && console.log('same, return'); + // No change. return; } + if (this.sourceBlock_ && Blockly.Events.isEnabled()) { Blockly.Events.fire(new Blockly.Events.BlockChange( this.sourceBlock_, 'field', this.name, oldValue, newValue)); } - this.setText(newValue); + this.doValueUpdate_(newValue); + if (this.isDirty_) { + this.forceRerender(); + } + doLogging && console.log(this.value_); +}; + +/** + * Process the result of validation. + * @param {*} newValue New value. + * @param {*} validatedValue Validated value. + * @return {*} New value, or an Error object. + * @private + */ +Blockly.Field.prototype.processValidation_ = function(newValue, + validatedValue) { + if (validatedValue === null) { + this.doValueInvalid_(newValue); + if (this.isDirty_) { + this.forceRerender(); + } + return Error(); + } + if (validatedValue !== undefined) { + newValue = validatedValue; + } + return newValue; +}; + +/** + * Get the current value of the field. + * @return {*} Current value. + */ +Blockly.Field.prototype.getValue = function() { + return this.value_; +}; + +/** + * Used to validate a value. Returns input by default. Can be overridden by + * subclasses, see FieldDropdown. + * @param {*} newValue The value to be validated. + * @return {*} The validated value, same as input by default. + * @protected + */ +Blockly.Field.prototype.doClassValidation_ = function(newValue) { + // For backwards compatibility. + newValue = this.classValidator(newValue); + return newValue; +}; + +/** + * Used to update the value of a field. Can be overridden by subclasses to do + * custom storage of values/updating of external things. + * @param {*} newValue The value to be saved. + * @protected + */ +Blockly.Field.prototype.doValueUpdate_ = function(newValue) { + this.value_ = newValue; + this.isDirty_ = true; + // For backwards compatibility. + this.text_ = String(newValue); +}; + +/** + * Used to notify the field an invalid value was input. Can be overidden by + * subclasses, see FieldTextInput. + * No-op by default. + * @param {*} _invalidValue The input value that was determined to be invalid. + * @protected + */ +Blockly.Field.prototype.doValueInvalid_ = function(_invalidValue) { + // NOP }; /** @@ -602,11 +864,22 @@ Blockly.Field.prototype.onMouseDown_ = function(e) { /** * Change the tooltip text for this field. - * @param {string|!Element} _newTip Text for tooltip or a parent element to - * link to for its tooltip. - */ -Blockly.Field.prototype.setTooltip = function(_newTip) { - // Non-abstract sub-classes may wish to implement this. See FieldLabel. + * @param {string|function|!Element} newTip Text for tooltip or a parent + * element to link to for its tooltip. + */ +Blockly.Field.prototype.setTooltip = function(newTip) { + var clickTarget = this.getClickTarget_(); + if (!clickTarget) { + // Field has not been initialized yet. + this.tooltip_ = newTip; + return; + } + + if (!newTip && newTip !== '') { // If null or undefined. + clickTarget.tooltip = this.sourceBlock_; + } else { + clickTarget.tooltip = newTip; + } }; /** diff --git a/core/field_angle.js b/core/field_angle.js index bf9d6b81f45..75e65fb6273 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -28,28 +28,26 @@ goog.provide('Blockly.FieldAngle'); goog.require('Blockly.DropDownDiv'); goog.require('Blockly.FieldTextInput'); -goog.require('Blockly.utils'); - -goog.require('goog.userAgent'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.math'); +goog.require('Blockly.utils.userAgent'); /** * Class for an editable angle field. - * @param {(string|number)=} opt_value The initial content of the field. The - * value should cast to a number, and if it does not, '0' will be used. - * @param {Function=} opt_validator An optional function that is called - * to validate any constraints on what the user entered. Takes the new - * text as an argument and returns the accepted text or null to abort - * the change. + * @param {string|number=} opt_value The initial value of the field. Should cast + * to a number. Defaults to 0. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a number & returns a + * validated number, or null to abort the change. * @extends {Blockly.FieldTextInput} * @constructor */ Blockly.FieldAngle = function(opt_value, opt_validator) { - // Add degree symbol: '360°' (LTR) or '°360' (RTL) - this.symbol_ = Blockly.utils.createSvgElement('tspan', {}, null); - this.symbol_.appendChild(document.createTextNode('\u00B0')); - - opt_value = (opt_value && !isNaN(opt_value)) ? String(opt_value) : '0'; + opt_value = this.doClassValidation_(opt_value); + if (opt_value === null) { + opt_value = 0; + } Blockly.FieldAngle.superClass_.constructor.call( this, opt_value, opt_validator); }; @@ -66,6 +64,14 @@ Blockly.FieldAngle.fromJson = function(options) { return new Blockly.FieldAngle(options['angle']); }; +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const + */ +Blockly.FieldAngle.prototype.SERIALIZABLE = true; + /** * Round angles to the nearest 15 degrees when using mouse. * Set to 0 to disable rounding. @@ -113,89 +119,82 @@ Blockly.FieldAngle.WRAP = 360; Blockly.FieldAngle.RADIUS = Blockly.FieldAngle.HALF - 1; /** - * Adds degree symbol and recalculates width. - * Saves the computed width in a property. - * @private + * Create the block UI for this field. + * @package */ -Blockly.FieldAngle.prototype.render_ = function() { - if (!this.visible_) { - this.size_.width = 0; - return; - } - - // Update textElement. - this.textElement_.textContent = this.getDisplayText_(); - - // Insert degree symbol. - if (this.sourceBlock_.RTL) { - this.textElement_.insertBefore(this.symbol_, this.textElement_.firstChild); - } else { - this.textElement_.appendChild(this.symbol_); - } - this.updateWidth(); +Blockly.FieldAngle.prototype.initView = function() { + Blockly.FieldAngle.superClass_.initView.call(this); + // Add the degree symbol to the left of the number, even in RTL (issue #2380) + this.symbol_ = Blockly.utils.dom.createSvgElement('tspan', {}, null); + this.symbol_.appendChild(document.createTextNode('\u00B0')); + this.textElement_.appendChild(this.symbol_); }; /** - * Clean up this FieldAngle, as well as the inherited FieldTextInput. - * @return {!Function} Closure to call on destruction of the WidgetDiv. + * Updates the graph when the field rerenders. * @private */ -Blockly.FieldAngle.prototype.dispose_ = function() { - var thisField = this; - return function() { - Blockly.FieldAngle.superClass_.dispose_.call(thisField)(); - thisField.gauge_ = null; - if (thisField.clickWrapper_) { - Blockly.unbindEvent_(thisField.clickWrapper_); - } - if (thisField.moveWrapper1_) { - Blockly.unbindEvent_(thisField.moveWrapper1_); - } - if (thisField.moveWrapper2_) { - Blockly.unbindEvent_(thisField.moveWrapper2_); - } - }; +Blockly.FieldAngle.prototype.render_ = function() { + Blockly.FieldAngle.superClass_.render_.call(this); + this.updateGraph_(); }; /** - * Show the inline free-text editor on top of the text. + * Create and show the angle field's editor. * @private */ Blockly.FieldAngle.prototype.showEditor_ = function() { - var noFocus = - goog.userAgent.MOBILE || goog.userAgent.ANDROID || goog.userAgent.IPAD; // Mobile browsers have issues with in-line textareas (focus & keyboards). + var noFocus = + Blockly.utils.userAgent.MOBILE || + Blockly.utils.userAgent.ANDROID || + Blockly.utils.userAgent.IPAD; Blockly.FieldAngle.superClass_.showEditor_.call(this, noFocus); - // If there is an existing drop-down someone else owns, hide it immediately and clear it. - Blockly.DropDownDiv.hideWithoutAnimation(); - Blockly.DropDownDiv.clearContent(); - var div = Blockly.DropDownDiv.getContentDiv(); + var editor = this.dropdownCreate_(); + Blockly.DropDownDiv.getContentDiv().appendChild(editor); + + var border = this.sourceBlock_.getColourBorder(); + border = border.colourBorder || border.colourLight; + Blockly.DropDownDiv.setColour(this.sourceBlock_.getColour(), border); + + Blockly.DropDownDiv.showPositionedByField( + this, this.dropdownDispose_.bind(this)); + + this.updateGraph_(); +}; - // Build the SVG DOM. - var svg = Blockly.utils.createSvgElement('svg', { - 'xmlns': 'http://www.w3.org/2000/svg', - 'xmlns:html': 'http://www.w3.org/1999/xhtml', - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', +/** + * Create the angle dropdown editor. + * @return {!Element} The newly created angle picker. + * @private + */ +Blockly.FieldAngle.prototype.dropdownCreate_ = function() { + var svg = Blockly.utils.dom.createSvgElement('svg', { + 'xmlns': Blockly.utils.dom.SVG_NS, + 'xmlns:html': Blockly.utils.dom.HTML_NS, + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'height': (Blockly.FieldAngle.HALF * 2) + 'px', 'width': (Blockly.FieldAngle.HALF * 2) + 'px' - }, div); - var circle = Blockly.utils.createSvgElement('circle', { - 'cx': Blockly.FieldAngle.HALF, 'cy': Blockly.FieldAngle.HALF, + }, null); + var circle = Blockly.utils.dom.createSvgElement('circle', { + 'cx': Blockly.FieldAngle.HALF, + 'cy': Blockly.FieldAngle.HALF, 'r': Blockly.FieldAngle.RADIUS, 'class': 'blocklyAngleCircle' }, svg); - this.gauge_ = Blockly.utils.createSvgElement('path', - {'class': 'blocklyAngleGauge'}, svg); - this.line_ = Blockly.utils.createSvgElement('line', { + this.gauge_ = Blockly.utils.dom.createSvgElement('path', { + 'class': 'blocklyAngleGauge' + }, svg); + this.line_ = Blockly.utils.dom.createSvgElement('line', { 'x1': Blockly.FieldAngle.HALF, 'y1': Blockly.FieldAngle.HALF, 'class': 'blocklyAngleLine' }, svg); // Draw markers around the edge. for (var angle = 0; angle < 360; angle += 15) { - Blockly.utils.createSvgElement('line', { + Blockly.utils.dom.createSvgElement('line', { 'x1': Blockly.FieldAngle.HALF + Blockly.FieldAngle.RADIUS, 'y1': Blockly.FieldAngle.HALF, 'x2': Blockly.FieldAngle.HALF + Blockly.FieldAngle.RADIUS - @@ -207,31 +206,35 @@ Blockly.FieldAngle.prototype.showEditor_ = function() { }, svg); } - - Blockly.DropDownDiv.setColour(this.sourceBlock_.getColour(), - this.sourceBlock_.getColour()); - Blockly.DropDownDiv.showPositionedByField(this); // The angle picker is different from other fields in that it updates on // mousemove even if it's not in the middle of a drag. In future we may // change this behaviour. For now, using bindEvent_ instead of // bindEventWithChecks_ allows it to work without a mousedown/touchstart. this.clickWrapper_ = - Blockly.bindEvent_(svg, 'click', this, this.hide_.bind(this)); + Blockly.bindEvent_(svg, 'click', this, this.hide_); this.moveWrapper1_ = Blockly.bindEvent_(circle, 'mousemove', this, this.onMouseMove); this.moveWrapper2_ = Blockly.bindEvent_(this.gauge_, 'mousemove', this, this.onMouseMove); - this.updateGraph_(); + + return svg; }; /** - * Hide the editor and unbind event listeners. + * Dispose of events belonging to the angle editor. * @private */ -Blockly.FieldAngle.prototype.hide_ = function() { +Blockly.FieldAngle.prototype.dropdownDispose_ = function() { + Blockly.unbindEvent_(this.clickWrapper_); Blockly.unbindEvent_(this.moveWrapper1_); Blockly.unbindEvent_(this.moveWrapper2_); - Blockly.unbindEvent_(this.clickWrapper_); +}; + +/** + * Hide the editor. + * @private + */ +Blockly.FieldAngle.prototype.hide_ = function() { Blockly.DropDownDiv.hideIfOwner(this); Blockly.WidgetDiv.hide(); }; @@ -241,6 +244,7 @@ Blockly.FieldAngle.prototype.hide_ = function() { * @param {!Event} e Mouse move event. */ Blockly.FieldAngle.prototype.onMouseMove = function(e) { + // Calculate angle. var bBox = this.gauge_.ownerSVGElement.getBoundingClientRect(); var dx = e.clientX - bBox.left - Blockly.FieldAngle.HALF; var dy = e.clientY - bBox.top - Blockly.FieldAngle.HALF; @@ -249,42 +253,44 @@ Blockly.FieldAngle.prototype.onMouseMove = function(e) { // This shouldn't happen, but let's not let this error propagate further. return; } - angle = Blockly.utils.toDegrees(angle); + angle = Blockly.utils.math.toDegrees(angle); // 0: East, 90: North, 180: West, 270: South. if (dx < 0) { angle += 180; } else if (dy > 0) { angle += 360; } + + // Do offsetting. if (Blockly.FieldAngle.CLOCKWISE) { angle = Blockly.FieldAngle.OFFSET + 360 - angle; } else { - angle -= Blockly.FieldAngle.OFFSET; + angle = 360 - (Blockly.FieldAngle.OFFSET - angle); + } + if (angle > 360) { + angle -= 360; } + + // Do rounding. if (Blockly.FieldAngle.ROUND) { angle = Math.round(angle / Blockly.FieldAngle.ROUND) * Blockly.FieldAngle.ROUND; } - angle = this.callValidator(angle); - Blockly.FieldTextInput.htmlInput_.value = angle; - this.setValue(angle); - this.validate_(); - this.resizeEditor_(); -}; -/** - * Insert a degree symbol. - * @param {?string} text New text. - */ -Blockly.FieldAngle.prototype.setText = function(text) { - Blockly.FieldAngle.superClass_.setText.call(this, text); - if (!this.textElement_) { - // Not rendered yet. - return; + // Do wrapping. + if (angle > Blockly.FieldAngle.WRAP) { + angle -= 360; + } + + // Update value. + var angleString = String(angle); + if (angleString != this.text_) { + this.htmlInput_.value = angle; + this.setValue(angle); + // Always render the input angle. + this.text_ = angleString; + this.forceRerender(); } - this.updateGraph_(); - // Cached width is obsolete. Clear it. - this.size_.width = 0; }; /** @@ -295,13 +301,15 @@ Blockly.FieldAngle.prototype.updateGraph_ = function() { if (!this.gauge_) { return; } + // Always display the input (i.e. getText) even if it is invalid. var angleDegrees = Number(this.getText()) + Blockly.FieldAngle.OFFSET; - var angleRadians = Blockly.utils.toRadians(angleDegrees); + angleDegrees %= 360; + var angleRadians = Blockly.utils.math.toRadians(angleDegrees); var path = ['M ', Blockly.FieldAngle.HALF, ',', Blockly.FieldAngle.HALF]; var x2 = Blockly.FieldAngle.HALF; var y2 = Blockly.FieldAngle.HALF; if (!isNaN(angleRadians)) { - var angle1 = Blockly.utils.toRadians(Blockly.FieldAngle.OFFSET); + var angle1 = Blockly.utils.math.toRadians(Blockly.FieldAngle.OFFSET); var x1 = Math.cos(angle1) * Blockly.FieldAngle.RADIUS; var y1 = Math.sin(angle1) * -Blockly.FieldAngle.RADIUS; if (Blockly.FieldAngle.CLOCKWISE) { @@ -325,26 +333,24 @@ Blockly.FieldAngle.prototype.updateGraph_ = function() { }; /** - * Ensure that only an angle may be entered. - * @param {string} text The user's text. - * @return {?string} A string representing a valid angle, or null if invalid. + * Ensure that the input value is a valid angle. + * @param {string|number=} newValue The input value. + * @return {?number} A valid angle, or null if invalid. + * @protected */ -Blockly.FieldAngle.prototype.classValidator = function(text) { - if (text === null) { - return null; - } - var n = parseFloat(text || 0); - if (isNaN(n)) { +Blockly.FieldAngle.prototype.doClassValidation_ = function(newValue) { + if (isNaN(newValue)) { return null; } - n = n % 360; + var n = parseFloat(newValue || 0); + n %= 360; if (n < 0) { n += 360; } if (n > Blockly.FieldAngle.WRAP) { n -= 360; } - return String(n); + return n; }; Blockly.Field.register('field_angle', Blockly.FieldAngle); diff --git a/core/field_checkbox.js b/core/field_checkbox.js index bcd5b4f6daf..82f281cadd3 100644 --- a/core/field_checkbox.js +++ b/core/field_checkbox.js @@ -26,24 +26,30 @@ goog.provide('Blockly.FieldCheckbox'); +goog.require('Blockly.Events'); +goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Field'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); /** * Class for a checkbox field. - * @param {string} state The initial state of the field ('TRUE' or 'FALSE'). - * @param {Function=} opt_validator A function that is executed when a new - * option is selected. Its sole argument is the new checkbox state. If - * it returns a value, this becomes the new checkbox state, unless the - * value is null, in which case the change is aborted. + * @param {string|boolean=} opt_value The initial value of the field. Should + * either be 'TRUE', 'FALSE' or a boolean. Defaults to 'FALSE'. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a value ('TRUE' or 'FALSE') & + * returns a validated value ('TRUE' or 'FALSE'), or null to abort the + * change. * @extends {Blockly.Field} * @constructor */ -Blockly.FieldCheckbox = function(state, opt_validator) { - Blockly.FieldCheckbox.superClass_.constructor.call(this, '', opt_validator); - // Set the initial state. - this.setValue(state); +Blockly.FieldCheckbox = function(opt_value, opt_validator) { + opt_value = this.doClassValidation_(opt_value); + if (opt_value === null) { + opt_value = 'FALSE'; + } + Blockly.FieldCheckbox.superClass_.constructor.call(this, opt_value, opt_validator); + this.size_.width = Blockly.FieldCheckbox.WIDTH; }; goog.inherits(Blockly.FieldCheckbox, Blockly.Field); @@ -55,78 +61,151 @@ goog.inherits(Blockly.FieldCheckbox, Blockly.Field); * @nocollapse */ Blockly.FieldCheckbox.fromJson = function(options) { - return new Blockly.FieldCheckbox(options['checked'] ? 'TRUE' : 'FALSE'); + return new Blockly.FieldCheckbox(options['checked']); }; +/** + * The width of a checkbox field. + * @type {number} + * @const + */ +Blockly.FieldCheckbox.WIDTH = 5; + /** * Character for the checkmark. + * @type {string} + * @const */ Blockly.FieldCheckbox.CHECK_CHAR = '\u2713'; +/** + * Used to correctly position the check mark. + * @type {number} + * @const + */ +Blockly.FieldCheckbox.CHECK_X_OFFSET = -3; + +/** + * Used to correctly position the check mark. + * @type {number} + * @const + */ +Blockly.FieldCheckbox.CHECK_Y_OFFSET = 14; + +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const + */ +Blockly.FieldCheckbox.prototype.SERIALIZABLE = true; + /** * Mouse cursor style when over the hotspot that initiates editability. */ Blockly.FieldCheckbox.prototype.CURSOR = 'default'; /** - * Install this checkbox on a block. + * Used to tell if the field needs to be rendered the next time the block is + * rendered. Checkbox fields are statically sized, and only need to be + * rendered at initialization. + * @type {boolean} + * @private */ -Blockly.FieldCheckbox.prototype.init = function() { - if (this.fieldGroup_) { - // Checkbox has already been initialized once. - return; - } - Blockly.FieldCheckbox.superClass_.init.call(this); - // The checkbox doesn't use the inherited text element. - // Instead it uses a custom checkmark element that is either visible or not. - this.checkElement_ = Blockly.utils.createSvgElement('text', - {'class': 'blocklyText blocklyCheckbox', 'x': -3, 'y': 14}, - this.fieldGroup_); +Blockly.FieldCheckbox.prototype.isDirty_ = false; + +/** + * Create the block UI for this checkbox. + * @package + */ +Blockly.FieldCheckbox.prototype.initView = function() { + Blockly.FieldCheckbox.superClass_.initView.call(this); + + this.textElement_.setAttribute('x', Blockly.FieldCheckbox.CHECK_X_OFFSET); + this.textElement_.setAttribute('y', Blockly.FieldCheckbox.CHECK_Y_OFFSET); + Blockly.utils.dom.addClass(this.textElement_, 'blocklyCheckbox'); + var textNode = document.createTextNode(Blockly.FieldCheckbox.CHECK_CHAR); - this.checkElement_.appendChild(textNode); - this.checkElement_.style.display = this.state_ ? 'block' : 'none'; + this.textElement_.appendChild(textNode); + this.textElement_.style.display = this.value_ ? 'block' : 'none'; }; /** - * Return 'TRUE' if the checkbox is checked, 'FALSE' otherwise. - * @return {string} Current state. + * Toggle the state of the checkbox on click. + * @protected */ -Blockly.FieldCheckbox.prototype.getValue = function() { - return String(this.state_).toUpperCase(); +Blockly.FieldCheckbox.prototype.showEditor_ = function() { + this.setValue(!this.value_); }; /** - * Set the checkbox to be checked if newBool is 'TRUE' or true, - * unchecks otherwise. - * @param {string|boolean} newBool New state. - */ -Blockly.FieldCheckbox.prototype.setValue = function(newBool) { - var newState = (typeof newBool == 'string') ? - (newBool.toUpperCase() == 'TRUE') : !!newBool; - if (this.state_ !== newState) { - if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.BlockChange( - this.sourceBlock_, 'field', this.name, this.state_, newState)); - } - this.state_ = newState; - if (this.checkElement_) { - this.checkElement_.style.display = newState ? 'block' : 'none'; - } + * Ensure that the input value is valid ('TRUE' or 'FALSE'). + * @param {string|boolean=} newValue The input value. + * @return {?string} A valid value ('TRUE' or 'FALSE), or null if invalid. + * @protected + */ +Blockly.FieldCheckbox.prototype.doClassValidation_ = function(newValue) { + if (newValue === true || newValue === 'TRUE') { + return 'TRUE'; + } + if (newValue === false || newValue === 'FALSE') { + return 'FALSE'; } + return null; }; /** - * Toggle the state of the checkbox. - * @private + * Update the value of the field, and update the checkElement. + * @param {string} newValue The new value ('TRUE' or 'FALSE') of the field. + * @protected */ -Blockly.FieldCheckbox.prototype.showEditor_ = function() { - var newState = !this.state_; - if (this.sourceBlock_) { - // Call any validation function, and allow it to override. - newState = this.callValidator(newState); +Blockly.FieldCheckbox.prototype.doValueUpdate_ = function(newValue) { + this.value_ = this.convertValueToBool_(newValue); + // Update visual. + if (this.textElement_) { + this.textElement_.style.display = this.value_ ? 'block' : 'none'; } - if (newState !== null) { - this.setValue(String(newState).toUpperCase()); +}; + +/** + * Get the value of this field, either 'TRUE' or 'FALSE'. + * @return {string} The value of this field. + */ +Blockly.FieldCheckbox.prototype.getValue = function() { + return this.value_ ? 'TRUE' : 'FALSE'; +}; + +/** + * Get the boolean value of this field. + * @return {string} The boolean value of this field. + */ +Blockly.FieldCheckbox.prototype.getValueBoolean = function() { + return this.value_; +}; + +/** + * Get the text of this field. Used when the block is collapsed. + * @return {string} Text representing the value of this field + * ('true' or 'false'). + */ +Blockly.FieldCheckbox.prototype.getText = function() { + return String(this.convertValueToBool_(this.value_)); +}; + +/** + * Convert a value into a pure boolean. + * + * Converts 'TRUE' to true and 'FALSE' to false correctly, everything else + * is cast to a boolean. + * @param {*} value The value to convert. + * @return {boolean} The converted value. + * @private + */ +Blockly.FieldCheckbox.prototype.convertValueToBool_ = function(value) { + if (typeof value == 'string') { + return value == 'TRUE'; + } else { + return !!value; } }; diff --git a/core/field_colour.js b/core/field_colour.js index 9838669fcd5..5f26899ad67 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -27,26 +27,31 @@ goog.provide('Blockly.FieldColour'); goog.require('Blockly.DropDownDiv'); +goog.require('Blockly.Events'); +goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Field'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.colour'); -goog.require('goog.style'); +goog.require('goog.math.Size'); /** * Class for a colour input field. - * @param {string} colour The initial colour in '#rrggbb' format. - * @param {Function=} opt_validator A function that is executed when a new - * colour is selected. Its sole argument is the new colour value. Its - * return value becomes the selected colour, unless it is undefined, in - * which case the new colour stands, or it is null, in which case the change - * is aborted. + * @param {string=} opt_value The initial value of the field. Should be in + * '#rrggbb' format. Defaults to the first value in the default colour array. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a colour string & returns a + * validated colour string ('#rrggbb' format), or null to abort the change. * @extends {Blockly.Field} * @constructor */ -Blockly.FieldColour = function(colour, opt_validator) { - Blockly.FieldColour.superClass_.constructor.call(this, colour, opt_validator); - this.setText(Blockly.Field.NBSP + Blockly.Field.NBSP + Blockly.Field.NBSP); +Blockly.FieldColour = function(opt_value, opt_validator) { + opt_value = this.doClassValidation_(opt_value); + if (opt_value === null) { + opt_value = Blockly.FieldColour.COLOURS[0]; + } + Blockly.FieldColour.superClass_.constructor.call( + this, opt_value, opt_validator); }; goog.inherits(Blockly.FieldColour, Blockly.Field); @@ -77,6 +82,28 @@ Blockly.FieldColour.DEFAULT_WIDTH = 16; */ Blockly.FieldColour.DEFAULT_HEIGHT = 12; +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const + */ +Blockly.FieldColour.prototype.SERIALIZABLE = true; + +/** + * Mouse cursor style when over the hotspot that initiates the editor. + */ +Blockly.FieldColour.prototype.CURSOR = 'default'; + +/** + * Used to tell if the field needs to be rendered the next time the block is + * rendered. Colour fields are statically sized, and only need to be + * rendered at initialization. + * @type {boolean} + * @private + */ +Blockly.FieldColour.prototype.isDirty_ = false; + /** * Array of colours used by this field. If null, use the global list. * @type {Array.} @@ -116,88 +143,51 @@ Blockly.FieldColour.prototype.DROPDOWN_BORDER_COLOUR = 'silver'; Blockly.FieldColour.prototype.DROPDOWN_BACKGROUND_COLOUR = 'white'; /** - * Install this field on a block. + * Create the block UI for this colour field. + * @package */ -Blockly.FieldColour.prototype.init = function() { - Blockly.FieldColour.superClass_.init.call(this); - this.borderRect_.style['fillOpacity'] = 1; +Blockly.FieldColour.prototype.initView = function() { this.size_ = new goog.math.Size(Blockly.FieldColour.DEFAULT_WIDTH, Blockly.FieldColour.DEFAULT_HEIGHT); - this.setValue(this.getValue()); -}; - -/** - * Mouse cursor style when over the hotspot that initiates the editor. - */ -Blockly.FieldColour.prototype.CURSOR = 'default'; - -/** - * Close the colour picker if this input is being deleted. - */ -Blockly.FieldColour.prototype.dispose = function() { - Blockly.WidgetDiv.hideIfOwner(this); - Blockly.FieldColour.superClass_.dispose.call(this); -}; - -/** - * Return the current colour. - * @return {string} Current colour in '#rrggbb' format. - */ -Blockly.FieldColour.prototype.getValue = function() { - return this.colour_; -}; - -/** - * Get the size, and rerender if necessary. - * @return {!goog.math.Size} Height and width. - */ -Blockly.FieldColour.prototype.getSize = function() { - if (!this.size_.width) { - this.render_(); - } - - return this.size_; + this.createBorderRect_(); + this.borderRect_.style['fillOpacity'] = 1; + this.borderRect_.style.fill = this.value_; }; /** - * Updates the width of the field. Colour fields have a constant width, but - * the width is sometimes reset to force a rerender. + * Ensure that the input value is a valid colour. + * @param {string=} newValue The input value. + * @return {?string} A valid colour, or null if invalid. + * @protected */ -Blockly.FieldColour.prototype.updateWidth = function() { - var width = Blockly.FieldColour.DEFAULT_WIDTH; - if (this.borderRect_) { - this.borderRect_.setAttribute('width', - width + Blockly.BlockSvg.SEP_SPACE_X); +Blockly.FieldColour.prototype.doClassValidation_ = function(newValue) { + if (typeof newValue != 'string') { + return null; } - this.size_.width = width; + return Blockly.utils.colour.parse(newValue); }; /** - * Set the colour. - * @param {string} colour The new colour in '#rrggbb' format. + * Update the value of this colour field, and update the displayed colour. + * @param {string} newValue The new colour in '#rrggbb' format. + * @protected */ -Blockly.FieldColour.prototype.setValue = function(colour) { - if (this.sourceBlock_ && Blockly.Events.isEnabled() && - this.colour_ != colour) { - Blockly.Events.fire(new Blockly.Events.BlockChange( - this.sourceBlock_, 'field', this.name, this.colour_, colour)); - } - this.colour_ = colour; +Blockly.FieldColour.prototype.doValueUpdate_ = function(newValue) { + this.value_ = newValue; if (this.borderRect_) { - this.borderRect_.style.fill = colour; + this.borderRect_.style.fill = newValue; } }; /** - * Get the text from this field. Used when the block is collapsed. - * @return {string} Current text. + * Get the text for this field. Used when the block is collapsed. + * @return {string} Text representing the value of this field. */ Blockly.FieldColour.prototype.getText = function() { - var colour = this.colour_; + var colour = this.value_; // Try to use #rgb format if possible, rather than #rrggbb. - var m = colour.match(/^#(.)\1(.)\2(.)\3$/); - if (m) { - colour = '#' + m[1] + m[2] + m[3]; + if (/^#(.)\1(.)\2(.)\3$/.test(colour)) { + colour = '#' + colour[1] + colour[3] + colour[5]; } return colour; }; @@ -273,24 +263,18 @@ Blockly.FieldColour.prototype.setColumns = function(columns) { }; /** - * Create a palette under the colour field. + * Create and show the colour field's editor. * @private */ Blockly.FieldColour.prototype.showEditor_ = function() { - - Blockly.DropDownDiv.hideWithoutAnimation(); - Blockly.DropDownDiv.clearContent(); - - var picker = this.createWidget_(); + var picker = this.dropdownCreate_(); Blockly.DropDownDiv.getContentDiv().appendChild(picker); + Blockly.DropDownDiv.setColour( this.DROPDOWN_BACKGROUND_COLOUR, this.DROPDOWN_BORDER_COLOUR); - Blockly.DropDownDiv.showPositionedByField(this); - - // Configure event handler on the table to listen for any event in a cell. - Blockly.FieldColour.onUpWrapper_ = Blockly.bindEvent_(picker, - 'mouseup', this, this.onClick_); + Blockly.DropDownDiv.showPositionedByField( + this, this.dropdownDispose_.bind(this)); }; /** @@ -305,22 +289,18 @@ Blockly.FieldColour.prototype.onClick_ = function(e) { cell = cell.parentNode; } var colour = cell && cell.label; - Blockly.WidgetDiv.hide(); - if (this.sourceBlock_) { - // Call any validation function, and allow it to override. - colour = this.callValidator(colour); - } if (colour !== null) { this.setValue(colour); + Blockly.DropDownDiv.hideIfOwner(this); } }; /** - * Create a colour picker widget. + * Create a colour picker dropdown editor. * @return {!Element} The newly created colour picker. * @private */ -Blockly.FieldColour.prototype.createWidget_ = function() { +Blockly.FieldColour.prototype.dropdownCreate_ = function() { var columns = this.columns_ || Blockly.FieldColour.COLUMNS; var colours = this.colours_ || Blockly.FieldColour.COLOURS; var titles = this.titles_ || Blockly.FieldColour.TITLES; @@ -345,18 +325,19 @@ Blockly.FieldColour.prototype.createWidget_ = function() { div.className = 'blocklyColourSelected'; } } + + // Configure event handler on the table to listen for any event in a cell. + this.onUpWrapper_ = Blockly.bindEvent_(table, 'mouseup', this, this.onClick_); + return table; }; /** - * Hide the colour picker widget. + * Dispose of events belonging to the colour editor. * @private */ -Blockly.FieldColour.widgetDispose_ = function() { - if (Blockly.FieldColour.onUpWrapper_) { - Blockly.unbindEvent_(Blockly.FieldColour.onUpWrapper_); - } - Blockly.Events.setGroup(false); +Blockly.FieldColour.prototype.dropdownDispose_ = function() { + Blockly.unbindEvent_(this.onUpWrapper_); }; Blockly.Field.register('field_colour', Blockly.FieldColour); diff --git a/core/field_date.js b/core/field_date.js index 52d69cd8045..1586de38ab9 100644 --- a/core/field_date.js +++ b/core/field_date.js @@ -26,35 +26,35 @@ goog.provide('Blockly.FieldDate'); +goog.require('Blockly.Events'); goog.require('Blockly.Field'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.string'); goog.require('goog.date'); goog.require('goog.date.DateTime'); goog.require('goog.events'); goog.require('goog.i18n.DateTimeSymbols'); goog.require('goog.i18n.DateTimeSymbols_he'); -goog.require('goog.style'); goog.require('goog.ui.DatePicker'); /** * Class for a date input field. - * @param {string} date The initial date. - * @param {Function=} opt_validator A function that is executed when a new - * date is selected. Its sole argument is the new date value. Its - * return value becomes the selected date, unless it is undefined, in - * which case the new date stands, or it is null, in which case the change - * is aborted. + * @param {string=} opt_value The initial value of the field. Should be in + * 'YYYY-MM-DD' format. Defaults to the current date. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a date string & returns a + * validated date string ('YYYY-MM-DD' format), or null to abort the change. * @extends {Blockly.Field} * @constructor */ -Blockly.FieldDate = function(date, opt_validator) { - if (!date) { - date = new goog.date.Date().toIsoString(true); +Blockly.FieldDate = function(opt_value, opt_validator) { + opt_value = this.doClassValidation_(opt_value); + if (!opt_value) { + opt_value = new goog.date.Date().toIsoString(true); } - Blockly.FieldDate.superClass_.constructor.call(this, date, opt_validator); - this.setValue(date); + Blockly.FieldDate.superClass_.constructor.call(this, opt_value, opt_validator); }; goog.inherits(Blockly.FieldDate, Blockly.Field); @@ -69,105 +69,178 @@ Blockly.FieldDate.fromJson = function(options) { return new Blockly.FieldDate(options['date']); }; +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const + */ +Blockly.FieldDate.prototype.SERIALIZABLE = true; + /** * Mouse cursor style when over the hotspot that initiates the editor. */ Blockly.FieldDate.prototype.CURSOR = 'text'; /** - * Close the colour picker if this input is being deleted. + * Border colour for the dropdown div showing the date picker. Must be a CSS + * string. + * @type {string} + * @private */ -Blockly.FieldDate.prototype.dispose = function() { - Blockly.WidgetDiv.hideIfOwner(this); - Blockly.FieldDate.superClass_.dispose.call(this); -}; +Blockly.FieldDate.prototype.DROPDOWN_BORDER_COLOUR = 'silver'; /** - * Return the current date. - * @return {string} Current date. + * Background colour for the dropdown div showing the date picker. Must be a + * CSS string. + * @type {string} + * @private */ -Blockly.FieldDate.prototype.getValue = function() { - return this.date_; +Blockly.FieldDate.prototype.DROPDOWN_BACKGROUND_COLOUR = 'white'; + +/** + * Ensure that the input value is a valid date. + * @param {string=} newValue The input value. + * @return {?string} A valid date, or null if invalid. + * @protected + */ +Blockly.FieldDate.prototype.doClassValidation_ = function(newValue) { + if (!newValue) { + return null; + } + // Check if the new value is parsable or not. + var date = goog.date.Date.fromIsoString(newValue); + if (!date || date.toIsoString(true) != newValue) { + return null; + } + return newValue; }; /** - * Set the date. - * @param {string} date The new date. + * Render the field. If the picker is shown make sure it has the current + * date selected. + * @protected */ -Blockly.FieldDate.prototype.setValue = function(date) { - if (this.sourceBlock_) { - var validated = this.callValidator(date); - // If the new date is invalid, validation returns null. - // In this case we still want to display the illegal result. - if (validated !== null) { - date = validated; - } +Blockly.FieldDate.prototype.render_ = function() { + Blockly.FieldDate.superClass_.render_.call(this); + if (this.picker_) { + this.picker_.setDate(goog.date.Date.fromIsoString(this.getValue())); + this.updateEditor_(); } - this.date_ = date; - Blockly.Field.prototype.setText.call(this, date); }; /** - * Create a date picker under the date field. + * Updates the field's colours to match those of the block. + * @package + */ +Blockly.FieldDate.prototype.updateColour = function() { + this.todayColour_ = this.sourceBlock_.getColour(); + this.selectedColour_ = this.sourceBlock_.getColourShadow(); + this.updateEditor_(); +}; + +/** + * Updates the picker to show the current date and currently selected date. * @private */ -Blockly.FieldDate.prototype.showEditor_ = function() { - Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, - Blockly.FieldDate.widgetDispose_); +Blockly.FieldDate.prototype.updateEditor_ = function() { + if (!this.picker_) { + // Nothing to update. + return; + } - // Record viewport dimensions before adding the picker. - var viewportBBox = Blockly.utils.getViewportBBox(); - var anchorBBox = this.getScaledBBox_(); + // Updating today should come before updating selected, so that if the + // current day is selected, it will appear so. + if (this.oldTodayElement_) { + this.oldTodayElement_.style.backgroundColor = null; + this.oldTodayElement_.style.color = null; + } + var today = this.picker_.getElementByClass('goog-date-picker-today'); + this.oldTodayElement_ = today; + if (today) { + today.style.backgroundColor = this.todayColour_; + today.style.color = 'white'; + } + + if (this.oldSelectedElement_ && this.oldSelectedElement_ != today) { + this.oldSelectedElement_.style.backgroundColor = null; + this.oldSelectedElement_.style.color = null; + } + var selected = this.picker_.getElementByClass('goog-date-picker-selected'); + this.oldSelectedElement_ = selected; + if (selected) { + selected.style.backgroundColor = this.selectedColour_; + selected.style.color = this.todayColour_; + } +}; - // Create and add the date picker, then record the size. - var picker = this.createWidget_(); - var pickerSize = goog.style.getSize(picker.getElement()); +/** + * Create and show the date field's editor. + * @private + */ +Blockly.FieldDate.prototype.showEditor_ = function() { + this.picker_ = this.dropdownCreate_(); + this.picker_.render(Blockly.DropDownDiv.getContentDiv()); + Blockly.utils.dom.addClass(this.picker_.getElement(), 'blocklyDatePicker'); + Blockly.DropDownDiv.setColour( + this.DROPDOWN_BACKGROUND_COLOUR, this.DROPDOWN_BORDER_COLOUR); - // Position the picker to line up with the field. - Blockly.WidgetDiv.positionWithAnchor(viewportBBox, anchorBBox, pickerSize, - this.sourceBlock_.RTL); + Blockly.DropDownDiv.showPositionedByField( + this, this.dropdownDispose_.bind(this)); - // Configure event handler. - var thisField = this; - Blockly.FieldDate.changeEventKey_ = goog.events.listen(picker, - goog.ui.DatePicker.Events.CHANGE, - function(event) { - var date = event.date ? event.date.toIsoString(true) : ''; - Blockly.WidgetDiv.hide(); - if (thisField.sourceBlock_) { - // Call any validation function, and allow it to override. - date = thisField.callValidator(date); - } - thisField.setValue(date); - }); + this.updateEditor_(); }; /** - * Create a date picker widget and render it inside the widget div. + * Create the date dropdown editor. * @return {!goog.ui.DatePicker} The newly created date picker. * @private */ -Blockly.FieldDate.prototype.createWidget_ = function() { +Blockly.FieldDate.prototype.dropdownCreate_ = function() { // Create the date picker using Closure. Blockly.FieldDate.loadLanguage_(); var picker = new goog.ui.DatePicker(); picker.setAllowNone(false); picker.setShowWeekNum(false); - var div = Blockly.WidgetDiv.DIV; - picker.render(div); + picker.setUseNarrowWeekdayNames(true); + picker.setUseSimpleNavigationMenu(true); picker.setDate(goog.date.DateTime.fromIsoString(this.getValue())); + + this.changeEventKey_ = goog.events.listen( + picker, + goog.ui.DatePicker.Events.CHANGE, + this.onDateSelected_, + null, + this); + this.activeMonthEventKey_ = goog.events.listen( + picker, + goog.ui.DatePicker.Events.CHANGE_ACTIVE_MONTH, + this.updateEditor_, + null, + this); + return picker; }; /** - * Hide the date picker. + * Dispose of references to DOM elements and events belonging + * to the date editor. * @private */ -Blockly.FieldDate.widgetDispose_ = function() { - if (Blockly.FieldDate.changeEventKey_) { - goog.events.unlistenByKey(Blockly.FieldDate.changeEventKey_); - } - Blockly.Events.setGroup(false); +Blockly.FieldDate.prototype.dropdownDispose_ = function() { + goog.events.unlistenByKey(this.changeEventKey_); + goog.events.unlistenByKey(this.activeMonthEventKey_); +}; + +/** + * Handle a CHANGE event in the date picker. + * @param {!Event} event The CHANGE event. + * @private + */ +Blockly.FieldDate.prototype.onDateSelected_ = function(event) { + var date = event.date ? event.date.toIsoString(true) : ''; + this.setValue(date); + Blockly.DropDownDiv.hideIfOwner(this); }; /** @@ -176,13 +249,13 @@ Blockly.FieldDate.widgetDispose_ = function() { * @private */ Blockly.FieldDate.loadLanguage_ = function() { - var reg = /^DateTimeSymbols_(.+)$/; for (var prop in goog.i18n) { - var m = prop.match(reg); - if (m) { - var lang = m[1].toLowerCase().replace('_', '.'); // E.g. 'pt.br' + if (Blockly.utils.string.startsWith(prop, 'DateTimeSymbols_')) { + var lang = prop.substr(16).toLowerCase().replace('_', '.'); + // E.g. 'DateTimeSymbols_pt_BR' -> 'pt.br' if (goog.getObjectByName(lang, Blockly.Msg)) { goog.i18n.DateTimeSymbols = goog.i18n[prop]; + break; } } } @@ -192,159 +265,61 @@ Blockly.FieldDate.loadLanguage_ = function() { * CSS for date picker. See css.js for use. */ Blockly.FieldDate.CSS = [ - /* Copied from: goog/css/datepicker.css */ - /** - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - - /** - * Standard styling for a goog.ui.DatePicker. - * - * @author arv@google.com (Erik Arvidsson) - */ - - '.blocklyWidgetDiv .goog-date-picker,', - '.blocklyWidgetDiv .goog-date-picker th,', - '.blocklyWidgetDiv .goog-date-picker td {', + '.blocklyDatePicker,', + '.blocklyDatePicker th,', + '.blocklyDatePicker td {', ' font: 13px Arial, sans-serif;', + ' color: #3c4043;', '}', - '.blocklyWidgetDiv .goog-date-picker {', - ' -moz-user-focus: normal;', - ' -moz-user-select: none;', - ' position: relative;', - ' border: 1px solid #000;', - ' float: left;', - ' padding: 2px;', - ' color: #000;', - ' background: #c3d9ff;', - ' cursor: default;', - '}', - - '.blocklyWidgetDiv .goog-date-picker th {', - ' text-align: center;', - '}', - - '.blocklyWidgetDiv .goog-date-picker td {', + '.blocklyDatePicker th,', + '.blocklyDatePicker td {', ' text-align: center;', ' vertical-align: middle;', - ' padding: 1px 3px;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-menu {', - ' position: absolute;', - ' background: threedface;', - ' border: 1px solid gray;', - ' -moz-user-focus: normal;', - ' z-index: 1;', - ' outline: none;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-menu ul {', - ' list-style: none;', - ' margin: 0px;', - ' padding: 0px;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-menu ul li {', - ' cursor: default;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-menu-selected {', - ' background: #ccf;', - '}', - - '.blocklyWidgetDiv .goog-date-picker th {', - ' font-size: .9em;', '}', - '.blocklyWidgetDiv .goog-date-picker td div {', - ' float: left;', + '.blocklyDatePicker .goog-date-picker-wday,', + '.blocklyDatePicker .goog-date-picker-date {', + ' padding: 6px 6px;', '}', - '.blocklyWidgetDiv .goog-date-picker button {', - ' padding: 0px;', + '.blocklyDatePicker button {', + ' cursor: pointer;', + ' padding: 6px 6px;', ' margin: 1px 0;', ' border: 0;', - ' color: #20c;', + ' color: #3c4043;', ' font-weight: bold;', ' background: transparent;', '}', - '.blocklyWidgetDiv .goog-date-picker-date {', - ' background: #fff;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-week,', - '.blocklyWidgetDiv .goog-date-picker-wday {', - ' padding: 1px 3px;', - ' border: 0;', - ' border-color: #a2bbdd;', - ' border-style: solid;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-week {', - ' border-right-width: 1px;', + '.blocklyDatePicker .goog-date-picker-previousMonth,', + '.blocklyDatePicker .goog-date-picker-nextMonth {', + ' height: 24px;', + ' width: 24px;', '}', - '.blocklyWidgetDiv .goog-date-picker-wday {', - ' border-bottom-width: 1px;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-head td {', - ' text-align: center;', - '}', - - /** Use td.className instead of !important */ - '.blocklyWidgetDiv td.goog-date-picker-today-cont {', - ' text-align: center;', - '}', - - /** Use td.className instead of !important */ - '.blocklyWidgetDiv td.goog-date-picker-none-cont {', - ' text-align: center;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-month {', - ' min-width: 11ex;', - ' white-space: nowrap;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-year {', - ' min-width: 6ex;', - ' white-space: nowrap;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-monthyear {', - ' white-space: nowrap;', - '}', - - '.blocklyWidgetDiv .goog-date-picker table {', - ' border-collapse: collapse;', - '}', - - '.blocklyWidgetDiv .goog-date-picker-other-month {', - ' color: #888;', + '.blocklyDatePicker .goog-date-picker-monthyear {', + ' font-weight: bold;', '}', - '.blocklyWidgetDiv .goog-date-picker-wkend-start,', - '.blocklyWidgetDiv .goog-date-picker-wkend-end {', - ' background: #eee;', + '.blocklyDatePicker .goog-date-picker-wday, ', + '.blocklyDatePicker .goog-date-picker-other-month {', + ' color: #70757a;', + ' border-radius: 12px;', '}', - /** Use td.className instead of !important */ - '.blocklyWidgetDiv td.goog-date-picker-selected {', - ' background: #c3d9ff;', + '.blocklyDatePicker button,', + '.blocklyDatePicker .goog-date-picker-date {', + ' cursor: pointer;', + ' background-color: rgb(218, 220, 224, 0);', + ' border-radius: 12px;', + ' transition: background-color,opacity 100ms linear;', '}', - '.blocklyWidgetDiv .goog-date-picker-today {', - ' background: #9ab;', - ' font-weight: bold !important;', - ' border-color: #246 #9bd #9bd #246;', - ' color: #fff;', + '.blocklyDatePicker button:hover,', + '.blocklyDatePicker .goog-date-picker-date:hover {', + ' background-color: rgb(218, 220, 224, .5);', '}' ]; diff --git a/core/field_dropdown.js b/core/field_dropdown.js index 9eb3d04ac38..7d070cfe0cf 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -28,25 +28,28 @@ goog.provide('Blockly.FieldDropdown'); +goog.require('Blockly.Events'); +goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Field'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.string'); goog.require('Blockly.utils.uiMenu'); +goog.require('Blockly.utils.userAgent'); goog.require('goog.events'); goog.require('goog.ui.Menu'); goog.require('goog.ui.MenuItem'); -goog.require('goog.userAgent'); /** * Class for an editable dropdown field. * @param {(!Array.|!Function)} menuGenerator An array of options * for a dropdown list, or a function which generates these options. - * @param {Function=} opt_validator A function that is executed when a new - * option is selected, with the newly selected value as its sole argument. - * If it returns a value, that value (which must be one of the options) will - * become selected in place of the newly selected option, unless the return - * value is null, in which case the change is aborted. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a language-neutral dropdown + * option & returns a validated language-neutral dropdown option, or null to + * abort the change. * @extends {Blockly.Field} * @constructor */ @@ -76,6 +79,14 @@ Blockly.FieldDropdown.fromJson = function(options) { return new Blockly.FieldDropdown(options['options']); }; +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const + */ +Blockly.FieldDropdown.prototype.SERIALIZABLE = true; + /** * Horizontal distance that a checkmark overhangs the dropdown. */ @@ -87,21 +98,22 @@ Blockly.FieldDropdown.CHECKMARK_OVERHANG = 25; Blockly.FieldDropdown.MAX_MENU_HEIGHT_VH = 0.45; /** - * Android can't (in 2014) display "▾", so use "▼" instead. + * Used to position the imageElement_ correctly. + * @type {number} + * @const */ -Blockly.FieldDropdown.ARROW_CHAR = goog.userAgent.ANDROID ? '\u25BC' : '\u25BE'; +Blockly.FieldDropdown.IMAGE_Y_OFFSET = 5; /** - * Mouse cursor style when over the hotspot that initiates the editor. + * Android can't (in 2014) display "▾", so use "▼" instead. */ -Blockly.FieldDropdown.prototype.CURSOR = 'default'; +Blockly.FieldDropdown.ARROW_CHAR = + Blockly.utils.userAgent.ANDROID ? '\u25BC' : '\u25BE'; /** - * Language-neutral currently selected string or image object. - * @type {string|!Object} - * @protected + * Mouse cursor style when over the hotspot that initiates the editor. */ -Blockly.FieldDropdown.prototype.value_ = ''; +Blockly.FieldDropdown.prototype.CURSOR = 'default'; /** * SVG image element if currently selected option is an image, or null. @@ -119,20 +131,27 @@ Blockly.FieldDropdown.prototype.imageElement_ = null; Blockly.FieldDropdown.prototype.imageJson_ = null; /** - * Install this dropdown on a block. + * Create the block UI for this dropdown. + * @package */ -Blockly.FieldDropdown.prototype.init = function() { - if (this.fieldGroup_) { - // Dropdown has already been initialized once. - return; - } - // Add dropdown arrow: "option ▾" (LTR) or "▾ אופציה" (RTL) - this.arrow_ = Blockly.utils.createSvgElement('tspan', {}, null); - this.arrow_.appendChild(document.createTextNode(this.sourceBlock_.RTL ? +Blockly.FieldDropdown.prototype.initView = function() { + Blockly.FieldDropdown.superClass_.initView.call(this); + + this.imageElement_ = Blockly.utils.dom.createSvgElement( 'image', + { + 'y': Blockly.FieldDropdown.IMAGE_Y_OFFSET + }, this.fieldGroup_); + + this.arrow_ = Blockly.utils.dom.createSvgElement('tspan', {}, this.textElement_); + this.arrow_.appendChild(document.createTextNode( + this.sourceBlock_.RTL ? Blockly.FieldDropdown.ARROW_CHAR + ' ' : ' ' + Blockly.FieldDropdown.ARROW_CHAR)); - - Blockly.FieldDropdown.superClass_.init.call(this); + if (this.sourceBlock_.RTL) { + this.textElement_.insertBefore(this.arrow_, this.textContent_); + } else { + this.textElement_.appendChild(this.arrow_); + } }; /** @@ -140,42 +159,32 @@ Blockly.FieldDropdown.prototype.init = function() { * @private */ Blockly.FieldDropdown.prototype.showEditor_ = function() { - Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, null); - var menu = this.createMenu_(); - this.addActionListener_(menu); - this.positionMenu_(menu); -}; + Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, + this.widgetDispose_.bind(this)); + this.menu_ = this.widgetCreate_(); -/** - * Add a listener for mouse and keyboard events in the menu and its items. - * @param {!goog.ui.Menu} menu The menu to add listeners to. - * @private - */ -Blockly.FieldDropdown.prototype.addActionListener_ = function(menu) { - var thisField = this; - - function callback(e) { - var menu = this; - var menuItem = e.target; - if (menuItem) { - thisField.onItemSelected(menu, menuItem); - } - Blockly.WidgetDiv.hideIfOwner(thisField); - Blockly.Events.setGroup(false); - } - // Listen for mouse/keyboard events. - goog.events.listen(menu, goog.ui.Component.EventType.ACTION, callback); + this.menu_.render(Blockly.WidgetDiv.DIV); + // Element gets created in render. + Blockly.utils.dom.addClass(this.menu_.getElement(), 'blocklyDropdownMenu'); + + this.positionMenu_(this.menu_); + + // Focusing needs to be handled after the menu is rendered and positioned. + // Otherwise it will cause a page scroll to get the misplaced menu in + // view. See issue #1329. + this.menu_.setAllowAutoFocus(true); + this.menu_.getElement().focus(); }; /** - * Create and populate the menu and menu items for this dropdown, based on - * the options list. - * @return {!goog.ui.Menu} The populated dropdown menu. + * Create the dropdown editor widget. + * @return {goog.ui.Menu} The newly created dropdown menu. * @private */ -Blockly.FieldDropdown.prototype.createMenu_ = function() { +Blockly.FieldDropdown.prototype.widgetCreate_ = function() { var menu = new goog.ui.Menu(); menu.setRightToLeft(this.sourceBlock_.RTL); + var options = this.getOptions(); for (var i = 0; i < options.length; i++) { var content = options[i][0]; // Human-readable text or image. @@ -194,9 +203,35 @@ Blockly.FieldDropdown.prototype.createMenu_ = function() { menu.addChild(menuItem, true); menuItem.setChecked(value == this.value_); } + + this.menuActionEventKey_ = goog.events.listen( + menu, + goog.ui.Component.EventType.ACTION, + this.handleMenuActionEvent_, + false, + this); + return menu; }; +/** + * Dispose of events belonging to the dropdown editor. + * @private + */ +Blockly.FieldDropdown.prototype.widgetDispose_ = function() { + goog.events.unlistenByKey(this.menuActionEventKey_); +}; + +/** + * Handle an ACTION event in the dropdown menu. + * @param {!Event} event The CHANGE event. + * @private + */ +Blockly.FieldDropdown.prototype.handleMenuActionEvent_ = function(event) { + Blockly.WidgetDiv.hideIfOwner(this); + this.onItemSelected(this.menu_, event.target); +}; + /** * Place the menu correctly on the screen, taking into account the dimensions * of the menu and the dimensions of the screen so that it doesn't run off any @@ -205,11 +240,9 @@ Blockly.FieldDropdown.prototype.createMenu_ = function() { * @private */ Blockly.FieldDropdown.prototype.positionMenu_ = function(menu) { - // Record viewport dimensions before adding the dropdown. var viewportBBox = Blockly.utils.getViewportBBox(); var anchorBBox = this.getAnchorDimensions_(); - this.createWidget_(menu); var menuSize = Blockly.utils.uiMenu.getSize(menu); var menuMaxHeightPx = Blockly.FieldDropdown.MAX_MENU_HEIGHT_VH @@ -221,26 +254,8 @@ Blockly.FieldDropdown.prototype.positionMenu_ = function(menu) { if (this.sourceBlock_.RTL) { Blockly.utils.uiMenu.adjustBBoxesForRTL(viewportBBox, anchorBBox, menuSize); } - // Position the menu. Blockly.WidgetDiv.positionWithAnchor(viewportBBox, anchorBBox, menuSize, this.sourceBlock_.RTL); - // Calling menuDom.focus() has to wait until after the menu has been placed - // correctly. Otherwise it will cause a page scroll to get the misplaced menu - // in view. See issue #1329. - menu.getElement().focus(); -}; - -/** - * Create and render the menu widget inside Blockly's widget div. - * @param {!goog.ui.Menu} menu The menu to add to the widget div. - * @private - */ -Blockly.FieldDropdown.prototype.createWidget_ = function(menu) { - var div = Blockly.WidgetDiv.DIV; - menu.render(div); - Blockly.utils.addClass(menu.getElement(), 'blocklyDropdownMenu'); - // Enable autofocus after the initial render to avoid issue #1329. - menu.setAllowAutoFocus(true); }; /** @@ -270,14 +285,7 @@ Blockly.FieldDropdown.prototype.getAnchorDimensions_ = function() { * @param {!goog.ui.MenuItem} menuItem The MenuItem selected within menu. */ Blockly.FieldDropdown.prototype.onItemSelected = function(menu, menuItem) { - var value = menuItem.getValue(); - if (this.sourceBlock_) { - // Call any validation function, and allow it to override. - value = this.callValidator(value); - } - if (value !== null) { - this.setValue(value); - } + this.setValue(menuItem.getValue()); }; /** @@ -313,9 +321,9 @@ Blockly.FieldDropdown.prototype.trimOptions_ = function() { for (var i = 0; i < options.length; i++) { strings.push(options[i][0]); } - var shortest = Blockly.utils.shortestStringLength(strings); - var prefixLength = Blockly.utils.commonWordPrefix(strings, shortest); - var suffixLength = Blockly.utils.commonWordSuffix(strings, shortest); + var shortest = Blockly.utils.string.shortestStringLength(strings); + var prefixLength = Blockly.utils.string.commonWordPrefix(strings, shortest); + var suffixLength = Blockly.utils.string.commonWordSuffix(strings, shortest); if (!prefixLength && !suffixLength) { return; } @@ -380,32 +388,43 @@ Blockly.FieldDropdown.prototype.getOptions = function() { }; /** - * Get the language-neutral value from this dropdown menu. - * @return {string} Current text. + * Ensure that the input value is a valid language-neutral option. + * @param {string=} newValue The input value. + * @return {?string} A valid language-neutral option, or null if invalid. + * @protected */ -Blockly.FieldDropdown.prototype.getValue = function() { - return this.value_; +Blockly.FieldDropdown.prototype.doClassValidation_ = function(newValue) { + var isValueValid = false; + var options = this.getOptions(); + for (var i = 0, option; option = options[i]; i++) { + // Options are tuples of human-readable text and language-neutral values. + if (option[1] == newValue) { + isValueValid = true; + break; + } + } + if (!isValueValid) { + if (this.sourceBlock_) { + console.warn('Cannot set the dropdown\'s value to an unavailable option.' + + ' Block type: ' + this.sourceBlock_.type + ', Field name: ' + this.name + + ', Value: ' + newValue); + } + return null; + } + return newValue; }; /** - * Set the language-neutral value for this dropdown menu. - * @param {string} newValue New value to set. + * Update the value of this dropdown field. + * @param {string} newValue The new language-enutral value. + * @protected */ -Blockly.FieldDropdown.prototype.setValue = function(newValue) { - if (newValue === null || (newValue === this.value_ && this.text_)) { - return; // No change if null and text_ was initialized. - } - if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.BlockChange( - this.sourceBlock_, 'field', this.name, this.value_, newValue)); - } - this.value_ = newValue; - // Look up and display the human-readable text. +Blockly.FieldDropdown.prototype.doValueUpdate_ = function(newValue) { + Blockly.FieldDropdown.superClass_.doValueUpdate_.call(this, newValue); var options = this.getOptions(); - for (var i = 0; i < options.length; i++) { - // Options are tuples of human-readable text and language-neutral values. - if (options[i][1] == newValue) { - var content = options[i][0]; + for (var i = 0, option; option = options[i]; i++) { + if (option[1] == this.value_) { + var content = option[0]; if (typeof content == 'object') { this.imageJson_ = content; this.text_ = content.alt; @@ -413,15 +432,23 @@ Blockly.FieldDropdown.prototype.setValue = function(newValue) { this.imageJson_ = null; this.text_ = content; } - // Always rerender if either the value or the text has changed. - this.forceRerender(); - return; } } - // Value not found. Add it, maybe it will become valid once set - // (like variable names). - this.text_ = newValue; - this.forceRerender(); +}; + +/** + * Updates the dropdown arrow to match the colour/style of the block. + * @package + */ +Blockly.FieldDropdown.prototype.updateColour = function() { + // Update arrow's colour. + if (this.sourceBlock_ && this.arrow_) { + if (this.sourceBlock_.isShadow()) { + this.arrow_.style.fill = this.sourceBlock_.getColourShadow(); + } else { + this.arrow_.style.fill = this.sourceBlock_.getColour(); + } + } }; /** @@ -429,23 +456,11 @@ Blockly.FieldDropdown.prototype.setValue = function(newValue) { * @private */ Blockly.FieldDropdown.prototype.render_ = function() { - if (!this.visible_) { - this.size_.width = 0; - return; - } - if (this.sourceBlock_ && this.arrow_) { - // Update arrow's colour. - this.arrow_.style.fill = this.sourceBlock_.getColour(); - } - var child; - while ((child = this.textElement_.firstChild)) { - this.textElement_.removeChild(child); - } - if (this.imageElement_) { - Blockly.utils.removeNode(this.imageElement_); - this.imageElement_ = null; - } + // Hide both elements. + this.textContent_.nodeValue = ''; + this.imageElement_.style.display = 'none'; + // Show correct element. if (this.imageJson_) { this.renderSelectedImage_(); } else { @@ -461,20 +476,19 @@ Blockly.FieldDropdown.prototype.render_ = function() { * @private */ Blockly.FieldDropdown.prototype.renderSelectedImage_ = function() { - // Image option is selected. - this.imageElement_ = Blockly.utils.createSvgElement('image', - { - 'y': 5, - 'height': this.imageJson_.height + 'px', - 'width': this.imageJson_.width + 'px' - }, this.fieldGroup_); + this.imageElement_.style.display = ''; this.imageElement_.setAttributeNS( - 'http://www.w3.org/1999/xlink', 'xlink:href', this.imageJson_.src); - // Insert dropdown arrow. - this.textElement_.appendChild(this.arrow_); + Blockly.utils.dom.XLINK_NS, 'xlink:href', this.imageJson_.src); + this.imageElement_.setAttribute('height', this.imageJson_.height); + this.imageElement_.setAttribute('width', this.imageJson_.width); + var arrowWidth = Blockly.Field.getCachedWidth(this.arrow_); + // TODO: Standardize sizing, need to talk to rachel and abby about rendering + // redux. + // I think really this means plus 10? this.size_.height = Number(this.imageJson_.height) + 19; this.size_.width = Number(this.imageJson_.width) + arrowWidth; + if (this.sourceBlock_.RTL) { this.imageElement_.setAttribute('x', arrowWidth); this.textElement_.setAttribute('x', -1); @@ -489,52 +503,13 @@ Blockly.FieldDropdown.prototype.renderSelectedImage_ = function() { * @private */ Blockly.FieldDropdown.prototype.renderSelectedText_ = function() { - // Text option is selected. - // Replace the text. - var textNode = document.createTextNode(this.getDisplayText_()); - this.textElement_.appendChild(textNode); - // Insert dropdown arrow. - if (this.sourceBlock_.RTL) { - this.textElement_.insertBefore(this.arrow_, this.textElement_.firstChild); - } else { - this.textElement_.appendChild(this.arrow_); - } + this.textContent_.nodeValue = this.getDisplayText_(); this.textElement_.setAttribute('text-anchor', 'start'); this.textElement_.setAttribute('x', 0); - this.size_.height = Blockly.BlockSvg.MIN_BLOCK_Y; this.size_.width = Blockly.Field.getCachedWidth(this.textElement_); }; -/** - * Updates the width of the field. Overrides field.prototype.updateWidth to - * deal with image selections on IE and Edge. If the selected item is not an - * image, or if the browser is not IE / Edge, this simply calls the parent - * implementation. - */ -Blockly.FieldDropdown.prototype.updateWidth = function() { - if (this.imageJson_ && (goog.userAgent.IE || goog.userAgent.EDGE)) { - // Recalculate the full width. - var arrowWidth = Blockly.Field.getCachedWidth(this.arrow_); - var width = Number(this.imageJson_.width) + arrowWidth + - Blockly.BlockSvg.SEP_SPACE_X; - if (this.borderRect_) { - this.borderRect_.setAttribute('width', width); - } - this.size_.width = width; - } else { - Blockly.Field.prototype.updateWidth.call(this); - } -}; - -/** - * Close the dropdown menu if this input is being deleted. - */ -Blockly.FieldDropdown.prototype.dispose = function() { - Blockly.WidgetDiv.hideIfOwner(this); - Blockly.FieldDropdown.superClass_.dispose.call(this); -}; - /** * Validates the data structure to be processed as an options list. * @param {?} options The proposed dropdown options. diff --git a/core/field_image.js b/core/field_image.js index 6878c17f4b3..bd5a56ae176 100644 --- a/core/field_image.js +++ b/core/field_image.js @@ -27,16 +27,18 @@ goog.provide('Blockly.FieldImage'); goog.require('Blockly.Field'); +goog.require('Blockly.Tooltip'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); goog.require('goog.math.Size'); /** * Class for an image on a block. - * @param {string} src The URL of the image. - * @param {number} width Width of the image. - * @param {number} height Height of the image. + * @param {string=} src The URL of the image. Defaults to an empty string. + * @param {!(string|number)} width Width of the image. + * @param {!(string|number)} height Height of the image. * @param {string=} opt_alt Optional alt text for when block is collapsed. * @param {Function=} opt_onClick Optional function to be called when the image * is clicked. If opt_onClick is defined, opt_alt must also be defined. @@ -48,15 +50,25 @@ Blockly.FieldImage = function(src, width, height, opt_alt, opt_onClick, opt_flipRtl) { this.sourceBlock_ = null; + + if (isNaN(height) || isNaN(width)) { + throw Error('Height and width values of an image field must cast to' + + ' numbers.'); + } + // Ensure height and width are numbers. Strings are bad at math. this.height_ = Number(height); this.width_ = Number(width); + if (this.height_ <= 0 || this.width_ <= 0) { + throw Error('Height and width values of an image field must be greater' + + ' than 0.'); + } this.size_ = new goog.math.Size(this.width_, this.height_ + 2 * Blockly.BlockSvg.INLINE_PADDING_Y); + this.flipRtl_ = opt_flipRtl; - this.tooltip_ = ''; - this.setValue(src); - this.setText(opt_alt); + this.text_ = opt_alt || ''; + this.setValue(src || ''); if (typeof opt_onClick == 'function') { this.clickHandler_ = opt_onClick; @@ -84,106 +96,62 @@ Blockly.FieldImage.fromJson = function(options) { }; /** - * Editable fields are saved by the XML renderer, non-editable fields are not. + * Editable fields usually show some sort of UI indicating they are + * editable. This field should not. + * @type {boolean} + * @const */ Blockly.FieldImage.prototype.EDITABLE = false; /** - * Install this image on a block. + * Used to tell if the field needs to be rendered the next time the block is + * rendered. Image fields are statically sized, and only need to be + * rendered at initialization. + * @type {boolean} + * @private */ -Blockly.FieldImage.prototype.init = function() { - if (this.fieldGroup_) { - // Image has already been initialized once. - return; - } - // Build the DOM. - /** @type {SVGElement} */ - this.fieldGroup_ = Blockly.utils.createSvgElement('g', {}, null); - if (!this.visible_) { - this.fieldGroup_.style.display = 'none'; - } - /** @type {SVGElement} */ - this.imageElement_ = Blockly.utils.createSvgElement( +Blockly.FieldImage.prototype.isDirty_ = false; + +/** + * Create the block UI for this image. + * @package + */ +Blockly.FieldImage.prototype.initView = function() { + this.imageElement_ = Blockly.utils.dom.createSvgElement( 'image', { 'height': this.height_ + 'px', - 'width': this.width_ + 'px' + 'width': this.width_ + 'px', + 'alt': this.text_ }, this.fieldGroup_); - this.setValue(this.src_); - this.setText(this.text_); - this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_); - - if (this.tooltip_) { - this.imageElement_.tooltip = this.tooltip_; - } else { - // Configure the field to be transparent with respect to tooltips. - this.setTooltip(this.sourceBlock_); - } - Blockly.Tooltip.bindMouseEvents(this.imageElement_); - - this.maybeAddClickHandler_(); + this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS, + 'xlink:href', this.value_); }; /** - * Dispose of all DOM objects belonging to this text. + * Ensure that the input value (the source URL) is a string. + * @param {string=} newValue The input value + * @return {?string} A string, or null if invalid. + * @protected */ -Blockly.FieldImage.prototype.dispose = function() { - if (this.fieldGroup_) { - Blockly.utils.removeNode(this.fieldGroup_); - this.fieldGroup_ = null; +Blockly.FieldImage.prototype.doClassValidation_ = function(newValue) { + if (typeof newValue != 'string') { + return null; } - this.imageElement_ = null; + return newValue; }; /** - * Bind events for a mouse down on the image, but only if a click handler has - * been defined. - * @private + * Update the value of this image field, and update the displayed image. + * @param {string} newValue The new image src. + * @protected */ -Blockly.FieldImage.prototype.maybeAddClickHandler_ = function() { - if (this.clickHandler_) { - this.mouseDownWrapper_ = - Blockly.bindEventWithChecks_( - this.fieldGroup_, 'mousedown', this, this.clickHandler_); - } -}; - -/** - * Change the tooltip text for this field. - * @param {string|!Element} newTip Text for tooltip or a parent element to - * link to for its tooltip. - */ -Blockly.FieldImage.prototype.setTooltip = function(newTip) { - this.tooltip_ = newTip; +Blockly.FieldImage.prototype.doValueUpdate_ = function(newValue) { + this.value_ = newValue; if (this.imageElement_) { - this.imageElement_.tooltip = newTip; - } -}; - -/** - * Get the source URL of this image. - * @return {string} Current text. - * @override - */ -Blockly.FieldImage.prototype.getValue = function() { - return this.src_; -}; - -/** - * Set the source URL of this image. - * @param {?string} src New source. - * @override - */ -Blockly.FieldImage.prototype.setValue = function(src) { - if (src === null) { - // No change if null. - return; - } - this.src_ = src; - if (this.imageElement_) { - this.imageElement_.setAttributeNS('http://www.w3.org/1999/xlink', - 'xlink:href', src || ''); + this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS, + 'xlink:href', this.value_ || ''); } }; @@ -211,29 +179,6 @@ Blockly.FieldImage.prototype.setText = function(alt) { } }; -/** - * Images are fixed width, no need to render. - * @private - */ -Blockly.FieldImage.prototype.render_ = function() { - // NOP -}; - -/** - * Images are fixed width, no need to render even if forced. - */ -Blockly.FieldImage.prototype.forceRerender = function() { - // NOP -}; - -/** - * Images are fixed width, no need to update. - * @private - */ -Blockly.FieldImage.prototype.updateWidth = function() { - // NOP -}; - /** * If field click is called, and click handler defined, * call the handler. diff --git a/core/field_label.js b/core/field_label.js index 7050c6b7ad8..efeeb1e6c46 100644 --- a/core/field_label.js +++ b/core/field_label.js @@ -19,7 +19,8 @@ */ /** - * @fileoverview Non-editable text field. Used for titles, labels, etc. + * @fileoverview Non-editable, non-serializable text field. Used for titles, + * labels, etc. * @author fraser@google.com (Neil Fraser) */ 'use strict'; @@ -29,22 +30,27 @@ goog.provide('Blockly.FieldLabel'); goog.require('Blockly.Field'); goog.require('Blockly.Tooltip'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); goog.require('goog.math.Size'); /** - * Class for a non-editable field. - * @param {string} text The initial content of the field. + * Class for a non-editable, non-serializable text field. + * @param {string=} opt_value The initial value of the field. Should cast to a + * string. Defaults to an empty string if null or undefined. * @param {string=} opt_class Optional CSS class for the field's text. * @extends {Blockly.Field} * @constructor */ -Blockly.FieldLabel = function(text, opt_class) { +Blockly.FieldLabel = function(opt_value, opt_class) { this.size_ = new goog.math.Size(0, 17.5); this.class_ = opt_class; - this.setValue(text); - this.tooltip_ = ''; + opt_value = this.doClassValidation_(opt_value); + if (opt_value === null) { + opt_value = ''; + } + this.setValue(opt_value); }; goog.inherits(Blockly.FieldLabel, Blockly.Field); @@ -62,69 +68,36 @@ Blockly.FieldLabel.fromJson = function(options) { }; /** - * Editable fields are saved by the XML renderer, non-editable fields are not. + * Editable fields usually show some sort of UI indicating they are + * editable. This field should not. + * @type {boolean} + * @const */ Blockly.FieldLabel.prototype.EDITABLE = false; /** - * Install this text on a block. + * Create block UI for this label. + * @package */ -Blockly.FieldLabel.prototype.init = function() { - if (this.textElement_) { - // Text has already been initialized once. - return; - } - // Build the DOM. - this.textElement_ = Blockly.utils.createSvgElement('text', - {'class': 'blocklyText', 'y': this.size_.height - 5}, null); +Blockly.FieldLabel.prototype.initView = function() { + this.createTextElement_(); + this.textElement_.setAttribute('y', this.size_.height - 5); if (this.class_) { - Blockly.utils.addClass(this.textElement_, this.class_); - } - if (!this.visible_) { - this.textElement_.style.display = 'none'; + Blockly.utils.dom.addClass(this.textElement_, this.class_); } - this.sourceBlock_.getSvgRoot().appendChild(this.textElement_); - - if (this.tooltip_) { - this.textElement_.tooltip = this.tooltip_; - } else { - // Configure the field to be transparent with respect to tooltips. - this.textElement_.tooltip = this.sourceBlock_; - } - Blockly.Tooltip.bindMouseEvents(this.textElement_); - // Force a render. - this.render_(); -}; - -/** - * Dispose of all DOM objects belonging to this text. - */ -Blockly.FieldLabel.prototype.dispose = function() { - if (this.textElement_) { - Blockly.utils.removeNode(this.textElement_); - this.textElement_ = null; - } -}; - -/** - * Gets the group element for this field. - * Used for measuring the size and for positioning. - * @return {!Element} The group element. - */ -Blockly.FieldLabel.prototype.getSvgRoot = function() { - return /** @type {!Element} */ (this.textElement_); }; /** - * Change the tooltip text for this field. - * @param {string|!Element} newTip Text for tooltip or a parent element to - * link to for its tooltip. + * Ensure that the input value casts to a valid string. + * @param {string=} newValue The input value. + * @return {?string} A valid string, or null if invalid. + * @protected */ -Blockly.FieldLabel.prototype.setTooltip = function(newTip) { - this.tooltip_ = newTip; - if (this.textElement_) { - this.textElement_.tooltip = newTip; +Blockly.FieldLabel.prototype.doClassValidation_ = function(newValue) { + if (newValue === null || newValue === undefined) { + return null; } + return String(newValue); }; Blockly.Field.register('field_label', Blockly.FieldLabel); diff --git a/core/field_label_serializable.js b/core/field_label_serializable.js new file mode 100644 index 00000000000..833a4c61dcd --- /dev/null +++ b/core/field_label_serializable.js @@ -0,0 +1,79 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Non-editable, serializable text field. Behaves like a + * normal label but is serialized to XML. It may only be + * edited programmatically. + */ +'use strict'; + +goog.provide('Blockly.FieldLabelSerializable'); + +goog.require('Blockly.FieldLabel'); +goog.require('Blockly.utils'); + + +/** + * Class for a non-editable, serializable text field. + * @param {*} opt_value The initial value of the field. Should cast to a + * string. Defaults to an empty string if null or undefined. + * @param {string=} opt_class Optional CSS class for the field's text. + * @extends {Blockly.FieldLabel} + * @constructor + * + */ +Blockly.FieldLabelSerializable = function(opt_value, opt_class) { + Blockly.FieldLabelSerializable.superClass_.constructor.call(this, opt_value, + opt_class); +}; +goog.inherits(Blockly.FieldLabelSerializable, Blockly.FieldLabel); + +/** + * Construct a FieldLabelSerializable from a JSON arg object, + * dereferencing any string table references. + * @param {!Object} options A JSON object with options (text, and class). + * @returns {!Blockly.FieldLabelSerializable} The new field instance. + * @package + * @nocollapse + */ +Blockly.FieldLabelSerializable.fromJson = function(options) { + var text = Blockly.utils.replaceMessageReferences(options['text']); + return new Blockly.FieldLabelSerializable(text, options['class']); +}; + +/** + * Editable fields usually show some sort of UI indicating they are + * editable. This field should not. + * @type {boolean} + * @public + */ +Blockly.FieldLabelSerializable.prototype.EDITABLE = false; + +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. This field should be serialized, but only edited programmatically. + * @type {boolean} + * @public + */ +Blockly.FieldLabelSerializable.prototype.SERIALIZABLE = true; + +Blockly.Field.register( + 'field_label_serializable', Blockly.FieldLabelSerializable); diff --git a/core/field_number.js b/core/field_number.js index 7d4cf275901..2e729d193d4 100644 --- a/core/field_number.js +++ b/core/field_number.js @@ -31,24 +31,25 @@ goog.require('Blockly.FieldTextInput'); /** * Class for an editable number field. - * @param {(string|number)=} opt_value The initial content of the field. - * The value should cast to a number, and if it does not, '0' will be used. + * @param {string|number=} opt_value The initial value of the field. Should cast + * to a number. Defaults to 0. * @param {(string|number)=} opt_min Minimum value. * @param {(string|number)=} opt_max Maximum value. * @param {(string|number)=} opt_precision Precision for value. - * @param {Function=} opt_validator An optional function that is called - * to validate any constraints on what the user entered. Takes the new - * text as an argument and returns either the accepted text, a replacement - * text, or null to abort the change. - * @extends {Blockly.FieldTextInput} + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a number & returns a validated + * number, or null to abort the change. * @constructor */ Blockly.FieldNumber = function(opt_value, opt_min, opt_max, opt_precision, opt_validator) { - opt_value = (opt_value && !isNaN(opt_value)) ? String(opt_value) : '0'; + this.setConstraints(opt_min, opt_max, opt_precision); + opt_value = this.doClassValidation_(opt_value); + if (opt_value === null) { + opt_value = 0; + } Blockly.FieldNumber.superClass_.constructor.call( this, opt_value, opt_validator); - this.setConstraints(opt_min, opt_max, opt_precision); }; goog.inherits(Blockly.FieldNumber, Blockly.FieldTextInput); @@ -65,6 +66,14 @@ Blockly.FieldNumber.fromJson = function(options) { options['min'], options['max'], options['precision']); }; +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const + */ +Blockly.FieldNumber.prototype.SERIALIZABLE = true; + /** * Set the maximum, minimum and precision constraints on this field. * Any of these properties may be undefiend or NaN to be disabled. @@ -79,40 +88,52 @@ Blockly.FieldNumber.fromJson = function(options) { Blockly.FieldNumber.prototype.setConstraints = function(min, max, precision) { precision = parseFloat(precision); this.precision_ = isNaN(precision) ? 0 : precision; + var precisionString = this.precision_.toString(); + var decimalIndex = precisionString.indexOf('.'); + this.fractionalDigits_ = (decimalIndex == -1) ? -1 : + precisionString.length - (decimalIndex + 1); min = parseFloat(min); this.min_ = isNaN(min) ? -Infinity : min; max = parseFloat(max); this.max_ = isNaN(max) ? Infinity : max; - this.setValue(this.callValidator(this.getValue())); + this.setValue(this.getValue()); }; /** - * Ensure that only a number in the correct range may be entered. - * @param {string} text The user's text. - * @return {?string} A string representing a valid number, or null if invalid. + * Ensure that the input value is a valid number (must fulfill the + * constraints placed on the field). + * @param {string|number=} newValue The input value. + * @return {?number} A valid number, or null if invalid. + * @protected */ -Blockly.FieldNumber.prototype.classValidator = function(text) { - if (text === null) { +Blockly.FieldNumber.prototype.doClassValidation_ = function(newValue) { + if (newValue === null || newValue === undefined) { return null; } - text = String(text); + // Clean up text. + newValue = String(newValue); // TODO: Handle cases like 'ten', '1.203,14', etc. // 'O' is sometimes mistaken for '0' by inexperienced users. - text = text.replace(/O/ig, '0'); + newValue = newValue.replace(/O/ig, '0'); // Strip out thousands separators. - text = text.replace(/,/g, ''); - var n = parseFloat(text || 0); + newValue = newValue.replace(/,/g, ''); + + // Clean up number. + var n = parseFloat(newValue || 0); if (isNaN(n)) { // Invalid number. return null; } + // Get the value in range. + n = Math.min(Math.max(n, this.min_), this.max_); // Round to nearest multiple of precision. if (this.precision_ && isFinite(n)) { n = Math.round(n / this.precision_) * this.precision_; } - // Get the value in range. - n = Math.min(Math.max(n, this.min_), this.max_); - return String(n); + // Clean up floating point errors. + n = (this.fractionalDigits_ == -1) ? n : + Number(n.toFixed(this.fractionalDigits_)); + return n; }; Blockly.Field.register('field_number', Blockly.FieldNumber); diff --git a/core/field_textinput.js b/core/field_textinput.js index a2f587d18a8..c525b5c9c39 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -26,27 +26,32 @@ goog.provide('Blockly.FieldTextInput'); -goog.require('Blockly.DropDownDiv'); +goog.require('Blockly.Events'); +goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Field'); goog.require('Blockly.Msg'); goog.require('Blockly.utils'); - -goog.require('goog.math.Coordinate'); -goog.require('goog.userAgent'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.userAgent'); /** * Class for an editable text field. - * @param {string} text The initial content of the field. - * @param {Function=} opt_validator An optional function that is called - * to validate any constraints on what the user entered. Takes the new - * text as an argument and returns either the accepted text, a replacement - * text, or null to abort the change. + * @param {string=} opt_value The initial value of the field. Should cast to a + * string. Defaults to an empty string if null or undefined. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a string & returns a validated + * string, or null to abort the change. * @extends {Blockly.Field} * @constructor */ -Blockly.FieldTextInput = function(text, opt_validator) { - Blockly.FieldTextInput.superClass_.constructor.call(this, text, +Blockly.FieldTextInput = function(opt_value, opt_validator) { + opt_value = this.doClassValidation_(opt_value); + if (opt_value === null) { + opt_value = ''; + } + Blockly.FieldTextInput.superClass_.constructor.call(this, opt_value, opt_validator); }; goog.inherits(Blockly.FieldTextInput, Blockly.Field); @@ -62,7 +67,7 @@ goog.inherits(Blockly.FieldTextInput, Blockly.Field); */ Blockly.FieldTextInput.fromJson = function(options) { var text = Blockly.utils.replaceMessageReferences(options['text']); - var field = new Blockly.FieldTextInput(text, options['class']); + var field = new Blockly.FieldTextInput(text); if (typeof options['spellcheck'] === 'boolean') { field.setSpellcheck(options['spellcheck']); } @@ -70,17 +75,17 @@ Blockly.FieldTextInput.fromJson = function(options) { }; /** - * Point size of text. Should match blocklyText's font-size in CSS. + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const */ -Blockly.FieldTextInput.FONTSIZE = 11; +Blockly.FieldTextInput.prototype.SERIALIZABLE = true; /** - * The HTML input element for the user to type, or null if no FieldTextInput - * editor is currently open. - * @type {HTMLInputElement} - * @protected + * Point size of text. Should match blocklyText's font-size in CSS. */ -Blockly.FieldTextInput.htmlInput_ = null; +Blockly.FieldTextInput.FONTSIZE = 11; /** * Mouse cursor style when over the hotspot that initiates the editor. @@ -94,51 +99,74 @@ Blockly.FieldTextInput.prototype.CURSOR = 'text'; Blockly.FieldTextInput.prototype.spellcheck_ = true; /** - * Close the input widget if this input is being deleted. + * Ensure that the input value casts to a valid string. + * @param {string=} newValue The input value. + * @return {?string} A valid string, or null if invalid. + * @protected */ -Blockly.FieldTextInput.prototype.dispose = function() { - Blockly.WidgetDiv.hideIfOwner(this); - Blockly.FieldTextInput.superClass_.dispose.call(this); +Blockly.FieldTextInput.prototype.doClassValidation_ = function(newValue) { + if (newValue === null || newValue === undefined) { + return null; + } + return String(newValue); }; /** - * Set the value of this field. - * @param {?string} newValue New value. - * @override + * Called by setValue if the text input is not valid. If the field is + * currently being edited it reverts value of the field to the previous + * value while allowing the display text to be handled by the htmlInput_. + * @param {*} _invalidValue The input value that was determined to be invalid. + * This is not used by the text input because its display value is stored on + * the htmlInput_. + * @protected */ -Blockly.FieldTextInput.prototype.setValue = function(newValue) { - if (newValue !== null) { // No change if null. - if (this.sourceBlock_) { - var validated = this.callValidator(newValue); - // If the new value is invalid, validation returns null. - // In this case we still want to display the illegal result. - if (validated !== null) { - newValue = validated; - } +Blockly.FieldTextInput.prototype.doValueInvalid_ = function(_invalidValue) { + if (this.isBeingEdited_) { + this.isTextValid_ = false; + var oldValue = this.value_; + // Revert value when the text becomes invalid. + this.value_ = this.htmlInput_.untypedDefaultValue_; + if (this.sourceBlock_ && Blockly.Events.isEnabled()) { + Blockly.Events.fire(new Blockly.Events.BlockChange( + this.sourceBlock_, 'field', this.name, oldValue, this.value_)); } - Blockly.Field.prototype.setValue.call(this, newValue); } }; /** - * Set the text in this field and fire a change event. - * @param {*} newText New text. + * Called by setValue if the text input is valid. Updates the value of the + * field, and updates the text of the field if it is not currently being + * edited (i.e. handled by the htmlInput_). + * @param {string} newValue The new validated value of the field. + * @protected */ -Blockly.FieldTextInput.prototype.setText = function(newText) { - if (newText === null) { - // No change if null. - return; +Blockly.FieldTextInput.prototype.doValueUpdate_ = function(newValue) { + this.isTextValid_ = true; + this.value_ = newValue; + if (!this.isBeingEdited_) { + // This should only occur if setValue is triggered programmatically. + this.text_ = String(newValue); + this.isDirty_ = true; } - newText = String(newText); - if (newText === this.text_) { - // No change. - return; - } - if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.BlockChange( - this.sourceBlock_, 'field', this.name, this.text_, newText)); +}; + +/** + * Updates the colour of the htmlInput given the current validity of the + * field's value. + * @protected + */ +Blockly.FieldTextInput.prototype.render_ = function() { + Blockly.FieldTextInput.superClass_.render_.call(this); + // This logic is done in render_ rather than doValueInvalid_ or + // doValueUpdate_ so that the code is more centralized. + if (this.isBeingEdited_) { + this.resizeEditor_(); + if (!this.isTextValid_) { + Blockly.utils.dom.addClass(this.htmlInput_, 'blocklyInvalidInput'); + } else { + Blockly.utils.dom.removeClass(this.htmlInput_, 'blocklyInvalidInput'); + } } - Blockly.Field.prototype.setText.call(this, newText); }; /** @@ -158,8 +186,9 @@ Blockly.FieldTextInput.prototype.setSpellcheck = function(check) { Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) { this.workspace_ = this.sourceBlock_.workspace; var quietInput = opt_quietInput || false; - if (!quietInput && (goog.userAgent.MOBILE || goog.userAgent.ANDROID || - goog.userAgent.IPAD)) { + if (!quietInput && (Blockly.utils.userAgent.MOBILE || + Blockly.utils.userAgent.ANDROID || + Blockly.utils.userAgent.IPAD)) { this.showPromptEditor_(); } else { this.showInlineEditor_(quietInput); @@ -175,9 +204,6 @@ Blockly.FieldTextInput.prototype.showPromptEditor_ = function() { var fieldText = this; Blockly.prompt(Blockly.Msg['CHANGE_VALUE_TITLE'], this.text_, function(newValue) { - if (fieldText.sourceBlock_) { - newValue = fieldText.callValidator(newValue); - } fieldText.setValue(newValue); }); }; @@ -189,9 +215,25 @@ Blockly.FieldTextInput.prototype.showPromptEditor_ = function() { * @private */ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { - Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_()); + this.isBeingEdited_ = true; + Blockly.WidgetDiv.show( + this, this.sourceBlock_.RTL, this.widgetDispose_.bind(this)); + this.htmlInput_ = this.widgetCreate_(); + + if (!quietInput) { + this.htmlInput_.focus(); + this.htmlInput_.select(); + } +}; + +/** + * Create the text input editor widget. + * @return {!HTMLInputElement} The newly created text input editor. + * @private + */ +Blockly.FieldTextInput.prototype.widgetCreate_ = function() { var div = Blockly.WidgetDiv.DIV; - // Create the input. + var htmlInput = document.createElement('input'); htmlInput.className = 'blocklyHtmlInput'; htmlInput.setAttribute('spellcheck', this.spellcheck_); @@ -199,56 +241,88 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { (Blockly.FieldTextInput.FONTSIZE * this.workspace_.scale) + 'pt'; div.style.fontSize = fontSize; htmlInput.style.fontSize = fontSize; - - Blockly.FieldTextInput.htmlInput_ = htmlInput; div.appendChild(htmlInput); - htmlInput.value = htmlInput.defaultValue = this.text_; + htmlInput.value = htmlInput.defaultValue = this.value_; + htmlInput.untypedDefaultValue_ = this.value_; htmlInput.oldValue_ = null; - this.validate_(); this.resizeEditor_(); - if (!quietInput) { - htmlInput.focus(); - htmlInput.select(); + + this.bindInputEvents_(htmlInput); + + return htmlInput; +}; + +/** + * Close the editor, save the results, and dispose any events bound to the + * text input's editor. + * @private + */ +Blockly.FieldTextInput.prototype.widgetDispose_ = function() { + // Finalize value. + this.isBeingEdited_ = false; + // No need to call setValue because if the widget is being closed the + // latest input text has already been validated. + if (this.value_ !== this.text_) { + // At the end of an edit the text should be the same as the value. It + // may not be if the input text is different than the validated text. + // We should fix that. + this.text_ = String(this.value_); + this.isTextValid_ = true; + this.forceRerender(); } + // Otherwise don't rerender. - this.bindEvents_(htmlInput); + // Call onFinishEditing + // TODO: Get rid of this or make it less of a hack. + if (this.onFinishEditing_) { + this.onFinishEditing_(this.value_); + } + + // Remove htmlInput events. + this.unbindInputEvents_(); + + // Delete style properties. + var style = Blockly.WidgetDiv.DIV.style; + style.width = 'auto'; + style.height = 'auto'; + style.fontSize = ''; }; /** - * Bind handlers for user input on this field and size changes on the workspace. - * @param {!HTMLInputElement} htmlInput The htmlInput created in showEditor, to - * which event handlers will be bound. + * Bind handlers for user input on the text input field's editor. + * @param {!HTMLInputElement} htmlInput The htmlInput to which event + * handlers will be bound. * @private */ -Blockly.FieldTextInput.prototype.bindEvents_ = function(htmlInput) { - // Bind to keydown -- trap Enter without IME and Esc to hide. - htmlInput.onKeyDownWrapper_ = +Blockly.FieldTextInput.prototype.bindInputEvents_ = function(htmlInput) { + // Trap Enter without IME and Esc to hide. + this.onKeyDownWrapper_ = Blockly.bindEventWithChecks_( htmlInput, 'keydown', this, this.onHtmlInputKeyDown_); - // Bind to keyup -- trap Enter; resize after every keystroke. - htmlInput.onKeyUpWrapper_ = + // Resize after every keystroke. + this.onKeyUpWrapper_ = Blockly.bindEventWithChecks_( htmlInput, 'keyup', this, this.onHtmlInputChange_); - // Bind to keyPress -- repeatedly resize when holding down a key. - htmlInput.onKeyPressWrapper_ = + // Repeatedly resize when holding down a key. + this.onKeyPressWrapper_ = Blockly.bindEventWithChecks_( htmlInput, 'keypress', this, this.onHtmlInputChange_); - htmlInput.onWorkspaceChangeWrapper_ = this.resizeEditor_.bind(this); - this.workspace_.addChangeListener(htmlInput.onWorkspaceChangeWrapper_); + + // TODO: Figure out if this is necessary. + this.onWorkspaceChangeWrapper_ = this.resizeEditor_.bind(this); + this.workspace_.addChangeListener(this.onWorkspaceChangeWrapper_); }; /** * Unbind handlers for user input and workspace size changes. - * @param {!HTMLInputElement} htmlInput The html for this text input. * @private */ -Blockly.FieldTextInput.prototype.unbindEvents_ = function(htmlInput) { - Blockly.unbindEvent_(htmlInput.onKeyDownWrapper_); - Blockly.unbindEvent_(htmlInput.onKeyUpWrapper_); - Blockly.unbindEvent_(htmlInput.onKeyPressWrapper_); - this.workspace_.removeChangeListener( - htmlInput.onWorkspaceChangeWrapper_); +Blockly.FieldTextInput.prototype.unbindInputEvents_ = function() { + Blockly.unbindEvent_(this.onKeyDownWrapper_); + Blockly.unbindEvent_(this.onKeyUpWrapper_); + Blockly.unbindEvent_(this.onKeyPressWrapper_); + this.workspace_.removeChangeListener(this.onWorkspaceChangeWrapper_); }; /** @@ -257,18 +331,14 @@ Blockly.FieldTextInput.prototype.unbindEvents_ = function(htmlInput) { * @private */ Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_ = function(e) { - var htmlInput = Blockly.FieldTextInput.htmlInput_; var tabKey = 9, enterKey = 13, escKey = 27; if (e.keyCode == enterKey) { Blockly.WidgetDiv.hide(); - Blockly.DropDownDiv.hideIfOwner(this); } else if (e.keyCode == escKey) { - htmlInput.value = htmlInput.defaultValue; + this.htmlInput_.value = this.htmlInput_.defaultValue; Blockly.WidgetDiv.hide(); - Blockly.DropDownDiv.hideIfOwner(this); } else if (e.keyCode == tabKey) { Blockly.WidgetDiv.hide(); - Blockly.DropDownDiv.hideIfOwner(this); this.sourceBlock_.tab(this, !e.shiftKey); e.preventDefault(); } @@ -280,51 +350,24 @@ Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_ = function(e) { * @private */ Blockly.FieldTextInput.prototype.onHtmlInputChange_ = function(_e) { - var htmlInput = Blockly.FieldTextInput.htmlInput_; - // Update source block. - var text = htmlInput.value; - if (text !== htmlInput.oldValue_) { - htmlInput.oldValue_ = text; + var text = this.htmlInput_.value; + if (text !== this.htmlInput_.oldValue_) { + this.htmlInput_.oldValue_ = text; // TODO(#2169): Once issue is fixed the setGroup functionality could be // moved up to the Field setValue method. This would create a // broader fix for all field types. Blockly.Events.setGroup(true); this.setValue(text); + // Always render the input text. + this.text_ = this.htmlInput_.value; + this.forceRerender(); Blockly.Events.setGroup(false); - this.validate_(); - } else if (goog.userAgent.WEBKIT) { - // Cursor key. Render the source block to show the caret moving. - // Chrome only (version 26, OS X). - this.sourceBlock_.render(); - } - this.resizeEditor_(); - Blockly.svgResize(this.sourceBlock_.workspace); -}; - -/** - * Check to see if the contents of the editor validates. - * Style the editor accordingly. - * @protected - */ -Blockly.FieldTextInput.prototype.validate_ = function() { - var valid = true; - if (!Blockly.FieldTextInput.htmlInput_) { - throw Error('htmlInput not defined'); - } - var htmlInput = Blockly.FieldTextInput.htmlInput_; - if (this.sourceBlock_) { - valid = this.callValidator(htmlInput.value); - } - if (valid === null) { - Blockly.utils.addClass(htmlInput, 'blocklyInvalidInput'); - } else { - Blockly.utils.removeClass(htmlInput, 'blocklyInvalidInput'); } }; /** - * Resize the editor and the underlying block to fit the text. + * Resize the editor to fit the text. * @protected */ Blockly.FieldTextInput.prototype.resizeEditor_ = function() { @@ -336,78 +379,28 @@ Blockly.FieldTextInput.prototype.resizeEditor_ = function() { // In RTL mode block fields and LTR input fields the left edge moves, // whereas the right edge is fixed. Reposition the editor. var x = this.sourceBlock_.RTL ? bBox.right - div.offsetWidth : bBox.left; - var xy = new goog.math.Coordinate(x, bBox.top); + var xy = new Blockly.utils.Coordinate(x, bBox.top); // Shift by a few pixels to line up exactly. xy.y += 1; - if (goog.userAgent.GECKO && Blockly.WidgetDiv.DIV.style.top) { + if (Blockly.utils.userAgent.GECKO && Blockly.WidgetDiv.DIV.style.top) { // Firefox mis-reports the location of the border by a pixel // once the WidgetDiv is moved into position. xy.x -= 1; xy.y -= 1; } - if (goog.userAgent.WEBKIT) { + if (Blockly.utils.userAgent.WEBKIT) { xy.y -= 3; } div.style.left = xy.x + 'px'; div.style.top = xy.y + 'px'; }; -/** - * Close the editor, save the results, and dispose of the editable - * text field's elements. - * @return {!Function} Closure to call on destruction of the WidgetDiv. - * @private - */ -Blockly.FieldTextInput.prototype.widgetDispose_ = function() { - var thisField = this; - return function() { - var htmlInput = Blockly.FieldTextInput.htmlInput_; - // Save the edit (if it validates). - thisField.maybeSaveEdit_(); - - thisField.unbindEvents_(htmlInput); - Blockly.FieldTextInput.htmlInput_ = null; - Blockly.Events.setGroup(false); - - // Delete style properties. - var style = Blockly.WidgetDiv.DIV.style; - style.width = 'auto'; - style.height = 'auto'; - style.fontSize = ''; - }; -}; - -/** - * Attempt to save the text field changes when the user input loses focus. - * If the value is not valid, revert to the default value. - * @private - */ -Blockly.FieldTextInput.prototype.maybeSaveEdit_ = function() { - var htmlInput = Blockly.FieldTextInput.htmlInput_; - // Save the edit (if it validates). - var text = htmlInput.value; - if (this.sourceBlock_) { - var text1 = this.callValidator(text); - if (text1 === null) { - // Invalid edit. - text = htmlInput.defaultValue; - } else { - // Validation function has changed the text. - text = text1; - if (this.onFinishEditing_) { - this.onFinishEditing_(text); - } - } - } - this.setText(text); - this.sourceBlock_.rendered && this.sourceBlock_.render(); -}; - /** * Ensure that only a number may be entered. * @param {string} text The user's text. * @return {?string} A string representing a valid number, or null if invalid. + * @deprecated */ Blockly.FieldTextInput.numberValidator = function(text) { console.warn('Blockly.FieldTextInput.numberValidator is deprecated. ' + @@ -429,6 +422,7 @@ Blockly.FieldTextInput.numberValidator = function(text) { * Ensure that only a nonnegative integer may be entered. * @param {string} text The user's text. * @return {?string} A string representing a valid int, or null if invalid. + * @deprecated */ Blockly.FieldTextInput.nonnegativeIntegerValidator = function(text) { var n = Blockly.FieldTextInput.numberValidator(text); diff --git a/core/field_variable.js b/core/field_variable.js index fae79727cf4..42fba9ebeff 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -26,11 +26,14 @@ goog.provide('Blockly.FieldVariable'); +goog.require('Blockly.Events'); +goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.FieldDropdown'); goog.require('Blockly.Msg'); goog.require('Blockly.utils'); goog.require('Blockly.VariableModel'); goog.require('Blockly.Variables'); +goog.require('Blockly.Xml'); goog.require('goog.math.Size'); @@ -39,8 +42,9 @@ goog.require('goog.math.Size'); * Class for a variable's dropdown field. * @param {?string} varname The default name for the variable. If null, * a unique variable name will be generated. - * @param {Function=} opt_validator A function that is executed when a new - * option is selected. Its sole argument is the new option value. + * @param {Function=} opt_validator A function that is called to validate + * changes to the field's value. Takes in a variable ID & returns a + * validated variable ID, or null to abort the change. * @param {Array.=} opt_variableTypes A list of the types of variables * to include in the dropdown. * @param {string=} opt_defaultType The type of variable to create if this @@ -79,20 +83,19 @@ Blockly.FieldVariable.fromJson = function(options) { }; /** - * Initialize everything needed to render this field. This includes making sure - * that the field's value is valid. - * @public + * The workspace that this variable field belongs to. + * @type {?Blockly.Workspace} + * @private */ -Blockly.FieldVariable.prototype.init = function() { - if (this.fieldGroup_) { - // Dropdown has already been initialized once. - return; - } - Blockly.FieldVariable.superClass_.init.call(this); +Blockly.FieldVariable.prototype.workspace_ = null; - // TODO (#1010): Change from init/initModel to initView/initModel - this.initModel(); -}; +/** + * Serializable fields are saved by the XML renderer, non-serializable fields + * are not. Editable fields should also be serializable. + * @type {boolean} + * @const + */ +Blockly.FieldVariable.prototype.SERIALIZABLE = true; /** * Initialize the model for this field if it has not already been initialized. @@ -104,28 +107,59 @@ Blockly.FieldVariable.prototype.initModel = function() { if (this.variable_) { return; // Initialization already happened. } - this.workspace_ = this.sourceBlock_.workspace; var variable = Blockly.Variables.getOrCreateVariablePackage( this.workspace_, null, this.defaultVariableName, this.defaultType_); // Don't fire a change event for this setValue. It would have null as the // old value, which is not valid. Blockly.Events.disable(); - try { - this.setValue(variable.getId()); - } finally { - Blockly.Events.enable(); + this.setValue(variable.getId()); + Blockly.Events.enable(); +}; + +/** + * Initialize this field based on the given XML. + * @param {!Element} fieldElement The element containing information about the + * variable field's state. + */ +Blockly.FieldVariable.prototype.fromXml = function(fieldElement) { + var id = fieldElement.getAttribute('id'); + var variableName = fieldElement.textContent; + // 'variabletype' should be lowercase, but until July 2019 it was sometimes + // recorded as 'variableType'. Thus we need to check for both. + var variableType = fieldElement.getAttribute('variabletype') || + fieldElement.getAttribute('variableType') || ''; + + var variable = Blockly.Variables.getOrCreateVariablePackage( + this.workspace_, id, variableName, variableType); + + // This should never happen :) + if (variableType != null && variableType !== variable.type) { + throw Error('Serialized variable type with id \'' + + variable.getId() + '\' had type ' + variable.type + ', and ' + + 'does not match variable field that references it: ' + + Blockly.Xml.domToText(fieldElement) + '.'); } + + this.setValue(variable.getId()); }; /** - * Dispose of this field. - * @public + * Serialize this field to XML. + * @param {!Element} fieldElement The element to populate with info about the + * field's state. + * @return {!Element} The element containing info about the field's state. */ -Blockly.FieldVariable.prototype.dispose = function() { - Blockly.FieldVariable.superClass_.dispose.call(this); - this.workspace_ = null; - this.variableMap_ = null; +Blockly.FieldVariable.prototype.toXml = function(fieldElement) { + // Make sure the variable is initialized. + this.initModel(); + + fieldElement.id = this.variable_.getId(); + fieldElement.textContent = this.variable_.name; + if (this.variable_.type) { + fieldElement.setAttribute('variabletype', this.variable_.type); + } + return fieldElement; }; /** @@ -137,6 +171,7 @@ Blockly.FieldVariable.prototype.setSourceBlock = function(block) { throw Error('Variable fields are not allowed to exist on shadow blocks.'); } Blockly.FieldVariable.superClass_.setSourceBlock.call(this, block); + this.workspace_ = block.workspace; }; /** @@ -169,30 +204,57 @@ Blockly.FieldVariable.prototype.getVariable = function() { }; /** - * Set the variable ID. - * @param {string} id New variable ID, which must reference an existing - * variable. + * Gets the validation function for this field, or null if not set. + * Returns null if the variable is not set, because validators should not + * run on the initial setValue call, because the field won't be attached to + * a block and workspace at that point. + * @return {Function} Validation function, or null. */ -Blockly.FieldVariable.prototype.setValue = function(id) { - var workspace = this.sourceBlock_.workspace; - var variable = Blockly.Variables.getVariable(workspace, id); +Blockly.FieldVariable.prototype.getValidator = function() { + // Validators shouldn't operate on the initial setValue call. + // Normally this is achieved by calling setValidator after setValue, but + // this is not a possibility with variable fields. + if (this.variable_) { + return this.validator_; + } + return null; +}; +/** + * Ensure that the id belongs to a valid variable of an allowed type. + * @param {string} newId The id of the new variable to set. + * @return {?string} The validated id, or null if invalid. + * @protected + */ +Blockly.FieldVariable.prototype.doClassValidation_ = function(newId) { + var variable = Blockly.Variables.getVariable(this.workspace_, newId); if (!variable) { - throw Error('Variable id doesn\'t point to a real variable! ID was ' + id); + console.warn('Variable id doesn\'t point to a real variable! ' + + 'ID was ' + newId); + return null; } - // Type checks! + // Type Checks. var type = variable.type; if (!this.typeIsAllowed_(type)) { - throw Error('Variable type doesn\'t match this field! Type was ' + type); - } - if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - var oldValue = this.variable_ ? this.variable_.getId() : null; - Blockly.Events.fire(new Blockly.Events.BlockChange( - this.sourceBlock_, 'field', this.name, oldValue, id)); + console.warn('Variable type doesn\'t match this field! Type was ' + type); + return null; } - this.variable_ = variable; - this.value_ = id; - this.setText(variable.name); + return newId; +}; + +/** + * Update the value of this variable field, as well as its variable and text. + * + * The variable ID should be valid at this point, but if a variable field + * validator returns a bad ID, this could break. + * @param {string} newId The id of the new variable. + * @protected + */ +Blockly.FieldVariable.prototype.doValueUpdate_ = function(newId) { + this.variable_ = Blockly.Variables.getVariable(this.workspace_, newId); + this.value_ = newId; + this.text_ = (this.variable_.name); + this.isDirty_ = true; }; /** @@ -225,9 +287,8 @@ Blockly.FieldVariable.prototype.getVariableTypes_ = function() { var variableTypes = this.variableTypes; if (variableTypes === null) { // If variableTypes is null, return all variable types. - if (this.sourceBlock_) { - var workspace = this.sourceBlock_.workspace; - return workspace.getVariableTypes(); + if (this.workspace_) { + return this.workspace_.getVariableTypes(); } } variableTypes = variableTypes || ['']; @@ -292,18 +353,14 @@ Blockly.FieldVariable.dropdownCreate = function() { ' variable selected.'); } var name = this.getText(); - var workspace = null; - if (this.sourceBlock_) { - workspace = this.sourceBlock_.workspace; - } var variableModelList = []; - if (workspace) { + if (this.workspace_) { var variableTypes = this.getVariableTypes_(); // Get a copy of the list, so that adding rename and new variable options // doesn't modify the workspace's list. for (var i = 0; i < variableTypes.length; i++) { var variableType = variableTypes[i]; - var variables = workspace.getVariablesOfType(variableType); + var variables = this.workspace_.getVariablesOfType(variableType); variableModelList = variableModelList.concat(variables); } } @@ -336,20 +393,19 @@ Blockly.FieldVariable.dropdownCreate = function() { */ Blockly.FieldVariable.prototype.onItemSelected = function(menu, menuItem) { var id = menuItem.getValue(); - if (this.sourceBlock_ && this.sourceBlock_.workspace) { - var workspace = this.sourceBlock_.workspace; + // Handle special cases. + if (this.workspace_) { if (id == Blockly.RENAME_VARIABLE_ID) { // Rename variable. - Blockly.Variables.renameVariable(workspace, this.variable_); + Blockly.Variables.renameVariable(this.workspace_, this.variable_); return; } else if (id == Blockly.DELETE_VARIABLE_ID) { // Delete variable. - workspace.deleteVariableById(this.variable_.getId()); + this.workspace_.deleteVariableById(this.variable_.getId()); return; } - - // TODO (#1529): Call any validation function, and allow it to override. } + // Handle unspecial case. this.setValue(id); }; diff --git a/core/flyout_base.js b/core/flyout_base.js index f1ad80f978a..b92c6bcf832 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -32,13 +32,14 @@ goog.require('Blockly.Events.BlockCreate'); goog.require('Blockly.Events.VarCreate'); goog.require('Blockly.FlyoutButton'); goog.require('Blockly.Gesture'); +goog.require('Blockly.Tooltip'); goog.require('Blockly.Touch'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); goog.require('Blockly.WorkspaceSvg'); goog.require('Blockly.Xml'); -goog.require('goog.math.Rect'); - /** * Class for a flyout. @@ -212,9 +213,9 @@ Blockly.Flyout.prototype.createDom = function(tagName) { */ // Setting style to display:none to start. The toolbox and flyout // hide/show code will set up proper visibility and size later. - this.svgGroup_ = Blockly.utils.createSvgElement(tagName, + this.svgGroup_ = Blockly.utils.dom.createSvgElement(tagName, {'class': 'blocklyFlyout', 'style': 'display: none'}, null); - this.svgBackground_ = Blockly.utils.createSvgElement('path', + this.svgBackground_ = Blockly.utils.dom.createSvgElement('path', {'class': 'blocklyFlyoutBackground'}, this.svgGroup_); this.svgGroup_.appendChild(this.workspace_.createDom()); return this.svgGroup_; @@ -278,7 +279,7 @@ Blockly.Flyout.prototype.dispose = function() { this.workspace_ = null; } if (this.svgGroup_) { - Blockly.utils.removeNode(this.svgGroup_); + Blockly.utils.dom.removeNode(this.svgGroup_); this.svgGroup_ = null; } this.svgBackground_ = null; @@ -375,7 +376,7 @@ Blockly.Flyout.prototype.positionAt_ = function(width, height, x, y) { this.svgGroup_.setAttribute("height", height); if (this.svgGroup_.tagName == 'svg') { var transform = 'translate(' + x + 'px,' + y + 'px)'; - Blockly.utils.setCssTransform(this.svgGroup_, transform); + Blockly.utils.dom.setCssTransform(this.svgGroup_, transform); } else { // IE and Edge don't support CSS transforms on SVG elements so // it's important to set the transform on the SVG element itself @@ -404,7 +405,7 @@ Blockly.Flyout.prototype.hide = function() { } this.setVisible(false); // Delete all the event listeners. - for (var x = 0, listen; listen = this.listeners_[x]; x++) { + for (var i = 0, listen; listen = this.listeners_[i]; i++) { Blockly.unbindEvent_(listen); } this.listeners_.length = 0; @@ -447,27 +448,30 @@ Blockly.Flyout.prototype.show = function(xmlList) { var contents = []; var gaps = []; this.permanentlyDisabled_.length = 0; + var default_gap = this.horizontalLayout_ ? this.GAP_X : this.GAP_Y; for (var i = 0, xml; xml = xmlList[i]; i++) { - if (xml.tagName) { - var tagName = xml.tagName.toUpperCase(); - var default_gap = this.horizontalLayout_ ? this.GAP_X : this.GAP_Y; - if (tagName == 'BLOCK') { + if (!xml.tagName) { + continue; + } + switch (xml.tagName.toUpperCase()) { + case 'BLOCK': var curBlock = Blockly.Xml.domToBlock(xml, this.workspace_); - if (curBlock.disabled) { + if (!curBlock.isEnabled()) { // Record blocks that were initially disabled. // Do not enable these blocks as a result of capacity filtering. this.permanentlyDisabled_.push(curBlock); } contents.push({type: 'block', block: curBlock}); + // This is a deprecated method for adding gap to a block. + // var gap = parseInt(xml.getAttribute('gap'), 10); gaps.push(isNaN(gap) ? default_gap : gap); - } else if (xml.tagName.toUpperCase() == 'SEP') { - // Change the gap between two blocks. + break; + case 'SEP': + // Change the gap between two toolbox elements. // // The default gap is 24, can be set larger or smaller. - // This overwrites the gap attribute on the previous block. - // Note that a deprecated method is to add a gap to a block. - // + // This overwrites the gap attribute on the previous element. var newGap = parseInt(xml.getAttribute('gap'), 10); // Ignore gaps before the first block. if (!isNaN(newGap) && gaps.length > 0) { @@ -475,14 +479,15 @@ Blockly.Flyout.prototype.show = function(xmlList) { } else { gaps.push(default_gap); } - } else if (tagName == 'BUTTON' || tagName == 'LABEL') { - // Labels behave the same as buttons, but are styled differently. - var isLabel = tagName == 'LABEL'; + break; + case 'LABEL': + case 'BUTTON': + var isLabel = xml.tagName.toUpperCase() == 'LABEL'; var curButton = new Blockly.FlyoutButton(this.workspace_, this.targetWorkspace_, xml, isLabel); contents.push({type: 'button', button: curButton}); gaps.push(default_gap); - } + break; } } @@ -533,7 +538,7 @@ Blockly.Flyout.prototype.clearOldBlocks_ = function() { for (var j = 0; j < this.mats_.length; j++) { var rect = this.mats_[j]; if (rect) { - Blockly.utils.removeNode(rect); + Blockly.utils.dom.removeNode(rect); } } this.mats_.length = 0; @@ -603,12 +608,12 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) { * Does this flyout allow you to create a new instance of the given block? * Used for deciding if a block can be "dragged out of" the flyout. * @param {!Blockly.BlockSvg} block The block to copy from the flyout. - * @return {!boolean} True if you can create a new instance of the block, false + * @return {boolean} True if you can create a new instance of the block, false * otherwise. * @package */ Blockly.Flyout.prototype.isBlockCreatable_ = function(block) { - return !block.disabled; + return block.isEnabled(); }; /** @@ -688,7 +693,7 @@ Blockly.Flyout.prototype.initFlyoutButton_ = function(button, x, y) { Blockly.Flyout.prototype.createRect_ = function(block, x, y, blockHW, index) { // Create an invisible rectangle under the block to act as a button. Just // using the block as a button is poor, since blocks have holes in them. - var rect = Blockly.utils.createSvgElement('rect', + var rect = Blockly.utils.dom.createSvgElement('rect', { 'fill-opacity': 0, 'x': x, @@ -744,10 +749,10 @@ Blockly.Flyout.prototype.filterForCapacity_ = function() { var blocks = this.workspace_.getTopBlocks(false); for (var i = 0, block; block = blocks[i]; i++) { if (this.permanentlyDisabled_.indexOf(block) == -1) { - var disable = !this.targetWorkspace_ + var enable = this.targetWorkspace_ .isCapacityAvailable(Blockly.utils.getBlockTypeCounts(block)); while (block) { - block.setDisabled(disable); + block.setEnabled(enable); block = block.getNextBlock(); } } @@ -790,7 +795,7 @@ Blockly.Flyout.prototype.placeNewBlock_ = function(oldBlock) { } // Create the new block by cloning the block in the flyout (via XML). - var xml = Blockly.Xml.blockToDom(oldBlock); + var xml = Blockly.Xml.blockToDom(oldBlock, true); // The target workspace would normally resize during domToBlock, which will // lead to weird jumps. Save it for terminateDrag. targetWorkspace.setResizesEnabled(false); @@ -812,25 +817,23 @@ Blockly.Flyout.prototype.placeNewBlock_ = function(oldBlock) { var flyoutOffsetPixels = this.workspace_.getOriginOffsetInPixels(); // The position of the old block in flyout workspace coordinates. - var oldBlockPosWs = oldBlock.getRelativeToSurfaceXY(); - + var oldBlockPos = oldBlock.getRelativeToSurfaceXY(); // The position of the old block in pixels relative to the flyout // workspace's origin. - var oldBlockPosPixels = oldBlockPosWs.scale(this.workspace_.scale); + oldBlockPos.scale(this.workspace_.scale); // The position of the old block in pixels relative to the upper left corner // of the injection div. - var oldBlockOffsetPixels = goog.math.Coordinate.sum(flyoutOffsetPixels, - oldBlockPosPixels); + var oldBlockOffsetPixels = Blockly.utils.Coordinate.sum(flyoutOffsetPixels, + oldBlockPos); // The position of the old block in pixels relative to the origin of the // main workspace. - var finalOffsetPixels = goog.math.Coordinate.difference(oldBlockOffsetPixels, + var finalOffset = Blockly.utils.Coordinate.difference(oldBlockOffsetPixels, mainOffsetPixels); - // The position of the old block in main workspace coordinates. - var finalOffsetMainWs = finalOffsetPixels.scale(1 / targetWorkspace.scale); + finalOffset.scale(1 / targetWorkspace.scale); - block.moveBy(finalOffsetMainWs.x, finalOffsetMainWs.y); + block.moveBy(finalOffset.x, finalOffset.y); return block; }; diff --git a/core/flyout_button.js b/core/flyout_button.js index 4cd12fab944..6f8985b3109 100644 --- a/core/flyout_button.js +++ b/core/flyout_button.js @@ -27,8 +27,8 @@ goog.provide('Blockly.FlyoutButton'); goog.require('Blockly.utils'); - -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); /** @@ -62,10 +62,10 @@ Blockly.FlyoutButton = function(workspace, targetWorkspace, xml, isLabel) { this.text_ = xml.getAttribute('text'); /** - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @private */ - this.position_ = new goog.math.Coordinate(0, 0); + this.position_ = new Blockly.utils.Coordinate(0, 0); /** * Whether this button should be styled as a label. @@ -123,12 +123,12 @@ Blockly.FlyoutButton.prototype.createDom = function() { cssClass += ' ' + this.cssClass_; } - this.svgGroup_ = Blockly.utils.createSvgElement('g', {'class': cssClass}, + this.svgGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': cssClass}, this.workspace_.getCanvas()); if (!this.isLabel_) { // Shadow rectangle (light source does not mirror in RTL). - var shadow = Blockly.utils.createSvgElement('rect', + var shadow = Blockly.utils.dom.createSvgElement('rect', { 'class': 'blocklyFlyoutButtonShadow', 'rx': 4, 'ry': 4, 'x': 1, 'y': 1 @@ -136,7 +136,7 @@ Blockly.FlyoutButton.prototype.createDom = function() { this.svgGroup_); } // Background rectangle. - var rect = Blockly.utils.createSvgElement('rect', + var rect = Blockly.utils.dom.createSvgElement('rect', { 'class': this.isLabel_ ? 'blocklyFlyoutLabelBackground' : 'blocklyFlyoutButtonBackground', @@ -144,7 +144,7 @@ Blockly.FlyoutButton.prototype.createDom = function() { }, this.svgGroup_); - var svgText = Blockly.utils.createSvgElement('text', + var svgText = Blockly.utils.dom.createSvgElement('text', { 'class': this.isLabel_ ? 'blocklyFlyoutLabelText' : 'blocklyText', 'x': 0, @@ -205,7 +205,7 @@ Blockly.FlyoutButton.prototype.moveTo = function(x, y) { /** * Location of the button. - * @return {!goog.math.Coordinate} x, y coordinates. + * @return {!Blockly.utils.Coordinate} x, y coordinates. * @package */ Blockly.FlyoutButton.prototype.getPosition = function() { @@ -229,7 +229,7 @@ Blockly.FlyoutButton.prototype.dispose = function() { Blockly.unbindEvent_(this.onMouseUpWrapper_); } if (this.svgGroup_) { - Blockly.utils.removeNode(this.svgGroup_); + Blockly.utils.dom.removeNode(this.svgGroup_); this.svgGroup_ = null; } this.workspace_ = null; diff --git a/core/flyout_horizontal.js b/core/flyout_horizontal.js index 33f9eaa1942..adb1f29b502 100644 --- a/core/flyout_horizontal.js +++ b/core/flyout_horizontal.js @@ -27,13 +27,10 @@ goog.provide('Blockly.HorizontalFlyout'); goog.require('Blockly.Block'); -goog.require('Blockly.Events'); -goog.require('Blockly.FlyoutButton'); goog.require('Blockly.Flyout'); -goog.require('Blockly.WorkspaceSvg'); - -goog.require('goog.math.Rect'); -goog.require('goog.userAgent'); +goog.require('Blockly.FlyoutButton'); +goog.require('Blockly.utils'); +goog.require('Blockly.utils.Rect'); /** @@ -315,7 +312,7 @@ Blockly.HorizontalFlyout.prototype.layout_ = function(contents, gaps) { * Determine if a drag delta is toward the workspace, based on the position * and orientation of the flyout. This is used in determineDragIntention_ to * determine if a new block should be created or if the flyout should scroll. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at mouse down, in pixel units. * @return {boolean} True if the drag is toward the workspace. * @package @@ -338,7 +335,7 @@ Blockly.HorizontalFlyout.prototype.isDragTowardWorkspace = function( /** * Return the deletion rectangle for this flyout in viewport coordinates. - * @return {goog.math.Rect} Rectangle in which to delete. + * @return {Blockly.utils.Rect} Rectangle in which to delete. */ Blockly.HorizontalFlyout.prototype.getClientRect = function() { if (!this.svgGroup_) { @@ -350,17 +347,14 @@ Blockly.HorizontalFlyout.prototype.getClientRect = function() { // area are still deleted. Must be larger than the largest screen size, // but be smaller than half Number.MAX_SAFE_INTEGER (not available on IE). var BIG_NUM = 1000000000; - var y = flyoutRect.top; - var height = flyoutRect.height; + var top = flyoutRect.top; if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP) { - return new goog.math.Rect(-BIG_NUM, y - BIG_NUM, BIG_NUM * 2, - BIG_NUM + height); - } else if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_BOTTOM) { - return new goog.math.Rect(-BIG_NUM, y, BIG_NUM * 2, - BIG_NUM + height); + var height = flyoutRect.height; + return new Blockly.utils.Rect(-BIG_NUM, top + height, -BIG_NUM, BIG_NUM); + } else { // Bottom. + return new Blockly.utils.Rect(top, -BIG_NUM, -BIG_NUM, BIG_NUM); } - // TODO: Else throw error (should never happen). }; /** diff --git a/core/flyout_vertical.js b/core/flyout_vertical.js index d88c669f447..fbf2720de67 100644 --- a/core/flyout_vertical.js +++ b/core/flyout_vertical.js @@ -27,13 +27,11 @@ goog.provide('Blockly.VerticalFlyout'); goog.require('Blockly.Block'); -goog.require('Blockly.Events'); goog.require('Blockly.Flyout'); goog.require('Blockly.FlyoutButton'); -goog.require('Blockly.WorkspaceSvg'); - -goog.require('goog.math.Rect'); -goog.require('goog.userAgent'); +goog.require('Blockly.utils'); +goog.require('Blockly.utils.Rect'); +goog.require('Blockly.utils.userAgent'); /** @@ -292,7 +290,7 @@ Blockly.VerticalFlyout.prototype.layout_ = function(contents, gaps) { * Determine if a drag delta is toward the workspace, based on the position * and orientation of the flyout. This is used in determineDragIntention_ to * determine if a new block should be created or if the flyout should scroll. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at mouse down, in pixel units. * @return {boolean} True if the drag is toward the workspace. * @package @@ -315,7 +313,7 @@ Blockly.VerticalFlyout.prototype.isDragTowardWorkspace = function( /** * Return the deletion rectangle for this flyout in viewport coordinates. - * @return {goog.math.Rect} Rectangle in which to delete. + * @return {Blockly.utils.Rect} Rectangle in which to delete. */ Blockly.VerticalFlyout.prototype.getClientRect = function() { if (!this.svgGroup_) { @@ -327,17 +325,16 @@ Blockly.VerticalFlyout.prototype.getClientRect = function() { // area are still deleted. Must be larger than the largest screen size, // but be smaller than half Number.MAX_SAFE_INTEGER (not available on IE). var BIG_NUM = 1000000000; - var x = flyoutRect.left; - var width = flyoutRect.width; + var left = flyoutRect.left; if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_LEFT) { - return new goog.math.Rect(x - BIG_NUM, -BIG_NUM, BIG_NUM + width, - BIG_NUM * 2); + var width = flyoutRect.width; + return new Blockly.utils.Rect(-BIG_NUM, BIG_NUM, -BIG_NUM, left + width); } else { // Right // Firefox sometimes reports the wrong value for the client rect. // See https://github.com/google/blockly/issues/1425 and // https://bugzilla.mozilla.org/show_bug.cgi?id=1066435 - if (goog.userAgent.GECKO && + if (Blockly.utils.userAgent.GECKO && this.targetWorkspace_ && this.targetWorkspace_.isMutator) { // The position of the left side of the mutator workspace in pixels // relative to the window origin. @@ -350,15 +347,15 @@ Blockly.VerticalFlyout.prototype.getClientRect = function() { // visible area of the workspace should be more than ten pixels wide. If // the browser reports that the flyout is within ten pixels of the left // side of the workspace, ignore it and manually calculate the value. - if (Math.abs(targetWsLeftPixels - x) < 10) { + if (Math.abs(targetWsLeftPixels - left) < 10) { // If we're in a mutator, its scale is always 1, purely because of some // oddities in our rendering optimizations. The actual scale is the // same as the scale on the parent workspace. var scale = this.targetWorkspace_.options.parentWorkspace.scale; - x = x + this.leftEdge_ * scale; + left += this.leftEdge_ * scale; } } - return new goog.math.Rect(x, -BIG_NUM, BIG_NUM + width, BIG_NUM * 2); + return new Blockly.utils.Rect(-BIG_NUM, BIG_NUM, left, BIG_NUM); } }; diff --git a/core/generator.js b/core/generator.js index b5a79495901..4241e2440b6 100644 --- a/core/generator.js +++ b/core/generator.js @@ -62,6 +62,14 @@ Blockly.Generator.prototype.INFINITE_LOOP_TRAP = null; */ Blockly.Generator.prototype.STATEMENT_PREFIX = null; +/** + * Arbitrary code to inject after every statement. + * Any instances of '%1' will be replaced by the block ID of the statement. + * E.g. 'highlight(%1);\n' + * @type {?string} + */ +Blockly.Generator.prototype.STATEMENT_SUFFIX = null; + /** * The method of indenting. Defaults to two spaces, but language generators * may override this to increase indent or change to tabs. @@ -96,7 +104,7 @@ Blockly.Generator.prototype.workspaceToCode = function(workspace) { var code = []; this.init(workspace); var blocks = workspace.getTopBlocks(true); - for (var x = 0, block; block = blocks[x]; x++) { + for (var i = 0, block; block = blocks[i]; i++) { var line = this.blockToCode(block); if (Array.isArray(line)) { // Value blocks return tuples of code and operator order. @@ -108,6 +116,12 @@ Blockly.Generator.prototype.workspaceToCode = function(workspace) { // This block is a naked value. Ask the language's code generator if // it wants to append a semicolon, or something. line = this.scrubNakedValue(line); + if (this.STATEMENT_PREFIX && !block.suppressPrefixSuffix) { + line = this.injectId(this.STATEMENT_PREFIX, block) + line; + } + if (this.STATEMENT_SUFFIX && !block.suppressPrefixSuffix) { + line = line + this.injectId(this.STATEMENT_SUFFIX, block); + } } code.push(line); } @@ -126,6 +140,7 @@ Blockly.Generator.prototype.workspaceToCode = function(workspace) { /** * Prepend a common prefix onto each line of code. + * Intended for indenting code or adding comment markers. * @param {string} text The lines of code. * @param {string} prefix The common prefix. * @return {string} The prefixed lines of code. @@ -167,7 +182,7 @@ Blockly.Generator.prototype.blockToCode = function(block, opt_thisOnly) { if (!block) { return ''; } - if (block.disabled) { + if (!block.isEnabled()) { // Skip past this block if it is disabled. return opt_thisOnly ? '' : this.blockToCode(block.getNextBlock()); } @@ -189,9 +204,11 @@ Blockly.Generator.prototype.blockToCode = function(block, opt_thisOnly) { } return [this.scrub_(block, code[0], opt_thisOnly), code[1]]; } else if (typeof code == 'string') { - var id = block.id.replace(/\$/g, '$$$$'); // Issue 251. - if (this.STATEMENT_PREFIX) { - code = this.STATEMENT_PREFIX.replace(/%1/g, '\'' + id + '\'') + code; + if (this.STATEMENT_PREFIX && !block.suppressPrefixSuffix) { + code = this.injectId(this.STATEMENT_PREFIX, block) + code; + } + if (this.STATEMENT_SUFFIX && !block.suppressPrefixSuffix) { + code = code + this.injectId(this.STATEMENT_SUFFIX, block); } return this.scrub_(block, code, opt_thisOnly); } else if (code === null) { @@ -274,7 +291,10 @@ Blockly.Generator.prototype.valueToCode = function(block, name, outerOrder) { }; /** - * Generate code representing the statement. Indent the code. + * Generate a code string representing the blocks attached to the named + * statement input. Indent the code. + * This is mainly used in generators. When trying to generate code to evaluate + * look at using workspaceToCode or blockToCode. * @param {!Blockly.Block} block The block containing the input. * @param {string} name The name of the input. * @return {string} Generated code or '' if no blocks are connected. @@ -296,23 +316,41 @@ Blockly.Generator.prototype.statementToCode = function(block, name) { /** * Add an infinite loop trap to the contents of a loop. - * If loop is empty, add a statment prefix for the loop block. + * Add statement suffix at the start of the loop block (right after the loop + * statement executes), and a statement prefix to the end of the loop block + * (right before the loop statement executes). * @param {string} branch Code for loop contents. - * @param {string} id ID of enclosing block. + * @param {!Blockly.Block} block Enclosing block. * @return {string} Loop contents, with infinite loop trap added. */ -Blockly.Generator.prototype.addLoopTrap = function(branch, id) { - id = id.replace(/\$/g, '$$$$'); // Issue 251. +Blockly.Generator.prototype.addLoopTrap = function(branch, block) { if (this.INFINITE_LOOP_TRAP) { - branch = this.INFINITE_LOOP_TRAP.replace(/%1/g, '\'' + id + '\'') + branch; + branch = this.prefixLines(this.injectId(this.INFINITE_LOOP_TRAP, block), + this.INDENT) + branch; } - if (this.STATEMENT_PREFIX) { - branch += this.prefixLines(this.STATEMENT_PREFIX.replace(/%1/g, - '\'' + id + '\''), this.INDENT); + if (this.STATEMENT_SUFFIX && !block.suppressPrefixSuffix) { + branch = this.prefixLines(this.injectId(this.STATEMENT_SUFFIX, block), + this.INDENT) + branch; + } + if (this.STATEMENT_PREFIX && !block.suppressPrefixSuffix) { + branch = branch + this.prefixLines(this.injectId(this.STATEMENT_PREFIX, + block), this.INDENT); } return branch; }; +/** + * Inject a block ID into a message to replace '%1'. + * Used for STATEMENT_PREFIX, STATEMENT_SUFFIX, and INFINITE_LOOP_TRAP. + * @param {string} msg Code snippet with '%1'. + * @param {!Blockly.Block} block Block which has an ID. + * @return {string} Code snippet with ID. + */ +Blockly.Generator.prototype.injectId = function(msg, block) { + var id = block.id.replace(/\$/g, '$$$$'); // Issue 251. + return msg.replace(/%1/g, '\'' + id + '\''); +}; + /** * Comma-separated list of reserved words. * @type {string} @@ -395,8 +433,8 @@ Blockly.Generator.prototype.init = function(_workspace) { * the block, or to handle comments for the specified block and any connected * value blocks. * @param {!Blockly.Block} _block The current block. - * @param {string} code The JavaScript code created for this block. - * @return {string} JavaScript code with comments and subsequent blocks added. + * @param {string} code The code created for this block. + * @return {string} Code with comments and subsequent blocks added. * @private */ Blockly.Generator.prototype.scrub_ = function(_block, code) { diff --git a/core/gesture.js b/core/gesture.js index 9023b272f46..83ee71767ce 100644 --- a/core/gesture.js +++ b/core/gesture.js @@ -27,19 +27,19 @@ goog.provide('Blockly.Gesture'); -goog.require('Blockly.BlockAnimations'); +goog.require('Blockly.blockAnimations'); goog.require('Blockly.BlockDragger'); goog.require('Blockly.BubbleDragger'); goog.require('Blockly.constants'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.FlyoutDragger'); goog.require('Blockly.Tooltip'); goog.require('Blockly.Touch'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); goog.require('Blockly.WorkspaceDragger'); -goog.require('goog.math.Coordinate'); - /* * Note: In this file "start" refers to touchstart, mousedown, and pointerstart @@ -57,16 +57,16 @@ goog.require('goog.math.Coordinate'); Blockly.Gesture = function(e, creatorWorkspace) { /** - * The position of the mouse when the gesture started. Units are css pixels, + * The position of the mouse when the gesture started. Units are CSS pixels, * with (0, 0) at the top left of the browser window (mouseEvent clientX/Y). - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} */ this.mouseDownXY_ = null; /** * How far the mouse has moved during this drag, in pixel units. * (0, 0) is at this.mouseDownXY_. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @private */ this.currentDragDeltaXY_ = null; @@ -280,7 +280,7 @@ Blockly.Gesture.prototype.dispose = function() { * @private */ Blockly.Gesture.prototype.updateFromEvent_ = function(e) { - var currentXY = new goog.math.Coordinate(e.clientX, e.clientY); + var currentXY = new Blockly.utils.Coordinate(e.clientX, e.clientY); var changed = this.updateDragDelta_(currentXY); // Exceeded the drag radius for the first time. if (changed) { @@ -292,18 +292,18 @@ Blockly.Gesture.prototype.updateFromEvent_ = function(e) { /** * DO MATH to set currentDragDeltaXY_ based on the most recent mouse position. - * @param {!goog.math.Coordinate} currentXY The most recent mouse/pointer + * @param {!Blockly.utils.Coordinate} currentXY The most recent mouse/pointer * position, in pixel units, with (0, 0) at the window's top left corner. * @return {boolean} True if the drag just exceeded the drag radius for the * first time. * @private */ Blockly.Gesture.prototype.updateDragDelta_ = function(currentXY) { - this.currentDragDeltaXY_ = goog.math.Coordinate.difference(currentXY, + this.currentDragDeltaXY_ = Blockly.utils.Coordinate.difference(currentXY, this.mouseDownXY_); if (!this.hasExceededDragRadius_) { - var currentDragDelta = goog.math.Coordinate.magnitude( + var currentDragDelta = Blockly.utils.Coordinate.magnitude( this.currentDragDeltaXY_); // The flyout has a different drag radius from the rest of Blockly. @@ -482,7 +482,7 @@ Blockly.Gesture.prototype.doStart = function(e) { } this.hasStarted_ = true; - Blockly.BlockAnimations.disconnectUiStop(); + Blockly.blockAnimations.disconnectUiStop(); this.startWorkspace_.updateScreenCalculationsIfScrolled(); if (this.startWorkspace_.isMutator) { // Mutator's coordinate system could be out of date because the bubble was @@ -512,7 +512,7 @@ Blockly.Gesture.prototype.doStart = function(e) { Blockly.longStart_(e, this); } - this.mouseDownXY_ = new goog.math.Coordinate(e.clientX, e.clientY); + this.mouseDownXY_ = new Blockly.utils.Coordinate(e.clientX, e.clientY); this.healStack_ = e.altKey || e.ctrlKey || e.metaKey; this.bindMouseEvents(e); @@ -734,7 +734,7 @@ Blockly.Gesture.prototype.doFieldClick_ = function() { Blockly.Gesture.prototype.doBlockClick_ = function() { // Block click in an autoclosing flyout. if (this.flyout_ && this.flyout_.autoClose) { - if (!this.targetBlock_.disabled) { + if (this.targetBlock_.isEnabled()) { if (!Blockly.Events.getGroup()) { Blockly.Events.setGroup(true); } @@ -898,10 +898,10 @@ Blockly.Gesture.prototype.isBlockClick_ = function() { * @private */ Blockly.Gesture.prototype.isFieldClick_ = function() { - var fieldEditable = this.startField_ ? - this.startField_.isCurrentlyEditable() : false; - return fieldEditable && !this.hasExceededDragRadius_ && (!this.flyout_ || - !this.flyout_.autoClose); + var fieldClickable = this.startField_ ? + this.startField_.isClickable() : false; + return fieldClickable && !this.hasExceededDragRadius_ && + (!this.flyout_ || !this.flyout_.autoClose); }; /** diff --git a/core/grid.js b/core/grid.js index ae6a8f9caf7..f8d7bee7437 100644 --- a/core/grid.js +++ b/core/grid.js @@ -27,9 +27,8 @@ goog.provide('Blockly.Grid'); -goog.require('Blockly.utils'); - -goog.require('goog.userAgent'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.userAgent'); /** @@ -187,7 +186,7 @@ Blockly.Grid.prototype.moveTo = function(x, y) { this.gridPattern_.setAttribute('x', x); this.gridPattern_.setAttribute('y', y); - if (goog.userAgent.IE || goog.userAgent.EDGE) { + if (Blockly.utils.userAgent.IE || Blockly.utils.userAgent.EDGE) { // IE/Edge doesn't notice that the x/y offsets have changed. // Force an update. this.update(this.scale_); @@ -209,22 +208,22 @@ Blockly.Grid.createDom = function(rnd, gridOptions, defs) { */ - var gridPattern = Blockly.utils.createSvgElement('pattern', + var gridPattern = Blockly.utils.dom.createSvgElement('pattern', { 'id': 'blocklyGridPattern' + rnd, 'patternUnits': 'userSpaceOnUse' }, defs); if (gridOptions['length'] > 0 && gridOptions['spacing'] > 0) { - Blockly.utils.createSvgElement('line', + Blockly.utils.dom.createSvgElement('line', {'stroke': gridOptions['colour']}, gridPattern); if (gridOptions['length'] > 1) { - Blockly.utils.createSvgElement('line', + Blockly.utils.dom.createSvgElement('line', {'stroke': gridOptions['colour']}, gridPattern); } // x1, y1, x1, x2 properties will be set later in update. } else { // Edge 16 doesn't handle empty patterns - Blockly.utils.createSvgElement('line', {}, gridPattern); + Blockly.utils.dom.createSvgElement('line', {}, gridPattern); } return gridPattern; }; diff --git a/core/icon.js b/core/icon.js index 0d3f2ddd316..73f3df6095e 100644 --- a/core/icon.js +++ b/core/icon.js @@ -27,8 +27,8 @@ goog.provide('Blockly.Icon'); goog.require('Blockly.utils'); - -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); /** @@ -59,7 +59,7 @@ Blockly.Icon.prototype.bubble_ = null; /** * Absolute coordinate of icon's center. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @protected */ Blockly.Icon.prototype.iconXY_ = null; @@ -77,10 +77,10 @@ Blockly.Icon.prototype.createIcon = function() { ... */ - this.iconGroup_ = Blockly.utils.createSvgElement('g', + this.iconGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyIconGroup'}, null); if (this.block_.isInFlyout) { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.iconGroup_), 'blocklyIconGroupReadonly'); } this.drawIcon_(this.iconGroup_); @@ -96,7 +96,7 @@ Blockly.Icon.prototype.createIcon = function() { */ Blockly.Icon.prototype.dispose = function() { // Dispose of and unlink the icon. - Blockly.utils.removeNode(this.iconGroup_); + Blockly.utils.dom.removeNode(this.iconGroup_); this.iconGroup_ = null; // Dispose of and unlink the bubble. this.setVisible(false); @@ -172,7 +172,7 @@ Blockly.Icon.prototype.renderIcon = function(cursorX) { /** * Notification that the icon has moved. Update the arrow accordingly. - * @param {!goog.math.Coordinate} xy Absolute location in workspace coordinates. + * @param {!Blockly.utils.Coordinate} xy Absolute location in workspace coordinates. */ Blockly.Icon.prototype.setIconLocation = function(xy) { this.iconXY_ = xy; @@ -189,17 +189,17 @@ Blockly.Icon.prototype.computeIconLocation = function() { // Find coordinates for the centre of the icon and update the arrow. var blockXY = this.block_.getRelativeToSurfaceXY(); var iconXY = Blockly.utils.getRelativeXY(this.iconGroup_); - var newXY = new goog.math.Coordinate( + var newXY = new Blockly.utils.Coordinate( blockXY.x + iconXY.x + this.SIZE / 2, blockXY.y + iconXY.y + this.SIZE / 2); - if (!goog.math.Coordinate.equals(this.getIconLocation(), newXY)) { + if (!Blockly.utils.Coordinate.equals(this.getIconLocation(), newXY)) { this.setIconLocation(newXY); } }; /** * Returns the center of the block's icon relative to the surface. - * @return {!goog.math.Coordinate} Object with x and y properties in workspace + * @return {!Blockly.utils.Coordinate} Object with x and y properties in workspace * coordinates. */ Blockly.Icon.prototype.getIconLocation = function() { diff --git a/core/inject.js b/core/inject.js index 57d2a13b402..5d4aa5545e9 100644 --- a/core/inject.js +++ b/core/inject.js @@ -29,14 +29,17 @@ goog.provide('Blockly.inject'); goog.require('Blockly.BlockDragSurfaceSvg'); goog.require('Blockly.Css'); goog.require('Blockly.DropDownDiv'); +goog.require('Blockly.Events'); goog.require('Blockly.Grid'); goog.require('Blockly.Options'); +goog.require('Blockly.Tooltip'); goog.require('Blockly.utils'); -goog.require('Blockly.WorkspaceSvg'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.userAgent'); goog.require('Blockly.WorkspaceDragSurfaceSvg'); +goog.require('Blockly.WorkspaceSvg'); goog.require('goog.ui.Component'); -goog.require('goog.userAgent'); /** @@ -54,7 +57,7 @@ Blockly.inject = function(container, opt_options) { document.querySelector(container); } // Verify that the container is in document. - if (!Blockly.utils.containsNode(document, container)) { + if (!Blockly.utils.dom.containsNode(document, container)) { throw Error('Error: container is not in current document.'); } var options = new Blockly.Options(opt_options || {}); @@ -64,7 +67,7 @@ Blockly.inject = function(container, opt_options) { var svg = Blockly.createDom_(subContainer, options); // Create surfaces for dragging things. These are optimizations - // so that the broowser does not repaint during the drag. + // so that the browser does not repaint during the drag. var blockDragSurface = new Blockly.BlockDragSurfaceSvg(subContainer); var workspaceDragSurface = new Blockly.WorkspaceDragSurfaceSvg(subContainer); @@ -109,10 +112,10 @@ Blockly.createDom_ = function(container, options) { ... */ - var svg = Blockly.utils.createSvgElement('svg', { - 'xmlns': 'http://www.w3.org/2000/svg', - 'xmlns:html': 'http://www.w3.org/1999/xhtml', - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + var svg = Blockly.utils.dom.createSvgElement('svg', { + 'xmlns': Blockly.utils.dom.SVG_NS, + 'xmlns:html': Blockly.utils.dom.HTML_NS, + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'class': 'blocklySvg' }, container); @@ -121,7 +124,7 @@ Blockly.createDom_ = function(container, options) { ... filters go here ... */ - var defs = Blockly.utils.createSvgElement('defs', {}, svg); + var defs = Blockly.utils.dom.createSvgElement('defs', {}, svg); // Each filter/pattern needs a unique ID for the case of multiple Blockly // instances on a page. Browser behaviour becomes undefined otherwise. // https://neil.fraser.name/news/2015/11/01/ @@ -140,11 +143,11 @@ Blockly.createDom_ = function(container, options) { k1="0" k2="1" k3="1" k4="0" /> */ - var embossFilter = Blockly.utils.createSvgElement('filter', + var embossFilter = Blockly.utils.dom.createSvgElement('filter', {'id': 'blocklyEmbossFilter' + rnd}, defs); - Blockly.utils.createSvgElement('feGaussianBlur', + Blockly.utils.dom.createSvgElement('feGaussianBlur', {'in': 'SourceAlpha', 'stdDeviation': 1, 'result': 'blur'}, embossFilter); - var feSpecularLighting = Blockly.utils.createSvgElement('feSpecularLighting', + var feSpecularLighting = Blockly.utils.dom.createSvgElement('feSpecularLighting', { 'in': 'blur', 'surfaceScale': 1, @@ -154,16 +157,16 @@ Blockly.createDom_ = function(container, options) { 'result': 'specOut' }, embossFilter); - Blockly.utils.createSvgElement('fePointLight', + Blockly.utils.dom.createSvgElement('fePointLight', {'x': -5000, 'y': -10000, 'z': 20000}, feSpecularLighting); - Blockly.utils.createSvgElement('feComposite', + Blockly.utils.dom.createSvgElement('feComposite', { 'in': 'specOut', 'in2': 'SourceAlpha', 'operator': 'in', 'result': 'specOut' }, embossFilter); - Blockly.utils.createSvgElement('feComposite', + Blockly.utils.dom.createSvgElement('feComposite', { 'in': 'SourceGraphic', 'in2': 'specOut', @@ -181,16 +184,16 @@ Blockly.createDom_ = function(container, options) { */ - var disabledPattern = Blockly.utils.createSvgElement('pattern', + var disabledPattern = Blockly.utils.dom.createSvgElement('pattern', { 'id': 'blocklyDisabledPattern' + rnd, 'patternUnits': 'userSpaceOnUse', 'width': 10, 'height': 10 }, defs); - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', {'width': 10, 'height': 10, 'fill': '#aaa'}, disabledPattern); - Blockly.utils.createSvgElement('path', + Blockly.utils.dom.createSvgElement('path', {'d': 'M 0 0 L 10 10 M 10 0 L 0 10', 'stroke': '#cc0'}, disabledPattern); options.disabledPatternId = disabledPattern.id; @@ -220,7 +223,7 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, if (!options.hasCategories && options.languageTree) { // Add flyout as an that is a sibling of the workspace svg. var flyout = mainWorkspace.addFlyout_('svg'); - Blockly.utils.insertAfter(flyout, svg); + Blockly.utils.dom.insertAfter(flyout, svg); } if (options.hasTrashcan) { mainWorkspace.addTrashcan(); @@ -254,12 +257,10 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, if (mainWorkspace.isContentBounded()) { // Already in workspace units, no need to divide by scale. var blocksBoundingBox = mainWorkspace.getBlocksBoundingBox(); - workspaceMetrics.contentLeft = blocksBoundingBox.x; - workspaceMetrics.contentTop = blocksBoundingBox.y; - workspaceMetrics.contentRight = - blocksBoundingBox.x + blocksBoundingBox.width; - workspaceMetrics.contentBottom = - blocksBoundingBox.y + blocksBoundingBox.height; + workspaceMetrics.contentLeft = blocksBoundingBox.left; + workspaceMetrics.contentTop = blocksBoundingBox.top; + workspaceMetrics.contentRight = blocksBoundingBox.right; + workspaceMetrics.contentBottom = blocksBoundingBox.bottom; } else { workspaceMetrics.contentLeft = defaultMetrics.contentLeft / scale; workspaceMetrics.contentTop = defaultMetrics.contentTop / scale; @@ -294,6 +295,7 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, case Blockly.Events.BLOCK_CREATE: case Blockly.Events.BLOCK_MOVE: var object = mainWorkspace.getBlockById(e.blockId); + object = object.getRootBlock(); break; case Blockly.Events.COMMENT_CREATE: case Blockly.Events.COMMENT_MOVE: @@ -304,25 +306,25 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, var objectMetrics = object.getBoundingRectangle(); // Bump any object that's above the top back inside. - var overflowTop = metrics.viewTop - objectMetrics.topLeft.y; + var overflowTop = metrics.viewTop - objectMetrics.top; if (overflowTop > 0) { object.moveBy(0, overflowTop); } // Bump any object that's below the bottom back inside. - var overflowBottom = metrics.viewBottom - objectMetrics.bottomRight.y; + var overflowBottom = metrics.viewBottom - objectMetrics.bottom; if (overflowBottom < 0) { object.moveBy(0, overflowBottom); } // Bump any object that's off the left back inside. - var overflowLeft = metrics.viewLeft - objectMetrics.topLeft.x; + var overflowLeft = metrics.viewLeft - objectMetrics.left; if (overflowLeft > 0) { object.moveBy(overflowLeft, 0); } // Bump any object that's off the right back inside. - var overflowRight = metrics.viewRight - objectMetrics.bottomRight.x; + var overflowRight = metrics.viewRight - objectMetrics.right; if (overflowRight < 0) { object.moveBy(overflowRight, 0); } @@ -434,7 +436,7 @@ Blockly.inject.bindDocumentEvents_ = function() { Blockly.bindEvent_(document, 'touchend', null, Blockly.longStop_); Blockly.bindEvent_(document, 'touchcancel', null, Blockly.longStop_); // Some iPad versions don't fire resize after portrait to landscape change. - if (goog.userAgent.IPAD) { + if (Blockly.utils.userAgent.IPAD) { Blockly.bindEventWithChecks_(window, 'orientationchange', document, function() { // TODO (#397): Fix for multiple Blockly workspaces. diff --git a/core/input.js b/core/input.js index 74aaf4c959f..5b9c8b17074 100644 --- a/core/input.js +++ b/core/input.js @@ -163,9 +163,10 @@ Blockly.Input.prototype.isVisible = function() { /** * Sets whether this input is visible or not. - * Used to collapse/uncollapse a block. + * Should only be used to collapse/uncollapse a block. * @param {boolean} visible True if visible. * @return {!Array.} List of blocks to render. + * @package */ Blockly.Input.prototype.setVisible = function(visible) { var renderList = []; diff --git a/core/insertion_marker_manager.js b/core/insertion_marker_manager.js index e0572e4a8f9..79b9b216e86 100644 --- a/core/insertion_marker_manager.js +++ b/core/insertion_marker_manager.js @@ -26,12 +26,10 @@ goog.provide('Blockly.InsertionMarkerManager'); -goog.require('Blockly.BlockAnimations'); -goog.require('Blockly.Events.BlockMove'); +goog.require('Blockly.blockAnimations'); +goog.require('Blockly.Events'); goog.require('Blockly.RenderedConnection'); -goog.require('goog.math.Coordinate'); - /** * Class that controls updates to connections during drags. It is primarily @@ -214,7 +212,7 @@ Blockly.InsertionMarkerManager.prototype.applyConnections = function() { // Determine which connection is inferior (lower in the source stack). var inferiorConnection = this.localConnection_.isSuperior() ? this.closestConnection_ : this.localConnection_; - Blockly.BlockAnimations.connectionUiEffect( + Blockly.blockAnimations.connectionUiEffect( inferiorConnection.getSourceBlock()); // Bring the just-edited stack to the front. var rootBlock = this.topBlock_.getRootBlock(); @@ -225,7 +223,7 @@ Blockly.InsertionMarkerManager.prototype.applyConnections = function() { /** * Update highlighted connections based on the most recent move location. - * @param {!goog.math.Coordinate} dxy Position relative to drag start, + * @param {!Blockly.utils.Coordinate} dxy Position relative to drag start, * in workspace units. * @param {?number} deleteArea One of {@link Blockly.DELETE_AREA_TRASH}, * {@link Blockly.DELETE_AREA_TOOLBOX}, or {@link Blockly.DELETE_AREA_NONE}. @@ -264,6 +262,7 @@ Blockly.InsertionMarkerManager.prototype.createMarkerBlock_ = function(sourceBlo try { var result = this.workspace_.newBlock(imType); result.setInsertionMarker(true, sourceBlock.width); + result.setCollapsed(sourceBlock.isCollapsed()); if (sourceBlock.mutationToDom) { var oldMutationDom = sourceBlock.mutationToDom(); if (oldMutationDom) { @@ -319,7 +318,7 @@ Blockly.InsertionMarkerManager.prototype.initAvailableConnections_ = function() * updated based on the closest candidate and the current drag distance. * @param {!Object} candidate An object containing a local connection, a closest * connection, and a radius. Returned by getCandidate_. - * @param {!goog.math.Coordinate} dxy Position relative to drag start, + * @param {!Blockly.utils.Coordinate} dxy Position relative to drag start, * in workspace units. * @return {boolean} Whether the preview should be updated. * @private @@ -364,7 +363,7 @@ Blockly.InsertionMarkerManager.prototype.shouldUpdatePreviews_ = function( /** * Find the nearest valid connection, which may be the same as the current * closest connection. - * @param {!goog.math.Coordinate} dxy Position relative to drag start, + * @param {!Blockly.utils.Coordinate} dxy Position relative to drag start, * in workspace units. * @return {!Object} An object containing a local connection, a closest * connection, and a radius. @@ -660,7 +659,8 @@ Blockly.InsertionMarkerManager.prototype.disconnectMarker_ = function() { } if (imConn.targetConnection) { - throw 'markerConnection_ still connected at the end of disconnectInsertionMarker'; + throw Error('markerConnection_ still connected at the end of ' + + 'disconnectInsertionMarker'); } this.markerConnection_ = null; @@ -679,8 +679,10 @@ Blockly.InsertionMarkerManager.prototype.connectMarker_ = function() { var imBlock = isLastInStack ? this.lastMarker_ : this.firstMarker_; var imConn = imBlock.getMatchingConnection(local.sourceBlock_, local); - goog.asserts.assert(imConn != this.markerConnection_, - 'Made it to connectMarker_ even though the marker isn\'t changing'); + if (imConn == this.markerConnection_) { + throw Error('Made it to connectMarker_ even though the marker isn\'t ' + + 'changing'); + } // Render disconnected from everything else so that we have a valid // connection location. diff --git a/core/mutator.js b/core/mutator.js index b7968e85090..f3aa9df1614 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -28,13 +28,15 @@ goog.provide('Blockly.Mutator'); goog.require('Blockly.Bubble'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.Icon'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.xml'); goog.require('Blockly.WorkspaceSvg'); goog.require('Blockly.Xml'); -goog.require('Blockly.Xml.utils'); /** @@ -68,7 +70,7 @@ Blockly.Mutator.prototype.workspaceHeight_ = 0; */ Blockly.Mutator.prototype.drawIcon_ = function(group) { // Square with rounded corners. - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', { 'class': 'blocklyIconShape', 'rx': '4', @@ -78,7 +80,7 @@ Blockly.Mutator.prototype.drawIcon_ = function(group) { }, group); // Gear teeth. - Blockly.utils.createSvgElement('path', + Blockly.utils.dom.createSvgElement('path', { 'class': 'blocklyIconSymbol', 'd': 'm4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,' + @@ -91,7 +93,7 @@ Blockly.Mutator.prototype.drawIcon_ = function(group) { }, group); // Axle hole. - Blockly.utils.createSvgElement( + Blockly.utils.dom.createSvgElement( 'circle', { 'class': 'blocklyIconShape', @@ -126,14 +128,14 @@ Blockly.Mutator.prototype.createEditor_ = function() { [Workspace] */ - this.svgDialog_ = Blockly.utils.createSvgElement('svg', + this.svgDialog_ = Blockly.utils.dom.createSvgElement('svg', {'x': Blockly.Bubble.BORDER_WIDTH, 'y': Blockly.Bubble.BORDER_WIDTH}, null); // Convert the list of names into a list of XML objects for the flyout. if (this.quarkNames_.length) { - var quarkXml = Blockly.Xml.utils.createElement('xml'); + var quarkXml = Blockly.utils.xml.createElement('xml'); for (var i = 0, quarkName; quarkName = this.quarkNames_[i]; i++) { - var element = Blockly.Xml.utils.createElement('block'); + var element = Blockly.utils.xml.createElement('block'); element.setAttribute('type', quarkName); quarkXml.appendChild(element); } @@ -182,7 +184,7 @@ Blockly.Mutator.prototype.updateEditable = function() { if (!this.block_.isInFlyout) { if (this.block_.isEditable()) { if (this.iconGroup_) { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.iconGroup_), 'blocklyIconGroupReadonly'); } @@ -190,7 +192,7 @@ Blockly.Mutator.prototype.updateEditable = function() { // Close any mutator bubble. Icon is not clickable. this.setVisible(false); if (this.iconGroup_) { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.iconGroup_), 'blocklyIconGroupReadonly'); } @@ -416,7 +418,7 @@ Blockly.Mutator.prototype.dispose = function() { Blockly.Mutator.prototype.updateBlockStyle = function() { var ws = this.workspace_; - if (ws && ws.getAllBlocks()){ + if (ws && ws.getAllBlocks()) { var workspaceBlocks = ws.getAllBlocks(); for (var i = 0; i < workspaceBlocks.length; i++) { var block = workspaceBlocks[i]; @@ -481,10 +483,11 @@ Blockly.Mutator.findParentWs = function(workspace) { }; // Export symbols that would otherwise be renamed by Closure compiler. -if (!goog.global['Blockly']) { - goog.global['Blockly'] = {}; +if (!Blockly.utils.global['Blockly']) { + Blockly.utils.global['Blockly'] = {}; } -if (!goog.global['Blockly']['Mutator']) { - goog.global['Blockly']['Mutator'] = {}; +if (!Blockly.utils.global['Blockly']['Mutator']) { + Blockly.utils.global['Blockly']['Mutator'] = {}; } -goog.global['Blockly']['Mutator']['reconnect'] = Blockly.Mutator.reconnect; +Blockly.utils.global['Blockly']['Mutator']['reconnect'] = + Blockly.Mutator.reconnect; diff --git a/core/options.js b/core/options.js index 9c71541f4bc..d584ae86d8f 100644 --- a/core/options.js +++ b/core/options.js @@ -26,8 +26,9 @@ goog.provide('Blockly.Options'); -goog.require('Blockly.Xml'); goog.require('Blockly.Themes.Classic'); +goog.require('Blockly.utils.userAgent'); +goog.require('Blockly.Xml'); /** @@ -48,7 +49,8 @@ Blockly.Options = function(options) { var hasDisable = false; var hasSounds = false; } else { - var languageTree = Blockly.Options.parseToolboxTree(options['toolbox']); + var languageTree = + Blockly.Options.parseToolboxTree(options['toolbox'] || null); var hasCategories = Boolean(languageTree && languageTree.getElementsByTagName('category').length); var hasTrashcan = options['trashcan']; @@ -164,7 +166,7 @@ Blockly.Options.prototype.getMetrics = null; * Parse the user-specified move options, using reasonable defaults where * behaviour is unspecified. * @param {!Object} options Dictionary of options. - * @param {!boolean} hasCategories Whether the workspace has categories or not. + * @param {boolean} hasCategories Whether the workspace has categories or not. * @return {!Object} A dictionary of normalized options. * @private */ @@ -263,11 +265,11 @@ Blockly.Options.parseGridOptions_ = function(options) { Blockly.Options.parseToolboxTree = function(tree) { if (tree) { if (typeof tree != 'string') { - if (typeof XSLTProcessor == 'undefined' && tree.outerHTML) { + if (Blockly.utils.userAgent.IE && tree.outerHTML) { // In this case the tree will not have been properly built by the // browser. The HTML will be contained in the element, but it will // not have the proper DOM structure since the browser doesn't support - // XSLTProcessor (XML -> HTML). This is the case in IE 9+. + // XSLTProcessor (XML -> HTML). tree = tree.outerHTML; } else if (!(tree instanceof Element)) { tree = null; @@ -275,6 +277,9 @@ Blockly.Options.parseToolboxTree = function(tree) { } if (typeof tree == 'string') { tree = Blockly.Xml.textToDom(tree); + if (tree.nodeName.toLowerCase() != 'xml') { + throw TypeError('Toolbox should be an document.'); + } } } else { tree = null; diff --git a/core/procedures.js b/core/procedures.js index cc84a490242..d69fbbd4d1c 100644 --- a/core/procedures.js +++ b/core/procedures.js @@ -32,12 +32,14 @@ goog.provide('Blockly.Procedures'); goog.require('Blockly.Blocks'); goog.require('Blockly.constants'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Field'); +goog.require('Blockly.Msg'); goog.require('Blockly.Names'); +goog.require('Blockly.utils.xml'); goog.require('Blockly.Workspace'); goog.require('Blockly.Xml'); -goog.require('Blockly.Xml.utils'); /** @@ -158,14 +160,14 @@ Blockly.Procedures.isNameUsed = function(name, workspace, opt_exclude) { */ Blockly.Procedures.rename = function(name) { // Strip leading and trailing whitespace. Beyond this, all names are legal. - name = name.replace(/^[\s\xa0]+|[\s\xa0]+$/g, ''); + name = name.trim(); // Ensure two identically-named procedures don't exist. - var legalName = Blockly.Procedures.findLegalName(name, this.sourceBlock_); - var oldName = this.text_; + var legalName = Blockly.Procedures.findLegalName(name, this.getSourceBlock()); + var oldName = this.getValue(); if (oldName != name && oldName != legalName) { // Rename any callers. - var blocks = this.sourceBlock_.workspace.getAllBlocks(false); + var blocks = this.getSourceBlock().workspace.getAllBlocks(false); for (var i = 0; i < blocks.length; i++) { if (blocks[i].renameProcedure) { blocks[i].renameProcedure(oldName, legalName); @@ -186,12 +188,12 @@ Blockly.Procedures.flyoutCategory = function(workspace) { // // do something // - var block = Blockly.Xml.utils.createElement('block'); + var block = Blockly.utils.xml.createElement('block'); block.setAttribute('type', 'procedures_defnoreturn'); block.setAttribute('gap', 16); - var nameField = Blockly.Xml.utils.createElement('field'); + var nameField = Blockly.utils.xml.createElement('field'); nameField.setAttribute('name', 'NAME'); - nameField.appendChild(Blockly.Xml.utils.createTextNode( + nameField.appendChild(Blockly.utils.xml.createTextNode( Blockly.Msg['PROCEDURES_DEFNORETURN_PROCEDURE'])); block.appendChild(nameField); xmlList.push(block); @@ -200,19 +202,19 @@ Blockly.Procedures.flyoutCategory = function(workspace) { // // do something // - var block = Blockly.Xml.utils.createElement('block'); + var block = Blockly.utils.xml.createElement('block'); block.setAttribute('type', 'procedures_defreturn'); block.setAttribute('gap', 16); - var nameField = Blockly.Xml.utils.createElement('field'); + var nameField = Blockly.utils.xml.createElement('field'); nameField.setAttribute('name', 'NAME'); - nameField.appendChild(Blockly.Xml.utils.createTextNode( + nameField.appendChild(Blockly.utils.xml.createTextNode( Blockly.Msg['PROCEDURES_DEFRETURN_PROCEDURE'])); block.appendChild(nameField); xmlList.push(block); } if (Blockly.Blocks['procedures_ifreturn']) { // - var block = Blockly.Xml.utils.createElement('block'); + var block = Blockly.utils.xml.createElement('block'); block.setAttribute('type', 'procedures_ifreturn'); block.setAttribute('gap', 16); xmlList.push(block); @@ -231,14 +233,14 @@ Blockly.Procedures.flyoutCategory = function(workspace) { // // // - var block = Blockly.Xml.utils.createElement('block'); + var block = Blockly.utils.xml.createElement('block'); block.setAttribute('type', templateName); block.setAttribute('gap', 16); - var mutation = Blockly.Xml.utils.createElement('mutation'); + var mutation = Blockly.utils.xml.createElement('mutation'); mutation.setAttribute('name', name); block.appendChild(mutation); for (var j = 0; j < args.length; j++) { - var arg = Blockly.Xml.utils.createElement('arg'); + var arg = Blockly.utils.xml.createElement('arg'); arg.setAttribute('name', args[j]); mutation.appendChild(arg); } diff --git a/core/rendered_connection.js b/core/rendered_connection.js index b4bebbbbb26..b9ab29a1612 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -27,9 +27,10 @@ goog.provide('Blockly.RenderedConnection'); goog.require('Blockly.Connection'); +goog.require('Blockly.Events'); goog.require('Blockly.utils'); - -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); /** @@ -44,10 +45,10 @@ Blockly.RenderedConnection = function(source, type) { /** * Workspace units, (0, 0) is top left of block. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @private */ - this.offsetInBlock_ = new goog.math.Coordinate(0, 0); + this.offsetInBlock_ = new Blockly.utils.Coordinate(0, 0); }; goog.inherits(Blockly.RenderedConnection, Blockly.Connection); @@ -143,7 +144,7 @@ Blockly.RenderedConnection.prototype.moveBy = function(dx, dy) { /** * Move this connection to the location given by its offset within the block and * the location of the block's top left corner. - * @param {!goog.math.Coordinate} blockTL The location of the top left corner + * @param {!Blockly.utils.Coordinate} blockTL The location of the top left corner * of the block, in workspace coordinates. */ Blockly.RenderedConnection.prototype.moveToOffset = function(blockTL) { @@ -186,7 +187,7 @@ Blockly.RenderedConnection.prototype.tighten_ = function() { * Find the closest compatible connection to this connection. * All parameters are in workspace units. * @param {number} maxLimit The maximum radius to another connection. - * @param {!goog.math.Coordinate} dxy Offset between this connection's location + * @param {!Blockly.utils.Coordinate} dxy Offset between this connection's location * in the database and the current location (as a result of dragging). * @return {!{connection: ?Blockly.Connection, radius: number}} Contains two * properties: 'connection' which is either another connection or null, @@ -209,7 +210,7 @@ Blockly.RenderedConnection.prototype.highlight = function() { var xy = this.sourceBlock_.getRelativeToSurfaceXY(); var x = this.x_ - xy.x; var y = this.y_ - xy.y; - Blockly.Connection.highlightedPath_ = Blockly.utils.createSvgElement( + Blockly.Connection.highlightedPath_ = Blockly.utils.dom.createSvgElement( 'path', { 'class': 'blocklyHighlightedConnectionPath', @@ -265,7 +266,7 @@ Blockly.RenderedConnection.prototype.unhideAll = function() { * Remove the highlighting around this connection. */ Blockly.RenderedConnection.prototype.unhighlight = function() { - Blockly.utils.removeNode(Blockly.Connection.highlightedPath_); + Blockly.utils.dom.removeNode(Blockly.Connection.highlightedPath_); delete Blockly.Connection.highlightedPath_; }; diff --git a/core/scrollbar.js b/core/scrollbar.js index 116d6df67df..7ea608a9bee 100644 --- a/core/scrollbar.js +++ b/core/scrollbar.js @@ -27,10 +27,10 @@ goog.provide('Blockly.Scrollbar'); goog.provide('Blockly.ScrollbarPair'); +goog.require('Blockly.Touch'); goog.require('Blockly.utils'); - -goog.require('goog.events.BrowserFeature'); -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); /** @@ -49,7 +49,7 @@ Blockly.ScrollbarPair = function(workspace) { workspace, true, true, 'blocklyMainWorkspaceScrollbar'); this.vScroll = new Blockly.Scrollbar( workspace, false, true, 'blocklyMainWorkspaceScrollbar'); - this.corner_ = Blockly.utils.createSvgElement( + this.corner_ = Blockly.utils.dom.createSvgElement( 'rect', { 'height': Blockly.Scrollbar.scrollbarThickness, @@ -57,7 +57,7 @@ Blockly.ScrollbarPair = function(workspace) { 'class': 'blocklyScrollbarBackground' }, null); - Blockly.utils.insertAfter(this.corner_, workspace.getBubbleCanvas()); + Blockly.utils.dom.insertAfter(this.corner_, workspace.getBubbleCanvas()); }; /** @@ -72,7 +72,7 @@ Blockly.ScrollbarPair.prototype.oldHostMetrics_ = null; * Unlink from all DOM elements to prevent memory leaks. */ Blockly.ScrollbarPair.prototype.dispose = function() { - Blockly.utils.removeNode(this.corner_); + Blockly.utils.dom.removeNode(this.corner_); this.corner_ = null; this.workspace_ = null; this.oldHostMetrics_ = null; @@ -211,10 +211,10 @@ Blockly.Scrollbar = function(workspace, horizontal, opt_pair, opt_class) { * The upper left corner of the scrollbar's SVG group in CSS pixels relative * to the scrollbar's origin. This is usually relative to the injection div * origin. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @private */ - this.position_ = new goog.math.Coordinate(0, 0); + this.position_ = new Blockly.utils.Coordinate(0, 0); // Store the thickness in a temp variable for readability. var scrollbarThickness = Blockly.Scrollbar.scrollbarThickness; @@ -246,10 +246,10 @@ Blockly.Scrollbar = function(workspace, horizontal, opt_pair, opt_class) { * The location of the origin of the workspace that the scrollbar is in, * measured in CSS pixels relative to the injection div origin. This is usually * (0, 0). When the scrollbar is in a flyout it may have a different origin. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @private */ -Blockly.Scrollbar.prototype.origin_ = new goog.math.Coordinate(0, 0); +Blockly.Scrollbar.prototype.origin_ = new Blockly.utils.Coordinate(0, 0); /** * The position of the mouse along this scrollbar's major axis at the start of @@ -257,7 +257,7 @@ Blockly.Scrollbar.prototype.origin_ = new goog.math.Coordinate(0, 0); * Units are CSS pixels, with (0, 0) at the top left of the browser window. * For a horizontal scrollbar this is the x coordinate of the mouse down event; * for a vertical scrollbar it's the y coordinate of the mouse down event. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} */ Blockly.Scrollbar.prototype.startDragMouse_ = 0; @@ -303,7 +303,7 @@ Blockly.Scrollbar.prototype.containerVisible_ = true; * Scrollbars should be larger on touch devices. */ Blockly.Scrollbar.scrollbarThickness = 15; -if (goog.events.BrowserFeature.TOUCH_ENABLED) { +if (Blockly.Touch.TOUCH_ENABLED) { Blockly.Scrollbar.scrollbarThickness = 25; } @@ -347,7 +347,7 @@ Blockly.Scrollbar.prototype.dispose = function() { Blockly.unbindEvent_(this.onMouseDownHandleWrapper_); this.onMouseDownHandleWrapper_ = null; - Blockly.utils.removeNode(this.outerSvg_); + Blockly.utils.dom.removeNode(this.outerSvg_); this.outerSvg_ = null; this.svgGroup_ = null; this.svgBackground_ = null; @@ -410,7 +410,7 @@ Blockly.Scrollbar.prototype.setPosition_ = function(x, y) { var tempX = this.position_.x + this.origin_.x; var tempY = this.position_.y + this.origin_.y; var transform = 'translate(' + tempX + 'px,' + tempY + 'px)'; - Blockly.utils.setCssTransform(this.outerSvg_, transform); + Blockly.utils.dom.setCssTransform(this.outerSvg_, transform); }; /** @@ -611,13 +611,13 @@ Blockly.Scrollbar.prototype.createDom_ = function(opt_class) { if (opt_class) { className += ' ' + opt_class; } - this.outerSvg_ = Blockly.utils.createSvgElement( + this.outerSvg_ = Blockly.utils.dom.createSvgElement( 'svg', {'class': className}, null); - this.svgGroup_ = Blockly.utils.createSvgElement('g', {}, this.outerSvg_); - this.svgBackground_ = Blockly.utils.createSvgElement( + this.svgGroup_ = Blockly.utils.dom.createSvgElement('g', {}, this.outerSvg_); + this.svgBackground_ = Blockly.utils.dom.createSvgElement( 'rect', {'class': 'blocklyScrollbarBackground'}, this.svgGroup_); var radius = Math.floor((Blockly.Scrollbar.scrollbarThickness - 5) / 2); - this.svgHandle_ = Blockly.utils.createSvgElement( + this.svgHandle_ = Blockly.utils.dom.createSvgElement( 'rect', { 'class': 'blocklyScrollbarHandle', @@ -625,7 +625,7 @@ Blockly.Scrollbar.prototype.createDom_ = function(opt_class) { 'ry': radius }, this.svgGroup_); - Blockly.utils.insertAfter(this.outerSvg_, this.workspace_.getParentSvg()); + Blockly.utils.dom.insertAfter(this.outerSvg_, this.workspace_.getParentSvg()); }; /** @@ -860,5 +860,5 @@ Blockly.Scrollbar.prototype.set = function(value) { * @param {number} y The y coordinate of the scrollbar's origin, in CSS pixels. */ Blockly.Scrollbar.prototype.setOrigin = function(x, y) { - this.origin_ = new goog.math.Coordinate(x, y); + this.origin_ = new Blockly.utils.Coordinate(x, y); }; diff --git a/core/theme.js b/core/theme.js index 1149ebd19ac..cda37fd5ba7 100644 --- a/core/theme.js +++ b/core/theme.js @@ -24,11 +24,19 @@ 'use strict'; goog.provide('Blockly.Theme'); + + +/** + * A block style or a category style. + * @typedef {!Object.} + */ +Blockly.Theme.Style; + /** * Class for a theme. - * @param {Object.} blockStyles A map from style + * @param {!Object.} blockStyles A map from style * names (strings) to objects with style attributes relating to blocks. - * @param {Object.} categoryStyles A map from + * @param {!Object.} categoryStyles A map from * style names (strings) to objects with style attributes relating to * categories. * @constructor @@ -40,8 +48,8 @@ Blockly.Theme = function(blockStyles, categoryStyles) { /** * Overrides or adds all values from blockStyles to blockStyles_ - * @param {Object.} blockStyles List of - * block styles. + * @param {Object.} blockStyles Map of + * block styles. */ Blockly.Theme.prototype.setAllBlockStyles = function(blockStyles) { for (var key in blockStyles) { @@ -50,8 +58,8 @@ Blockly.Theme.prototype.setAllBlockStyles = function(blockStyles) { }; /** - * Gets a list of all the block style names. - * @return {Array.} List of blockstyle names. + * Gets a map of all the block style names. + * @return {!Object.} Map of block styles. */ Blockly.Theme.prototype.getAllBlockStyles = function() { return this.blockStyles_; @@ -60,7 +68,7 @@ Blockly.Theme.prototype.getAllBlockStyles = function() { /** * Gets the BlockStyle for the given block style name. * @param {string} blockStyleName The name of the block style. - * @return {Blockly.BlockStyle} The style with the block style name. + * @return {Blockly.Theme.Style|undefined} The named block style. */ Blockly.Theme.prototype.getBlockStyle = function(blockStyleName) { return this.blockStyles_[blockStyleName]; @@ -69,7 +77,7 @@ Blockly.Theme.prototype.getBlockStyle = function(blockStyleName) { /** * Overrides or adds a style to the blockStyles map. * @param {string} blockStyleName The name of the block style. - * @param {Blockly.BlockStyle} blockStyle The block style + * @param {Blockly.Theme.Style} blockStyle The block style. */ Blockly.Theme.prototype.setBlockStyle = function(blockStyleName, blockStyle) { this.blockStyles_[blockStyleName] = blockStyle; @@ -77,8 +85,8 @@ Blockly.Theme.prototype.setBlockStyle = function(blockStyleName, blockStyle) { /** * Gets the CategoryStyle for the given category style name. - * @param {string} categoryStyleName The name of the block style. - * @return {Blockly.CategoryStyle} The style with the block style name. + * @param {string} categoryStyleName The name of the category style. + * @return {Blockly.Theme.Style|undefined} The named category style. */ Blockly.Theme.prototype.getCategoryStyle = function(categoryStyleName) { return this.categoryStyles_[categoryStyleName]; @@ -87,8 +95,9 @@ Blockly.Theme.prototype.getCategoryStyle = function(categoryStyleName) { /** * Overrides or adds a style to the categoryStyles map. * @param {string} categoryStyleName The name of the category style. - * @param {Blockly.CategoryStyle} categoryStyle The category style + * @param {Blockly.Theme.Style} categoryStyle The category style. */ -Blockly.Theme.prototype.setCategoryStyle = function(categoryStyleName, categoryStyle) { +Blockly.Theme.prototype.setCategoryStyle = function(categoryStyleName, + categoryStyle) { this.categoryStyles_[categoryStyleName] = categoryStyle; }; diff --git a/core/theme/classic.js b/core/theme/classic.js index 522e444409c..ad46626ce7a 100644 --- a/core/theme/classic.js +++ b/core/theme/classic.js @@ -20,17 +20,20 @@ /** * @fileoverview Classic theme. - * Contains multi colored border to create shadow effect. + * Contains multi-coloured border to create shadow effect. */ - 'use strict'; goog.provide('Blockly.Themes.Classic'); goog.require('Blockly.Theme'); -var defaultBlockStyles = { - "colour_blocks":{ + +// Temporary holding object. +Blockly.Themes.Classic = {}; + +Blockly.Themes.Classic.defaultBlockStyles = { + "colour_blocks": { "colourPrimary": "20" }, "list_blocks": { @@ -54,17 +57,17 @@ var defaultBlockStyles = { "variable_blocks": { "colourPrimary": "330" }, - "variable_dynamic_blocks":{ + "variable_dynamic_blocks": { "colourPrimary": "310" }, - "hat_blocks":{ - "colourPrimary":"330", - "hat":"cap" + "hat_blocks": { + "colourPrimary": "330", + "hat": "cap" } }; -var categoryStyles = { - "colour_category":{ +Blockly.Themes.Classic.categoryStyles = { + "colour_category": { "colour": "20" }, "list_category": { @@ -88,9 +91,11 @@ var categoryStyles = { "variable_category": { "colour": "330" }, - "variable_dynamic_category":{ + "variable_dynamic_category": { "colour": "310" } }; -Blockly.Themes.Classic = new Blockly.Theme(defaultBlockStyles, categoryStyles); +Blockly.Themes.Classic = + new Blockly.Theme(Blockly.Themes.Classic.defaultBlockStyles, + Blockly.Themes.Classic.categoryStyles); diff --git a/core/theme/highcontrast.js b/core/theme/highcontrast.js index 93c88ecf95c..f2737e19cd6 100644 --- a/core/theme/highcontrast.js +++ b/core/theme/highcontrast.js @@ -20,7 +20,7 @@ /** * @fileoverview High contrast theme. - * Darker colors to contrast the white font. + * Darker colours to contrast the white font. */ 'use strict'; @@ -28,89 +28,95 @@ goog.provide('Blockly.Themes.HighContrast'); goog.require('Blockly.Theme'); -var defaultBlockStyles = { - "colour_blocks":{ + +// Temporary holding object. +Blockly.Themes.HighContrast = {}; + +Blockly.Themes.HighContrast.defaultBlockStyles = { + "colour_blocks": { "colourPrimary": "#a52714", - "colourSecondary":"#FB9B8C", - "colourTertiary":"#FBE1DD" + "colourSecondary": "#FB9B8C", + "colourTertiary": "#FBE1DD" }, "list_blocks": { "colourPrimary": "#4a148c", - "colourSecondary":"#AD7BE9", - "colourTertiary":"#CDB6E9" + "colourSecondary": "#AD7BE9", + "colourTertiary": "#CDB6E9" }, "logic_blocks": { "colourPrimary": "#01579b", - "colourSecondary":"#64C7FF", - "colourTertiary":"#C5EAFF" + "colourSecondary": "#64C7FF", + "colourTertiary": "#C5EAFF" }, "loop_blocks": { "colourPrimary": "#33691e", - "colourSecondary":"#9AFF78", - "colourTertiary":"#E1FFD7" + "colourSecondary": "#9AFF78", + "colourTertiary": "#E1FFD7" }, "math_blocks": { "colourPrimary": "#1a237e", - "colourSecondary":"#8A9EFF", - "colourTertiary":"#DCE2FF" + "colourSecondary": "#8A9EFF", + "colourTertiary": "#DCE2FF" }, "procedure_blocks": { "colourPrimary": "#006064", - "colourSecondary":"#77E6EE", - "colourTertiary":"#CFECEE" + "colourSecondary": "#77E6EE", + "colourTertiary": "#CFECEE" }, "text_blocks": { "colourPrimary": "#004d40", - "colourSecondary":"#5ae27c", - "colourTertiary":"#D2FFDD" + "colourSecondary": "#5ae27c", + "colourTertiary": "#D2FFDD" }, "variable_blocks": { "colourPrimary": "#880e4f", - "colourSecondary":"#FF73BE", - "colourTertiary":"#FFD4EB" + "colourSecondary": "#FF73BE", + "colourTertiary": "#FFD4EB" }, "variable_dynamic_blocks": { "colourPrimary": "#880e4f", - "colourSecondary":"#FF73BE", - "colourTertiary":"#FFD4EB" + "colourSecondary": "#FF73BE", + "colourTertiary": "#FFD4EB" }, - "hat_blocks" : { + "hat_blocks": { "colourPrimary": "#880e4f", - "colourSecondary":"#FF73BE", - "colourTertiary":"#FFD4EB", + "colourSecondary": "#FF73BE", + "colourTertiary": "#FFD4EB", "hat": "cap" } }; -var categoryStyles = { - "colour_category":{ - "colour": "#a52714", +Blockly.Themes.HighContrast.categoryStyles = { + "colour_category": { + "colour": "#a52714" }, "list_category": { - "colour": "#4a148c", + "colour": "#4a148c" }, "logic_category": { - "colour": "#01579b", + "colour": "#01579b" }, "loop_category": { - "colour": "#33691e", + "colour": "#33691e" }, "math_category": { - "colour": "#1a237e", + "colour": "#1a237e" }, "procedure_category": { - "colour": "#006064", + "colour": "#006064" }, "text_category": { - "colour": "#004d40", + "colour": "#004d40" }, "variable_category": { - "colour": "#880e4f", + "colour": "#880e4f" }, - "variable_dynamic_category":{ - "colour": "#880e4f", + "variable_dynamic_category": { + "colour": "#880e4f" } }; -//This style is still being fleshed out and may change. -Blockly.Themes.HighContrast = new Blockly.Theme(defaultBlockStyles, categoryStyles); +// This style is still being fleshed out and may change. +Blockly.Themes.HighContrast = + new Blockly.Theme(Blockly.Themes.HighContrast.defaultBlockStyles, + Blockly.Themes.HighContrast.categoryStyles); diff --git a/core/theme/modern.js b/core/theme/modern.js index d7e06cf1a79..b6fbd49df54 100644 --- a/core/theme/modern.js +++ b/core/theme/modern.js @@ -20,7 +20,7 @@ /** * @fileoverview Modern theme. - * Same colors as classic, but single colored border. + * Same colours as classic, but single coloured border. */ 'use strict'; @@ -28,7 +28,11 @@ goog.provide('Blockly.Themes.Modern'); goog.require('Blockly.Theme'); -var defaultBlockStyles = { + +// Temporary holding object. +Blockly.Themes.Modern = {}; + +Blockly.Themes.Modern.defaultBlockStyles = { "colour_blocks": { "colourPrimary": "#a5745b", "colourSecondary": "#dbc7bd", @@ -82,35 +86,37 @@ var defaultBlockStyles = { } }; -var categoryStyles = { - "colour_category":{ - "colour": "#a5745b", +Blockly.Themes.Modern.categoryStyles = { + "colour_category": { + "colour": "#a5745b" }, "list_category": { - "colour": "#745ba5", + "colour": "#745ba5" }, "logic_category": { - "colour": "#5b80a5", + "colour": "#5b80a5" }, "loop_category": { - "colour": "#5ba55b", + "colour": "#5ba55b" }, "math_category": { - "colour": "#5b67a5", + "colour": "#5b67a5" }, "procedure_category": { - "colour": "#995ba5", + "colour": "#995ba5" }, "text_category": { - "colour": "#5ba58c", + "colour": "#5ba58c" }, "variable_category": { - "colour": "#a55b99", + "colour": "#a55b99" }, - "variable_dynamic_category":{ - "colour": "#a55b99", + "variable_dynamic_category": { + "colour": "#a55b99" } }; -//This style is still being fleshed out and may change. -Blockly.Themes.Modern = new Blockly.Theme(defaultBlockStyles, categoryStyles); +// This style is still being fleshed out and may change. +Blockly.Themes.Modern = + new Blockly.Theme(Blockly.Themes.Modern.defaultBlockStyles, + Blockly.Themes.Modern.categoryStyles); diff --git a/core/toolbox.js b/core/toolbox.js index 82d852e3947..d0619276d87 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -26,19 +26,21 @@ goog.provide('Blockly.Toolbox'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.Flyout'); goog.require('Blockly.HorizontalFlyout'); goog.require('Blockly.Touch'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.colour'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.Rect'); goog.require('Blockly.VerticalFlyout'); goog.require('goog.events'); -goog.require('goog.events.BrowserFeature'); +goog.require('goog.events.EventType'); goog.require('goog.html.SafeHtml'); -goog.require('goog.html.SafeStyle'); -goog.require('goog.math.Rect'); -goog.require('goog.style'); +goog.require('goog.ui.tree.BaseNode'); goog.require('goog.ui.tree.TreeControl'); goog.require('goog.ui.tree.TreeNode'); @@ -191,7 +193,7 @@ Blockly.Toolbox.prototype.init = function() { this.flyout_ = new Blockly.VerticalFlyout(workspaceOptions); } // Insert the flyout after the workspace. - Blockly.utils.insertAfter(this.flyout_.createDom('svg'), + Blockly.utils.dom.insertAfter(this.flyout_.createDom('svg'), this.workspace_.getParentSvg()); this.flyout_.init(workspace); @@ -219,7 +221,7 @@ Blockly.Toolbox.prototype.init = function() { Blockly.Toolbox.prototype.dispose = function() { this.flyout_.dispose(); this.tree_.dispose(); - Blockly.utils.removeNode(this.HtmlDiv); + Blockly.utils.dom.removeNode(this.HtmlDiv); this.workspace_ = null; this.lastCategory_ = null; }; @@ -359,25 +361,14 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) { lastElement = childIn; break; case 'SEP': - if (lastElement) { - if (lastElement.tagName.toUpperCase() == 'CATEGORY') { - // Separator between two categories. - // - treeOut.add(new Blockly.Toolbox.TreeSeparator( - this.treeSeparatorConfig_)); - } else { - // Change the gap between two blocks. - // - // The default gap is 24, can be set larger or smaller. - // Note that a deprecated method is to add a gap to a block. - // - var newGap = parseFloat(childIn.getAttribute('gap')); - if (!isNaN(newGap) && lastElement) { - lastElement.setAttribute('gap', newGap); - } - } + if (lastElement && lastElement.tagName.toUpperCase() == 'CATEGORY') { + // Separator between two categories. + // + treeOut.add(new Blockly.Toolbox.TreeSeparator( + this.treeSeparatorConfig_)); + break; } - break; + // Otherwise falls through. case 'BLOCK': case 'SHADOW': case 'LABEL': @@ -398,24 +389,30 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) { * @param {string} categoryName Name of the toolbox category. * @private */ -Blockly.Toolbox.prototype.setColour_ = function(colourValue, childOut, categoryName){ +Blockly.Toolbox.prototype.setColour_ = function(colourValue, childOut, + categoryName) { // Decode the colour for any potential message references // (eg. `%{BKY_MATH_HUE}`). var colour = Blockly.utils.replaceMessageReferences(colourValue); if (colour === null || colour === '') { // No attribute. No colour. childOut.hexColour = ''; - } else if (/^#[0-9a-fA-F]{6}$/.test(colour)) { - childOut.hexColour = colour; - this.hasColours_ = true; - } else if (typeof colour === 'number' || - (typeof colour === 'string' && !isNaN(Number(colour)))) { - childOut.hexColour = Blockly.hueToRgb(Number(colour)); - this.hasColours_ = true; } else { - childOut.hexColour = ''; - console.warn('Toolbox category "' + categoryName + - '" has unrecognized colour attribute: ' + colour); + var hue = Number(colour); + if (!isNaN(hue)) { + childOut.hexColour = Blockly.hueToHex(hue); + this.hasColours_ = true; + } else { + var hex = Blockly.utils.colour.parse(colour); + if (hex) { + childOut.hexColour = hex; + this.hasColours_ = true; + } else { + childOut.hexColour = ''; + console.warn('Toolbox category "' + categoryName + + '" has unrecognized colour attribute: ' + colour); + } + } } }; @@ -427,14 +424,15 @@ Blockly.Toolbox.prototype.setColour_ = function(colourValue, childOut, categoryN * @param {string} categoryName Name of the toolbox category. */ Blockly.Toolbox.prototype.setColourFromStyle_ = function( - styleName, childOut, categoryName){ + styleName, childOut, categoryName) { childOut.styleName = styleName; if (styleName && Blockly.getTheme()) { var style = Blockly.getTheme().getCategoryStyle(styleName); if (style && style.colour) { this.setColour_(style.colour, childOut, categoryName); } else { - console.warn('Style "' + styleName + '" must exist and contain a colour value'); + console.warn('Style "' + styleName + + '" must exist and contain a colour value'); } } }; @@ -526,7 +524,7 @@ Blockly.Toolbox.prototype.clearSelection = function() { * @package */ Blockly.Toolbox.prototype.addStyle = function(style) { - Blockly.utils.addClass(/** @type {!Element} */ (this.HtmlDiv), style); + Blockly.utils.dom.addClass(/** @type {!Element} */ (this.HtmlDiv), style); }; /** @@ -535,12 +533,12 @@ Blockly.Toolbox.prototype.addStyle = function(style) { * @package */ Blockly.Toolbox.prototype.removeStyle = function(style) { - Blockly.utils.removeClass(/** @type {!Element} */ (this.HtmlDiv), style); + Blockly.utils.dom.removeClass(/** @type {!Element} */ (this.HtmlDiv), style); }; /** * Return the deletion rectangle for this toolbox. - * @return {goog.math.Rect} Rectangle in which to delete. + * @return {Blockly.utils.Rect} Rectangle in which to delete. */ Blockly.Toolbox.prototype.getClientRect = function() { if (!this.HtmlDiv) { @@ -553,23 +551,21 @@ Blockly.Toolbox.prototype.getClientRect = function() { var BIG_NUM = 10000000; var toolboxRect = this.HtmlDiv.getBoundingClientRect(); - var x = toolboxRect.left; - var y = toolboxRect.top; - var width = toolboxRect.width; - var height = toolboxRect.height; + var top = toolboxRect.top; + var bottom = top + toolboxRect.height; + var left = toolboxRect.left; + var right = left + toolboxRect.width; // Assumes that the toolbox is on the SVG edge. If this changes // (e.g. toolboxes in mutators) then this code will need to be more complex. - if (this.toolboxPosition == Blockly.TOOLBOX_AT_LEFT) { - return new goog.math.Rect(-BIG_NUM, -BIG_NUM, BIG_NUM + x + width, - 2 * BIG_NUM); - } else if (this.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT) { - return new goog.math.Rect(x, -BIG_NUM, BIG_NUM + width, 2 * BIG_NUM); - } else if (this.toolboxPosition == Blockly.TOOLBOX_AT_TOP) { - return new goog.math.Rect(-BIG_NUM, -BIG_NUM, 2 * BIG_NUM, - BIG_NUM + y + height); - } else { // Bottom - return new goog.math.Rect(0, y, 2 * BIG_NUM, BIG_NUM + width); + if (this.toolboxPosition == Blockly.TOOLBOX_AT_TOP) { + return new Blockly.utils.Rect(-BIG_NUM, bottom, -BIG_NUM, BIG_NUM); + } else if (this.toolboxPosition == Blockly.TOOLBOX_AT_BOTTOM) { + return new Blockly.utils.Rect(top, BIG_NUM, -BIG_NUM, BIG_NUM); + } else if (this.toolboxPosition == Blockly.TOOLBOX_AT_LEFT) { + return new Blockly.utils.Rect(-BIG_NUM, BIG_NUM, -BIG_NUM, right); + } else { // Right + return new Blockly.utils.Rect(-BIG_NUM, BIG_NUM, left, BIG_NUM); } }; @@ -609,7 +605,7 @@ Blockly.Toolbox.TreeControl.prototype.enterDocument = function() { Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this); // Add touch handler. - if (goog.events.BrowserFeature.TOUCH_ENABLED) { + if (Blockly.Touch.TOUCH_ENABLED) { var el = this.getElement(); Blockly.bindEventWithChecks_(el, goog.events.EventType.TOUCHEND, this, this.handleTouchEvent_); diff --git a/core/tooltip.js b/core/tooltip.js index 3abf7787ff0..24d661cc099 100644 --- a/core/tooltip.js +++ b/core/tooltip.js @@ -35,9 +35,7 @@ */ goog.provide('Blockly.Tooltip'); -goog.require('Blockly.utils'); - -goog.require('goog.dom'); +goog.require('Blockly.utils.string'); /** @@ -167,7 +165,7 @@ Blockly.Tooltip.onMouseOver_ = function(e) { } // If the tooltip is an object, treat it as a pointer to the next object in // the chain to look at. Terminate when a string or function is found. - var element = e.target; + var element = e.currentTarget; while ((typeof element.tooltip != 'string') && (typeof element.tooltip != 'function')) { element = element.tooltip; @@ -213,9 +211,6 @@ Blockly.Tooltip.onMouseMove_ = function(e) { if (!Blockly.Tooltip.element_ || !Blockly.Tooltip.element_.tooltip) { // No tooltip here to show. return; - } else if (Blockly.WidgetDiv.isVisible()) { - // Don't display a tooltip if a widget is open (tooltip would be under it). - return; } else if (Blockly.Tooltip.blocked_) { // Someone doesn't want us to show tooltips. We are probably handling a // user gesture, such as a click or drag. @@ -294,7 +289,7 @@ Blockly.Tooltip.show_ = function() { while (typeof tip == 'function') { tip = tip(); } - tip = Blockly.utils.wrap(tip, Blockly.Tooltip.LIMIT); + tip = Blockly.utils.string.wrap(tip, Blockly.Tooltip.LIMIT); // Create new text, line by line. var lines = tip.split('\n'); for (var i = 0; i < lines.length; i++) { @@ -303,7 +298,8 @@ Blockly.Tooltip.show_ = function() { Blockly.Tooltip.DIV.appendChild(div); } var rtl = Blockly.Tooltip.element_.RTL; - var windowSize = goog.dom.getViewportSize(); + var windowWidth = document.documentElement.clientWidth; + var windowHeight = document.documentElement.clientHeight; // Display the tooltip. Blockly.Tooltip.DIV.style.direction = rtl ? 'rtl' : 'ltr'; Blockly.Tooltip.DIV.style.display = 'block'; @@ -318,7 +314,7 @@ Blockly.Tooltip.show_ = function() { var anchorY = Blockly.Tooltip.lastY_ + Blockly.Tooltip.OFFSET_Y; if (anchorY + Blockly.Tooltip.DIV.offsetHeight > - windowSize.height + window.scrollY) { + windowHeight + window.scrollY) { // Falling off the bottom of the screen; shift the tooltip up. anchorY -= Blockly.Tooltip.DIV.offsetHeight + 2 * Blockly.Tooltip.OFFSET_Y; } @@ -327,10 +323,10 @@ Blockly.Tooltip.show_ = function() { anchorX = Math.max(Blockly.Tooltip.MARGINS - window.scrollX, anchorX); } else { if (anchorX + Blockly.Tooltip.DIV.offsetWidth > - windowSize.width + window.scrollX - 2 * Blockly.Tooltip.MARGINS) { + windowWidth + window.scrollX - 2 * Blockly.Tooltip.MARGINS) { // Falling off the right edge of the screen; // clamp the tooltip on the edge. - anchorX = windowSize.width - Blockly.Tooltip.DIV.offsetWidth - + anchorX = windowWidth - Blockly.Tooltip.DIV.offsetWidth - 2 * Blockly.Tooltip.MARGINS; } } diff --git a/core/touch.js b/core/touch.js index 6b54bb8a7f3..8771600b6a3 100644 --- a/core/touch.js +++ b/core/touch.js @@ -31,9 +31,21 @@ goog.provide('Blockly.Touch'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.string'); -goog.require('goog.events.BrowserFeature'); +/** + * Whether touch is enabled in the browser. + * Copied from Closure's goog.events.BrowserFeature.TOUCH_ENABLED + */ +Blockly.Touch.TOUCH_ENABLED = + ('ontouchstart' in Blockly.utils.global || + !!(Blockly.utils.global['document'] && document.documentElement && + 'ontouchstart' in document.documentElement) || + // IE10 uses non-standard touch events, so it has a different check. + !!(Blockly.utils.global['navigator'] && + (Blockly.utils.global['navigator']['maxTouchPoints'] || + Blockly.utils.global['navigator']['msMaxTouchPoints']))); /** * Which touch events are we currently paying attention to? @@ -48,7 +60,7 @@ Blockly.Touch.touchIdentifier_ = null; * @type {Object} */ Blockly.Touch.TOUCH_MAP = {}; -if (goog.global.PointerEvent) { +if (Blockly.utils.global['PointerEvent']) { Blockly.Touch.TOUCH_MAP = { 'mousedown': ['pointerdown'], 'mouseenter': ['pointerenter'], @@ -60,7 +72,7 @@ if (goog.global.PointerEvent) { 'touchend': ['pointerup'], 'touchcancel': ['pointercancel'] }; -} else if (goog.events.BrowserFeature.TOUCH_ENABLED) { +} else if (Blockly.Touch.TOUCH_ENABLED) { Blockly.Touch.TOUCH_MAP = { 'mousedown': ['touchstart'], 'mousemove': ['touchmove'], @@ -199,7 +211,7 @@ Blockly.Touch.checkTouchIdentifier = function(e) { * @param {!Event} e A touch event. */ Blockly.Touch.setClientFromTouch = function(e) { - if (Blockly.utils.startsWith(e.type, 'touch')) { + if (Blockly.utils.string.startsWith(e.type, 'touch')) { // Map the touch event's properties to the event. var touchPoint = e.changedTouches[0]; e.clientX = touchPoint.clientX; @@ -213,9 +225,9 @@ Blockly.Touch.setClientFromTouch = function(e) { * @return {boolean} True if it is a mouse or touch event; false otherwise. */ Blockly.Touch.isMouseOrTouchEvent = function(e) { - return Blockly.utils.startsWith(e.type, 'touch') || - Blockly.utils.startsWith(e.type, 'mouse') || - Blockly.utils.startsWith(e.type, 'pointer'); + return Blockly.utils.string.startsWith(e.type, 'touch') || + Blockly.utils.string.startsWith(e.type, 'mouse') || + Blockly.utils.string.startsWith(e.type, 'pointer'); }; /** @@ -224,8 +236,8 @@ Blockly.Touch.isMouseOrTouchEvent = function(e) { * @return {boolean} True if it is a touch event; false otherwise. */ Blockly.Touch.isTouchEvent = function(e) { - return Blockly.utils.startsWith(e.type, 'touch') || - Blockly.utils.startsWith(e.type, 'pointer'); + return Blockly.utils.string.startsWith(e.type, 'touch') || + Blockly.utils.string.startsWith(e.type, 'pointer'); }; /** @@ -244,8 +256,8 @@ Blockly.Touch.splitEventByTouches = function(e) { type: e.type, changedTouches: [e.changedTouches[i]], target: e.target, - stopPropagation: function(){ e.stopPropagation(); }, - preventDefault: function(){ e.preventDefault(); } + stopPropagation: function() { e.stopPropagation(); }, + preventDefault: function() { e.preventDefault(); } }; events[i] = newEvent; } diff --git a/core/touch_gesture.js b/core/touch_gesture.js index fb84ed727bb..780579cf1f9 100644 --- a/core/touch_gesture.js +++ b/core/touch_gesture.js @@ -29,8 +29,7 @@ goog.provide('Blockly.TouchGesture'); goog.require('Blockly.Gesture'); goog.require('Blockly.utils'); - -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); /* @@ -58,7 +57,7 @@ Blockly.TouchGesture = function(e, creatorWorkspace) { /** * A map of cached points used for tracking multi-touch gestures. - * @type {Object} + * @type {Object} * @private */ this.cachedPoints_ = {}; @@ -240,7 +239,7 @@ Blockly.TouchGesture.prototype.handleTouchStart = function(e) { if (pointers.length == 2) { var point0 = this.cachedPoints_[pointers[0]]; var point1 = this.cachedPoints_[pointers[1]]; - this.startDistance_ = goog.math.Coordinate.distance(point0, point1); + this.startDistance_ = Blockly.utils.Coordinate.distance(point0, point1); this.isMultiTouch_ = true; e.preventDefault(); } @@ -263,7 +262,7 @@ Blockly.TouchGesture.prototype.handleTouchMove = function(e) { // Calculate the distance between the two pointers var point0 = this.cachedPoints_[pointers[0]]; var point1 = this.cachedPoints_[pointers[1]]; - var moveDistance = goog.math.Coordinate.distance(point0, point1); + var moveDistance = Blockly.utils.Coordinate.distance(point0, point1); var startDistance = this.startDistance_; var scale = this.touchScale_ = moveDistance / startDistance; @@ -301,14 +300,14 @@ Blockly.TouchGesture.prototype.handleTouchEnd = function(e) { /** * Helper function returning the current touch point coordinate. * @param {!Event} e A touch or pointer event. - * @return {goog.math.Coordinate} The current touch point coordinate + * @return {Blockly.utils.Coordinate} The current touch point coordinate * @package */ Blockly.TouchGesture.prototype.getTouchPoint = function(e) { if (!this.startWorkspace_) { return null; } - return new goog.math.Coordinate( + return new Blockly.utils.Coordinate( (e.pageX ? e.pageX : e.changedTouches[0].pageX), (e.pageY ? e.pageY : e.changedTouches[0].pageY) ); diff --git a/core/trashcan.js b/core/trashcan.js index 975f1beca87..8ab4c0e7b5a 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -26,9 +26,9 @@ goog.provide('Blockly.Trashcan'); -goog.require('Blockly.utils'); - -goog.require('goog.math.Rect'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.Rect'); +goog.require('Blockly.Xml'); /** @@ -224,21 +224,21 @@ Blockly.Trashcan.prototype.createDom = function() { clip-path="url(#blocklyTrashLidClipPath837493)"> */ - this.svgGroup_ = Blockly.utils.createSvgElement('g', + this.svgGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyTrash'}, null); var clip; var rnd = String(Math.random()).substring(2); - clip = Blockly.utils.createSvgElement('clipPath', + clip = Blockly.utils.dom.createSvgElement('clipPath', {'id': 'blocklyTrashBodyClipPath' + rnd}, this.svgGroup_); - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', { 'width': this.WIDTH_, 'height': this.BODY_HEIGHT_, 'y': this.LID_HEIGHT_ }, clip); - var body = Blockly.utils.createSvgElement('image', + var body = Blockly.utils.dom.createSvgElement('image', { 'width': Blockly.SPRITE.width, 'x': -this.SPRITE_LEFT_, @@ -247,15 +247,15 @@ Blockly.Trashcan.prototype.createDom = function() { 'clip-path': 'url(#blocklyTrashBodyClipPath' + rnd + ')' }, this.svgGroup_); - body.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + body.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); - clip = Blockly.utils.createSvgElement('clipPath', + clip = Blockly.utils.dom.createSvgElement('clipPath', {'id': 'blocklyTrashLidClipPath' + rnd}, this.svgGroup_); - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', {'width': this.WIDTH_, 'height': this.LID_HEIGHT_}, clip); - this.svgLid_ = Blockly.utils.createSvgElement('image', + this.svgLid_ = Blockly.utils.dom.createSvgElement('image', { 'width': Blockly.SPRITE.width, 'x': -this.SPRITE_LEFT_, @@ -264,7 +264,7 @@ Blockly.Trashcan.prototype.createDom = function() { 'clip-path': 'url(#blocklyTrashLidClipPath' + rnd + ')' }, this.svgGroup_); - this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + this.svgLid_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); Blockly.bindEventWithChecks_(this.svgGroup_, 'mouseup', this, this.click); @@ -286,7 +286,7 @@ Blockly.Trashcan.prototype.createDom = function() { */ Blockly.Trashcan.prototype.init = function(verticalSpacing) { if (this.workspace_.options.maxTrashcanContents > 0) { - Blockly.utils.insertAfter(this.flyout_.createDom('svg'), + Blockly.utils.dom.insertAfter(this.flyout_.createDom('svg'), this.workspace_.getParentSvg()); this.flyout_.init(this.workspace_); this.flyout_.isBlockCreatable_ = function() { @@ -307,7 +307,7 @@ Blockly.Trashcan.prototype.init = function(verticalSpacing) { */ Blockly.Trashcan.prototype.dispose = function() { if (this.svgGroup_) { - Blockly.utils.removeNode(this.svgGroup_); + Blockly.utils.dom.removeNode(this.svgGroup_); this.svgGroup_ = null; } this.svgLid_ = null; @@ -353,7 +353,7 @@ Blockly.Trashcan.prototype.position = function() { /** * Return the deletion rectangle for this trash can. - * @return {goog.math.Rect} Rectangle in which to delete. + * @return {Blockly.utils.Rect} Rectangle in which to delete. */ Blockly.Trashcan.prototype.getClientRect = function() { if (!this.svgGroup_) { @@ -361,12 +361,12 @@ Blockly.Trashcan.prototype.getClientRect = function() { } var trashRect = this.svgGroup_.getBoundingClientRect(); - var left = trashRect.left + this.SPRITE_LEFT_ - this.MARGIN_HOTSPOT_; var top = trashRect.top + this.SPRITE_TOP_ - this.MARGIN_HOTSPOT_; - var width = this.WIDTH_ + 2 * this.MARGIN_HOTSPOT_; - var height = this.LID_HEIGHT_ + this.BODY_HEIGHT_ + 2 * this.MARGIN_HOTSPOT_; - return new goog.math.Rect(left, top, width, height); - + var bottom = top + this.LID_HEIGHT_ + this.BODY_HEIGHT_ + + 2 * this.MARGIN_HOTSPOT_; + var left = trashRect.left + this.SPRITE_LEFT_ - this.MARGIN_HOTSPOT_; + var right = left + this.WIDTH_ + 2 * this.MARGIN_HOTSPOT_; + return new Blockly.utils.Rect(top, bottom, left, right); }; /** @@ -431,7 +431,7 @@ Blockly.Trashcan.prototype.click = function() { var xml = []; for (var i = 0, text; text = this.contents_[i]; i++) { - xml[i] = Blockly.Xml.textToDom(text).firstChild; + xml[i] = Blockly.Xml.textToDom(text); } this.flyout_.show(xml); }; @@ -469,7 +469,8 @@ Blockly.Trashcan.prototype.onDelete_ = function() { if (trashcan.workspace_.options.maxTrashcanContents <= 0) { return; } - if (event.type == Blockly.Events.BLOCK_DELETE) { + if (event.type == Blockly.Events.BLOCK_DELETE && + event.oldXml.tagName.toLowerCase() != 'shadow') { var cleanedXML = trashcan.cleanBlockXML_(event.oldXml); if (trashcan.contents_.indexOf(cleanedXML) != -1) { return; @@ -530,5 +531,5 @@ Blockly.Trashcan.prototype.cleanBlockXML_ = function(xml) { } node = nextNode; } - return '' + Blockly.Xml.domToText(xmlBlock) + ''; + return Blockly.Xml.domToText(xmlBlock); }; diff --git a/core/ui_menu_utils.js b/core/ui_menu_utils.js index 695041ce74e..6e1dbaec2c2 100644 --- a/core/ui_menu_utils.js +++ b/core/ui_menu_utils.js @@ -19,7 +19,7 @@ */ /** - * @fileoverview Utility methods for working with the closure menu + * @fileoverview Utility methods for working with the Closure menu * (goog.ui.menu). * @author fenichel@google.com (Rachel Fenichel) */ @@ -31,6 +31,8 @@ */ goog.provide('Blockly.utils.uiMenu'); +goog.require('goog.style'); + /** * Get the size of a rendered goog.ui.Menu. diff --git a/core/utils.js b/core/utils.js index a42858b2527..160696d7691 100644 --- a/core/utils.js +++ b/core/utils.js @@ -32,97 +32,13 @@ */ goog.provide('Blockly.utils'); -goog.require('goog.dom'); -goog.require('goog.math.Coordinate'); -goog.require('goog.userAgent'); +goog.require('Blockly.Msg'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.string'); +goog.require('Blockly.utils.userAgent'); +goog.require('goog.style'); -/** - * Remove an attribute from a element even if it's in IE 10. - * Similar to Element.removeAttribute() but it works on SVG elements in IE 10. - * Sets the attribute to null in IE 10, which treats removeAttribute as a no-op - * if it's called on an SVG element. - * @param {!Element} element DOM element to remove attribute from. - * @param {string} attributeName Name of attribute to remove. - */ -Blockly.utils.removeAttribute = function(element, attributeName) { - // goog.userAgent.isVersion is deprecated, but the replacement is - // goog.userAgent.isVersionOrHigher. - if (goog.userAgent.IE && goog.userAgent.isVersion('10.0')) { - element.setAttribute(attributeName, null); - } else { - element.removeAttribute(attributeName); - } -}; - -/** - * Add a CSS class to a element. - * Similar to Closure's goog.dom.classes.add, except it handles SVG elements. - * @param {!Element} element DOM element to add class to. - * @param {string} className Name of class to add. - * @return {boolean} True if class was added, false if already present. - */ -Blockly.utils.addClass = function(element, className) { - var classes = element.getAttribute('class') || ''; - if ((' ' + classes + ' ').indexOf(' ' + className + ' ') != -1) { - return false; - } - if (classes) { - classes += ' '; - } - element.setAttribute('class', classes + className); - return true; -}; - -/** - * Remove a CSS class from a element. - * Similar to Closure's goog.dom.classes.remove, except it handles SVG elements. - * @param {!Element} element DOM element to remove class from. - * @param {string} className Name of class to remove. - * @return {boolean} True if class was removed, false if never present. - */ -Blockly.utils.removeClass = function(element, className) { - var classes = element.getAttribute('class'); - if ((' ' + classes + ' ').indexOf(' ' + className + ' ') == -1) { - return false; - } - var classList = classes.split(/\s+/); - for (var i = 0; i < classList.length; i++) { - if (!classList[i] || classList[i] == className) { - classList.splice(i, 1); - i--; - } - } - if (classList.length) { - element.setAttribute('class', classList.join(' ')); - } else { - Blockly.utils.removeAttribute(element, 'class'); - } - return true; -}; - -/** - * Checks if an element has the specified CSS class. - * Similar to Closure's goog.dom.classes.has, except it handles SVG elements. - * @param {!Element} element DOM element to check. - * @param {string} className Name of class to check. - * @return {boolean} True if class exists, false otherwise. - * @package - */ -Blockly.utils.hasClass = function(element, className) { - var classes = element.getAttribute('class'); - return (' ' + classes + ' ').indexOf(' ' + className + ' ') != -1; -}; - -/** - * Removes a node from its parent. No-op if not attached to a parent. - * @param {Node} node The node to remove. - * @return {Node} The node removed if removed; else, null. - */ -// Copied from Closure goog.dom.removeNode -Blockly.utils.removeNode = function(node) { - return node && node.parentNode ? node.parentNode.removeChild(node) : null; -}; /** * Don't do anything for this event, just halt propagation. @@ -151,10 +67,10 @@ Blockly.utils.isTargetInput = function(e) { * Return the coordinates of the top-left corner of this element relative to * its parent. Only for SVG elements and children (e.g. rect, g, path). * @param {!Element} element SVG element to find the coordinates of. - * @return {!goog.math.Coordinate} Object with .x and .y properties. + * @return {!Blockly.utils.Coordinate} Object with .x and .y properties. */ Blockly.utils.getRelativeXY = function(element) { - var xy = new goog.math.Coordinate(0, 0); + var xy = new Blockly.utils.Coordinate(0, 0); // First, check for x and y attributes. var x = element.getAttribute('x'); if (x) { @@ -195,7 +111,7 @@ Blockly.utils.getRelativeXY = function(element) { * @param {!Element} element SVG element to find the coordinates of. If this is * not a child of the div Blockly was injected into, the behaviour is * undefined. - * @return {!goog.math.Coordinate} Object with .x and .y properties. + * @return {!Blockly.utils.Coordinate} Object with .x and .y properties. */ Blockly.utils.getInjectionDivXY_ = function(element) { var x = 0; @@ -210,7 +126,7 @@ Blockly.utils.getInjectionDivXY_ = function(element) { } element = element.parentNode; } - return new goog.math.Coordinate(x, y); + return new Blockly.utils.Coordinate(x, y); }; /** @@ -235,38 +151,13 @@ Blockly.utils.getRelativeXY.XY_REGEX_ = Blockly.utils.getRelativeXY.XY_STYLE_REGEX_ = /transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/; -/** - * Helper method for creating SVG elements. - * @param {string} name Element's tag name. - * @param {!Object} attrs Dictionary of attribute names and values. - * @param {Element} parent Optional parent on which to append the element. - * @return {!SVGElement} Newly created SVG element. - */ -Blockly.utils.createSvgElement = function(name, attrs, parent) { - var e = /** @type {!SVGElement} */ - (document.createElementNS(Blockly.SVG_NS, name)); - for (var key in attrs) { - e.setAttribute(key, attrs[key]); - } - // IE defines a unique attribute "runtimeStyle", it is NOT applied to - // elements created with createElementNS. However, Closure checks for IE - // and assumes the presence of the attribute and crashes. - if (document.body.runtimeStyle) { // Indicates presence of IE-only attr. - e.runtimeStyle = e.currentStyle = e.style; - } - if (parent) { - parent.appendChild(e); - } - return e; -}; - /** * Is this event a right-click? * @param {!Event} e Mouse event. * @return {boolean} True if right-click. */ Blockly.utils.isRightButton = function(e) { - if (e.ctrlKey && goog.userAgent.MAC) { + if (e.ctrlKey && Blockly.utils.userAgent.MAC) { // Control-clicking on Mac OS X is treated as a right-click. // WebKit on Mac OS X fails to change button to 2 (but Gecko does). return true; @@ -319,90 +210,6 @@ Blockly.utils.getScrollDeltaPixels = function(e) { } }; -/** - * Given an array of strings, return the length of the shortest one. - * @param {!Array.} array Array of strings. - * @return {number} Length of shortest string. - */ -Blockly.utils.shortestStringLength = function(array) { - if (!array.length) { - return 0; - } - return array.reduce(function(a, b) { - return a.length < b.length ? a : b; - }).length; -}; - -/** - * Given an array of strings, return the length of the common prefix. - * Words may not be split. Any space after a word is included in the length. - * @param {!Array.} array Array of strings. - * @param {number=} opt_shortest Length of shortest string. - * @return {number} Length of common prefix. - */ -Blockly.utils.commonWordPrefix = function(array, opt_shortest) { - if (!array.length) { - return 0; - } else if (array.length == 1) { - return array[0].length; - } - var wordPrefix = 0; - var max = opt_shortest || Blockly.utils.shortestStringLength(array); - for (var len = 0; len < max; len++) { - var letter = array[0][len]; - for (var i = 1; i < array.length; i++) { - if (letter != array[i][len]) { - return wordPrefix; - } - } - if (letter == ' ') { - wordPrefix = len + 1; - } - } - for (var i = 1; i < array.length; i++) { - var letter = array[i][len]; - if (letter && letter != ' ') { - return wordPrefix; - } - } - return max; -}; - -/** - * Given an array of strings, return the length of the common suffix. - * Words may not be split. Any space after a word is included in the length. - * @param {!Array.} array Array of strings. - * @param {number=} opt_shortest Length of shortest string. - * @return {number} Length of common suffix. - */ -Blockly.utils.commonWordSuffix = function(array, opt_shortest) { - if (!array.length) { - return 0; - } else if (array.length == 1) { - return array[0].length; - } - var wordPrefix = 0; - var max = opt_shortest || Blockly.utils.shortestStringLength(array); - for (var len = 0; len < max; len++) { - var letter = array[0].substr(-len - 1, 1); - for (var i = 1; i < array.length; i++) { - if (letter != array[i].substr(-len - 1, 1)) { - return wordPrefix; - } - } - if (letter == ' ') { - wordPrefix = len + 1; - } - } - for (var i = 1; i < array.length; i++) { - var letter = array[i].charAt(array[i].length - len - 1); - if (letter && letter != ' ') { - return wordPrefix; - } - } - return max; -}; - /** * Parse a string with any number of interpolation tokens (%1, %2, ...). * It will also replace string table references (e.g., %{bky_my_msg} and @@ -449,23 +256,13 @@ Blockly.utils.checkMessageReferences = function(message) { // TODO (#1169): Implement support for other string tables, // prefixes other than BKY_. - var regex = /%{(BKY_[A-Z][A-Z0-9_]*)}/gi; - var match = regex.exec(message); - while (match) { - var msgKey = match[1]; - msgKey = msgKey.toUpperCase(); - if (msgKey.substr(0, 4) != 'BKY_') { - console.log('WARNING: Unsupported message table prefix in %{' + - match[1] + '}.'); - validSoFar = false; // Continue to report other errors. - } else if (msgTable[msgKey.substr(4)] == undefined) { - console.log('WARNING: No message string for %{' + match[1] + '}.'); + var m = message.match(/%{BKY_[A-Z]\w*}/ig); + for (var i = 0; i < m.length; i++) { + var msgKey = m[i].toUpperCase(); + if (msgTable[msgKey.slice(6, -1)] == undefined) { + console.log('WARNING: No message string for ' + m[i] + ' in ' + message); validSoFar = false; // Continue to report other errors. } - - // Re-run on remainder of string. - message = message.substring(match.index + msgKey.length + 1); - match = regex.exec(message); } return validSoFar; @@ -543,14 +340,14 @@ Blockly.utils.tokenizeInterpolation_ = function(message, buffer.push(c); } else { var rawKey = buffer.join(''); - if (/[a-zA-Z][a-zA-Z0-9_]*/.test(rawKey)) { // Strict matching + if (/[A-Z]\w*/i.test(rawKey)) { // Strict matching // Found a valid string key. Attempt case insensitive match. var keyUpper = rawKey.toUpperCase(); // BKY_ is the prefix used to namespace the strings used in Blockly // core files and the predefined blocks in ../blocks/. // These strings are defined in ../msgs/ files. - var bklyKey = Blockly.utils.startsWith(keyUpper, 'BKY_') ? + var bklyKey = Blockly.utils.string.startsWith(keyUpper, 'BKY_') ? keyUpper.substring(4) : null; if (bklyKey && bklyKey in Blockly.Msg) { var rawValue = Blockly.Msg[bklyKey]; @@ -635,174 +432,6 @@ Blockly.utils.genUid = function() { Blockly.utils.genUid.soup_ = '!#$%()*+,-./:;=?@[]^_`{|}~' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; -/** - * Wrap text to the specified width. - * @param {string} text Text to wrap. - * @param {number} limit Width to wrap each line. - * @return {string} Wrapped text. - */ -Blockly.utils.wrap = function(text, limit) { - var lines = text.split('\n'); - for (var i = 0; i < lines.length; i++) { - lines[i] = Blockly.utils.wrapLine_(lines[i], limit); - } - return lines.join('\n'); -}; - -/** - * Wrap single line of text to the specified width. - * @param {string} text Text to wrap. - * @param {number} limit Width to wrap each line. - * @return {string} Wrapped text. - * @private - */ -Blockly.utils.wrapLine_ = function(text, limit) { - if (text.length <= limit) { - // Short text, no need to wrap. - return text; - } - // Split the text into words. - var words = text.trim().split(/\s+/); - // Set limit to be the length of the largest word. - for (var i = 0; i < words.length; i++) { - if (words[i].length > limit) { - limit = words[i].length; - } - } - - var lastScore; - var score = -Infinity; - var lastText; - var lineCount = 1; - do { - lastScore = score; - lastText = text; - // Create a list of booleans representing if a space (false) or - // a break (true) appears after each word. - var wordBreaks = []; - // Seed the list with evenly spaced linebreaks. - var steps = words.length / lineCount; - var insertedBreaks = 1; - for (var i = 0; i < words.length - 1; i++) { - if (insertedBreaks < (i + 1.5) / steps) { - insertedBreaks++; - wordBreaks[i] = true; - } else { - wordBreaks[i] = false; - } - } - wordBreaks = Blockly.utils.wrapMutate_(words, wordBreaks, limit); - score = Blockly.utils.wrapScore_(words, wordBreaks, limit); - text = Blockly.utils.wrapToText_(words, wordBreaks); - lineCount++; - } while (score > lastScore); - return lastText; -}; - -/** - * Compute a score for how good the wrapping is. - * @param {!Array.} words Array of each word. - * @param {!Array.} wordBreaks Array of line breaks. - * @param {number} limit Width to wrap each line. - * @return {number} Larger the better. - * @private - */ -Blockly.utils.wrapScore_ = function(words, wordBreaks, limit) { - // If this function becomes a performance liability, add caching. - // Compute the length of each line. - var lineLengths = [0]; - var linePunctuation = []; - for (var i = 0; i < words.length; i++) { - lineLengths[lineLengths.length - 1] += words[i].length; - if (wordBreaks[i] === true) { - lineLengths.push(0); - linePunctuation.push(words[i].charAt(words[i].length - 1)); - } else if (wordBreaks[i] === false) { - lineLengths[lineLengths.length - 1]++; - } - } - var maxLength = Math.max.apply(Math, lineLengths); - - var score = 0; - for (var i = 0; i < lineLengths.length; i++) { - // Optimize for width. - // -2 points per char over limit (scaled to the power of 1.5). - score -= Math.pow(Math.abs(limit - lineLengths[i]), 1.5) * 2; - // Optimize for even lines. - // -1 point per char smaller than max (scaled to the power of 1.5). - score -= Math.pow(maxLength - lineLengths[i], 1.5); - // Optimize for structure. - // Add score to line endings after punctuation. - if ('.?!'.indexOf(linePunctuation[i]) != -1) { - score += limit / 3; - } else if (',;)]}'.indexOf(linePunctuation[i]) != -1) { - score += limit / 4; - } - } - // All else being equal, the last line should not be longer than the - // previous line. For example, this looks wrong: - // aaa bbb - // ccc ddd eee - if (lineLengths.length > 1 && lineLengths[lineLengths.length - 1] <= - lineLengths[lineLengths.length - 2]) { - score += 0.5; - } - return score; -}; - -/** - * Mutate the array of line break locations until an optimal solution is found. - * No line breaks are added or deleted, they are simply moved around. - * @param {!Array.} words Array of each word. - * @param {!Array.} wordBreaks Array of line breaks. - * @param {number} limit Width to wrap each line. - * @return {!Array.} New array of optimal line breaks. - * @private - */ -Blockly.utils.wrapMutate_ = function(words, wordBreaks, limit) { - var bestScore = Blockly.utils.wrapScore_(words, wordBreaks, limit); - var bestBreaks; - // Try shifting every line break forward or backward. - for (var i = 0; i < wordBreaks.length - 1; i++) { - if (wordBreaks[i] == wordBreaks[i + 1]) { - continue; - } - var mutatedWordBreaks = [].concat(wordBreaks); - mutatedWordBreaks[i] = !mutatedWordBreaks[i]; - mutatedWordBreaks[i + 1] = !mutatedWordBreaks[i + 1]; - var mutatedScore = - Blockly.utils.wrapScore_(words, mutatedWordBreaks, limit); - if (mutatedScore > bestScore) { - bestScore = mutatedScore; - bestBreaks = mutatedWordBreaks; - } - } - if (bestBreaks) { - // Found an improvement. See if it may be improved further. - return Blockly.utils.wrapMutate_(words, bestBreaks, limit); - } - // No improvements found. Done. - return wordBreaks; -}; - -/** - * Reassemble the array of words into text, with the specified line breaks. - * @param {!Array.} words Array of each word. - * @param {!Array.} wordBreaks Array of line breaks. - * @return {string} Plain text. - * @private - */ -Blockly.utils.wrapToText_ = function(words, wordBreaks) { - var text = []; - for (var i = 0; i < words.length; i++) { - text.push(words[i]); - if (wordBreaks[i] !== undefined) { - text.push(wordBreaks[i] ? '\n' : ' '); - } - } - return text.join(''); -}; - /** * Check if 3D transforms are supported by adding an element * and attempting to set the property. @@ -814,7 +443,7 @@ Blockly.utils.is3dSupported = function() { } // CC-BY-SA Lorenzo Polidori // stackoverflow.com/questions/5661671/detecting-transform-translate3d-support - if (!goog.global.getComputedStyle) { + if (!Blockly.utils.global.getComputedStyle) { return false; } @@ -834,7 +463,7 @@ Blockly.utils.is3dSupported = function() { for (var t in transforms) { if (el.style[t] !== undefined) { el.style[t] = 'translate3d(1px,1px,1px)'; - var computedStyle = goog.global.getComputedStyle(el); + var computedStyle = Blockly.utils.global.getComputedStyle(el); if (!computedStyle) { // getComputedStyle in Firefox returns null when Blockly is loaded // inside an iframe with display: none. Returning false and not @@ -853,26 +482,6 @@ Blockly.utils.is3dSupported = function() { return Blockly.utils.is3dSupported.cached_; }; -/** - * Insert a node after a reference node. - * Contrast with node.insertBefore function. - * @param {!Element} newNode New element to insert. - * @param {!Element} refNode Existing element to precede new node. - * @package - */ -Blockly.utils.insertAfter = function(newNode, refNode) { - var siblingNode = refNode.nextSibling; - var parentNode = refNode.parentNode; - if (!parentNode) { - throw Error('Reference node has no parent.'); - } - if (siblingNode) { - parentNode.insertBefore(newNode, siblingNode); - } else { - parentNode.appendChild(newNode); - } -}; - /** * Calls a function after the page has loaded, possibly immediately. * @param {function()} fn Function to run. @@ -895,18 +504,6 @@ Blockly.utils.runAfterPageLoad = function(fn) { } }; -/** - * Sets the CSS transform property on an element. This function sets the - * non-vendor-prefixed and vendor-prefixed versions for backwards compatibility - * with older browsers. See https://caniuse.com/#feat=transforms2d - * @param {!Element} node The node which the CSS transform should be applied. - * @param {string} transform The value of the CSS `transform` property. - */ -Blockly.utils.setCssTransform = function(node, transform) { - node.style['transform'] = transform; - node.style['-webkit-transform'] = transform; -}; - /** * Get the position of the current viewport in window coordinates. This takes * scroll into account. @@ -915,30 +512,16 @@ Blockly.utils.setCssTransform = function(node, transform) { * @package */ Blockly.utils.getViewportBBox = function() { - // Pixels. - var windowSize = goog.dom.getViewportSize(); // Pixels, in window coordinates. var scrollOffset = goog.style.getViewportPageOffset(document); return { - right: windowSize.width + scrollOffset.x, - bottom: windowSize.height + scrollOffset.y, + right: document.documentElement.clientWidth + scrollOffset.x, + bottom: document.documentElement.clientHeight + scrollOffset.y, top: scrollOffset.y, left: scrollOffset.x }; }; -/** - * Fast prefix-checker. - * Copied from Closure's goog.string.startsWith. - * @param {string} str The string to check. - * @param {string} prefix A string to look for at the start of `str`. - * @return {boolean} True if `str` begins with `prefix`. - * @package - */ -Blockly.utils.startsWith = function(str, prefix) { - return str.lastIndexOf(prefix, 0) == 0; -}; - /** * Removes the first occurrence of a particular value from an array. * @param {!Array} arr Array from which to remove @@ -957,37 +540,21 @@ Blockly.utils.arrayRemove = function(arr, obj) { }; /** - * Converts degrees to radians. - * Copied from Closure's goog.math.toRadians. - * @param {number} angleDegrees Angle in degrees. - * @return {number} Angle in radians. - * @package - */ -Blockly.utils.toRadians = function(angleDegrees) { - return angleDegrees * Math.PI / 180; -}; - -/** - * Converts radians to degrees. - * Copied from Closure's goog.math.toDegrees. - * @param {number} angleRadians Angle in radians. - * @return {number} Angle in degrees. - * @package - */ -Blockly.utils.toDegrees = function(angleRadians) { - return angleRadians * 180 / Math.PI; -}; - -/** - * Whether a node contains another node. - * @param {!Node} parent The node that should contain the other node. - * @param {!Node} descendant The node to test presence of. - * @return {boolean} Whether the parent node contains the descendant node. - * @package + * Gets the document scroll distance as a coordinate object. + * Copied from Closure's goog.dom.getDocumentScroll. + * @return {!Blockly.utils.Coordinate} Object with values 'x' and 'y'. */ -Blockly.utils.containsNode = function(parent, descendant) { - return !!(parent.compareDocumentPosition(descendant) & - Node.DOCUMENT_POSITION_CONTAINED_BY); +Blockly.utils.getDocumentScroll = function() { + var el = document.documentElement; + var win = window; + if (Blockly.utils.userAgent.IE && win.pageYOffset != el.scrollTop) { + // The keyboard on IE10 touch devices shifts the page using the pageYOffset + // without modifying scrollTop. For this case, we want the body scroll + // offsets. + return new Blockly.utils.Coordinate(el.scrollLeft, el.scrollTop); + } + return new Blockly.utils.Coordinate( + win.pageXOffset || el.scrollLeft, win.pageYOffset || el.scrollTop); }; /** @@ -1020,18 +587,6 @@ Blockly.utils.getBlockTypeCounts = function(block, opt_stripFollowing) { }; /** - * Clamp the provided number between the lower bound and the upper bound. - * @param {number} lowerBound The desired lower bound. - * @param {number} number The number to clamp. - * @param {number} upperBound The desired upper bound. - * @return {number} The clamped number. - * @package + * Reference to the global object. */ -Blockly.utils.clampNumber = function(lowerBound, number, upperBound) { - if (upperBound < lowerBound) { - var temp = upperBound; - upperBound = lowerBound; - lowerBound = temp; - } - return Math.max(lowerBound, Math.min(number, upperBound)); -}; +Blockly.utils.global = this || self; diff --git a/core/utils/colour.js b/core/utils/colour.js new file mode 100644 index 00000000000..5a4f6ca7180 --- /dev/null +++ b/core/utils/colour.js @@ -0,0 +1,208 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Utility methods for colour manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @author fraser@google.com (Neil Fraser) + */ +'use strict'; + +/** + * @name Blockly.utils.colour + * @namespace + */ +goog.provide('Blockly.utils.colour'); + +goog.require('Blockly.utils'); + + +/** + * Parses a colour from a string. + * .parse('red') -> '#ff0000' + * .parse('#f00') -> '#ff0000' + * .parse('#ff0000') -> '#ff0000' + * .parse('rgb(255, 0, 0)') -> '#ff0000' + * @param {string} str Colour in some CSS format. + * @return {string|null} A string containing a hex representation of the colour, + * or null if can't be parsed. + */ +Blockly.utils.colour.parse = function(str) { + str = String(str).toLowerCase().trim(); + var hex = Blockly.utils.colour.names[str]; + if (hex) { + // e.g. 'red' + return hex; + } + hex = str[0] == '#' ? str : '#' + str; + if (/^#[0-9a-f]{6}$/.test(hex)) { + // e.g. '#00ff88' + return hex; + } + if (/^#[0-9a-f]{3}$/.test(hex)) { + // e.g. '#0f8' + return ['#', hex[1], hex[1], hex[2], hex[2], hex[3], hex[3]].join(''); + } + var rgb = str.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/); + if (rgb) { + // e.g. 'rgb(0, 128, 255)' + var r = Number(rgb[1]); + var g = Number(rgb[2]); + var b = Number(rgb[3]); + if (r >= 0 && r < 256 && g >= 0 && g < 256 && b >= 0 && b < 256) { + return Blockly.utils.colour.rgbToHex(r, g, b); + } + } + return null; +}; + +/** + * Converts a colour from RGB to hex representation. + * @param {number} r Amount of red, int between 0 and 255. + * @param {number} g Amount of green, int between 0 and 255. + * @param {number} b Amount of blue, int between 0 and 255. + * @return {string} Hex representation of the colour. + */ +Blockly.utils.colour.rgbToHex = function(r, g, b) { + var rgb = (r << 16) | (g << 8) | b; + if (r < 0x10) { + return '#' + (0x1000000 | rgb).toString(16).substr(1); + } + return '#' + rgb.toString(16); +}; + +/** + * Converts a hex representation of a colour to RGB. + * @param {string} hexColor Colour in '#ff0000' format. + * @return {!Array.} RGB representation of the colour. + */ +Blockly.utils.colour.hexToRgb = function(hexColor) { + var rgb = parseInt(hexColor.substr(1), 16); + var r = rgb >> 16; + var g = (rgb >> 8) & 255; + var b = rgb & 255; + + return [r, g, b]; +}; + +/** + * Converts an HSV triplet to hex representation. + * @param {number} h Hue value in [0, 360]. + * @param {number} s Saturation value in [0, 1]. + * @param {number} v Brightness in [0, 255]. + * @return {string} Hex representation of the colour. + */ +Blockly.utils.colour.hsvToHex = function(h, s, v) { + var red = 0; + var green = 0; + var blue = 0; + if (s == 0) { + red = v; + green = v; + blue = v; + } else { + var sextant = Math.floor(h / 60); + var remainder = (h / 60) - sextant; + var val1 = v * (1 - s); + var val2 = v * (1 - (s * remainder)); + var val3 = v * (1 - (s * (1 - remainder))); + switch (sextant) { + case 1: + red = val2; + green = v; + blue = val1; + break; + case 2: + red = val1; + green = v; + blue = val3; + break; + case 3: + red = val1; + green = val2; + blue = v; + break; + case 4: + red = val3; + green = val1; + blue = v; + break; + case 5: + red = v; + green = val1; + blue = val2; + break; + case 6: + case 0: + red = v; + green = val3; + blue = val1; + break; + } + } + return Blockly.utils.colour.rgbToHex( + Math.floor(red), Math.floor(green), Math.floor(blue)); +}; + +/** + * Blend two colours together, using the specified factor to indicate the + * weight given to the first colour. + * @param {string} colour1 First colour. + * @param {string} colour2 Second colour. + * @param {number} factor The weight to be given to colour1 over colour2. + * Values should be in the range [0, 1]. + * @return {string} Combined colour represented in hex. + */ +Blockly.utils.colour.blend = function(colour1, colour2, factor) { + var rgb1 = Blockly.utils.colour.hexToRgb(Blockly.utils.colour.parse(colour1)); + var rgb2 = Blockly.utils.colour.hexToRgb(Blockly.utils.colour.parse(colour2)); + var r = Math.round(rgb2[0] + factor * (rgb1[0] - rgb2[0])); + var g = Math.round(rgb2[1] + factor * (rgb1[1] - rgb2[1])); + var b = Math.round(rgb2[2] + factor * (rgb1[2] - rgb2[2])); + return Blockly.utils.colour.rgbToHex(r, g, b); +}; + +/** + * A map that contains the 16 basic colour keywords as defined by W3C: + * https://www.w3.org/TR/2018/REC-css-color-3-20180619/#html4 + * The keys of this map are the lowercase "readable" names of the colours, + * while the values are the "hex" values. + * + * @type {!Object} + */ +Blockly.utils.colour.names = { + 'aqua': '#00ffff', + 'black': '#000000', + 'blue': '#0000ff', + 'fuchsia': '#ff00ff', + 'gray': '#808080', + 'green': '#008000', + 'lime': '#00ff00', + 'maroon': '#800000', + 'navy': '#000080', + 'olive': '#808000', + 'purple': '#800080', + 'red': '#ff0000', + 'silver': '#c0c0c0', + 'teal': '#008080', + 'white': '#ffffff', + 'yellow': '#ffff00' +}; diff --git a/core/utils/coordinate.js b/core/utils/coordinate.js new file mode 100644 index 00000000000..21d6ca50f77 --- /dev/null +++ b/core/utils/coordinate.js @@ -0,0 +1,139 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Utility methods for coordinate manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @author fraser@google.com (Neil Fraser) + */ +'use strict'; + +/** + * @name Blockly.utils.Coordinate + * @namespace + */ +goog.provide('Blockly.utils.Coordinate'); + + +/** + * Class for representing coordinates and positions. + * @param {number} x Left. + * @param {number} y Top. + * @struct + * @constructor + */ +Blockly.utils.Coordinate = function(x, y) { + /** + * X-value + * @type {number} + */ + this.x = x; + + /** + * Y-value + * @type {number} + */ + this.y = y; +}; + +/** + * Compares coordinates for equality. + * @param {Blockly.utils.Coordinate} a A Coordinate. + * @param {Blockly.utils.Coordinate} b A Coordinate. + * @return {boolean} True iff the coordinates are equal, or if both are null. + */ +Blockly.utils.Coordinate.equals = function(a, b) { + if (a == b) { + return true; + } + if (!a || !b) { + return false; + } + return a.x == b.x && a.y == b.y; +}; + +/** + * Returns the distance between two coordinates. + * @param {!Blockly.utils.Coordinate} a A Coordinate. + * @param {!Blockly.utils.Coordinate} b A Coordinate. + * @return {number} The distance between `a` and `b`. + */ +Blockly.utils.Coordinate.distance = function(a, b) { + var dx = a.x - b.x; + var dy = a.y - b.y; + return Math.sqrt(dx * dx + dy * dy); +}; + +/** + * Returns the magnitude of a coordinate. + * @param {!Blockly.utils.Coordinate} a A Coordinate. + * @return {number} The distance between the origin and `a`. + */ +Blockly.utils.Coordinate.magnitude = function(a) { + return Math.sqrt(a.x * a.x + a.y * a.y); +}; + +/** + * Returns the difference between two coordinates as a new + * Blockly.utils.Coordinate. + * @param {!Blockly.utils.Coordinate|!SVGPoint} a An x/y coordinate. + * @param {!Blockly.utils.Coordinate|!SVGPoint} b An x/y coordinate. + * @return {!Blockly.utils.Coordinate} A Coordinate representing the difference + * between `a` and `b`. + */ +Blockly.utils.Coordinate.difference = function(a, b) { + return new Blockly.utils.Coordinate(a.x - b.x, a.y - b.y); +}; + +/** + * Returns the sum of two coordinates as a new Blockly.utils.Coordinate. + * @param {!Blockly.utils.Coordinate|!SVGPoint} a An x/y coordinate. + * @param {!Blockly.utils.Coordinate|!SVGPoint} b An x/y coordinate. + * @return {!Blockly.utils.Coordinate} A Coordinate representing the sum of + * the two coordinates. + */ +Blockly.utils.Coordinate.sum = function(a, b) { + return new Blockly.utils.Coordinate(a.x + b.x, a.y + b.y); +}; + +/** + * Scales this coordinate by the given scale factor. + * @param {number} s The scale factor to use for both x and y dimensions. + * @return {!Blockly.utils.Coordinate} This coordinate after scaling. + */ +Blockly.utils.Coordinate.prototype.scale = function(s) { + this.x *= s; + this.y *= s; + return this; +}; + +/** + * Translates this coordinate by the given offsets. + * respectively. + * @param {number} tx The value to translate x by. + * @param {number} ty The value to translate y by. + * @return {!Blockly.utils.Coordinate} This coordinate after translating. + */ +Blockly.utils.Coordinate.prototype.translate = function(tx, ty) { + this.x += tx; + this.y += ty; + return this; +}; diff --git a/core/utils/dom.js b/core/utils/dom.js new file mode 100644 index 00000000000..3a9b0013ebb --- /dev/null +++ b/core/utils/dom.js @@ -0,0 +1,187 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Utility methods for DOM manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @author fraser@google.com (Neil Fraser) + */ +'use strict'; + +/** + * @name Blockly.utils.dom + * @namespace + */ +goog.provide('Blockly.utils.dom'); + + +/** + * Required name space for SVG elements. + * @const + */ +Blockly.utils.dom.SVG_NS = 'http://www.w3.org/2000/svg'; + +/** + * Required name space for HTML elements. + * @const + */ +Blockly.utils.dom.HTML_NS = 'http://www.w3.org/1999/xhtml'; + +/** + * Required name space for XLINK elements. + * @const + */ +Blockly.utils.dom.XLINK_NS = 'http://www.w3.org/1999/xlink'; + +/** + * Helper method for creating SVG elements. + * @param {string} name Element's tag name. + * @param {!Object} attrs Dictionary of attribute names and values. + * @param {Element} parent Optional parent on which to append the element. + * @return {!SVGElement} Newly created SVG element. + */ +Blockly.utils.dom.createSvgElement = function(name, attrs, parent) { + var e = /** @type {!SVGElement} */ + (document.createElementNS(Blockly.utils.dom.SVG_NS, name)); + for (var key in attrs) { + e.setAttribute(key, attrs[key]); + } + // IE defines a unique attribute "runtimeStyle", it is NOT applied to + // elements created with createElementNS. However, Closure checks for IE + // and assumes the presence of the attribute and crashes. + if (document.body.runtimeStyle) { // Indicates presence of IE-only attr. + e.runtimeStyle = e.currentStyle = e.style; + } + if (parent) { + parent.appendChild(e); + } + return e; +}; + +/** + * Add a CSS class to a element. + * Similar to Closure's goog.dom.classes.add, except it handles SVG elements. + * @param {!Element} element DOM element to add class to. + * @param {string} className Name of class to add. + * @return {boolean} True if class was added, false if already present. + */ +Blockly.utils.dom.addClass = function(element, className) { + var classes = element.getAttribute('class') || ''; + if ((' ' + classes + ' ').indexOf(' ' + className + ' ') != -1) { + return false; + } + if (classes) { + classes += ' '; + } + element.setAttribute('class', classes + className); + return true; +}; + +/** + * Remove a CSS class from a element. + * Similar to Closure's goog.dom.classes.remove, except it handles SVG elements. + * @param {!Element} element DOM element to remove class from. + * @param {string} className Name of class to remove. + * @return {boolean} True if class was removed, false if never present. + */ +Blockly.utils.dom.removeClass = function(element, className) { + var classes = element.getAttribute('class'); + if ((' ' + classes + ' ').indexOf(' ' + className + ' ') == -1) { + return false; + } + var classList = classes.split(/\s+/); + for (var i = 0; i < classList.length; i++) { + if (!classList[i] || classList[i] == className) { + classList.splice(i, 1); + i--; + } + } + if (classList.length) { + element.setAttribute('class', classList.join(' ')); + } else { + element.removeAttribute('class'); + } + return true; +}; + +/** + * Checks if an element has the specified CSS class. + * Similar to Closure's goog.dom.classes.has, except it handles SVG elements. + * @param {!Element} element DOM element to check. + * @param {string} className Name of class to check. + * @return {boolean} True if class exists, false otherwise. + */ +Blockly.utils.dom.hasClass = function(element, className) { + var classes = element.getAttribute('class'); + return (' ' + classes + ' ').indexOf(' ' + className + ' ') != -1; +}; + +/** + * Removes a node from its parent. No-op if not attached to a parent. + * @param {Node} node The node to remove. + * @return {Node} The node removed if removed; else, null. + */ +// Copied from Closure goog.dom.removeNode +Blockly.utils.dom.removeNode = function(node) { + return node && node.parentNode ? node.parentNode.removeChild(node) : null; +}; + +/** + * Insert a node after a reference node. + * Contrast with node.insertBefore function. + * @param {!Element} newNode New element to insert. + * @param {!Element} refNode Existing element to precede new node. + */ +Blockly.utils.dom.insertAfter = function(newNode, refNode) { + var siblingNode = refNode.nextSibling; + var parentNode = refNode.parentNode; + if (!parentNode) { + throw Error('Reference node has no parent.'); + } + if (siblingNode) { + parentNode.insertBefore(newNode, siblingNode); + } else { + parentNode.appendChild(newNode); + } +}; + +/** + * Whether a node contains another node. + * @param {!Node} parent The node that should contain the other node. + * @param {!Node} descendant The node to test presence of. + * @return {boolean} Whether the parent node contains the descendant node. + */ +Blockly.utils.dom.containsNode = function(parent, descendant) { + return !!(parent.compareDocumentPosition(descendant) & + Node.DOCUMENT_POSITION_CONTAINED_BY); +}; + +/** + * Sets the CSS transform property on an element. This function sets the + * non-vendor-prefixed and vendor-prefixed versions for backwards compatibility + * with older browsers. See https://caniuse.com/#feat=transforms2d + * @param {!Element} element Element to which the CSS transform will be applied. + * @param {string} transform The value of the CSS `transform` property. + */ +Blockly.utils.dom.setCssTransform = function(element, transform) { + element.style['transform'] = transform; + element.style['-webkit-transform'] = transform; +}; diff --git a/core/utils/math.js b/core/utils/math.js new file mode 100644 index 00000000000..7a8cc3ff00d --- /dev/null +++ b/core/utils/math.js @@ -0,0 +1,70 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Utility methods for math. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @author fraser@google.com (Neil Fraser) + */ +'use strict'; + +/** + * @name Blockly.utils.math + * @namespace + */ +goog.provide('Blockly.utils.math'); + + +/** + * Converts degrees to radians. + * Copied from Closure's goog.math.toRadians. + * @param {number} angleDegrees Angle in degrees. + * @return {number} Angle in radians. + */ +Blockly.utils.math.toRadians = function(angleDegrees) { + return angleDegrees * Math.PI / 180; +}; + +/** + * Converts radians to degrees. + * Copied from Closure's goog.math.toDegrees. + * @param {number} angleRadians Angle in radians. + * @return {number} Angle in degrees. + */ +Blockly.utils.math.toDegrees = function(angleRadians) { + return angleRadians * 180 / Math.PI; +}; + +/** + * Clamp the provided number between the lower bound and the upper bound. + * @param {number} lowerBound The desired lower bound. + * @param {number} number The number to clamp. + * @param {number} upperBound The desired upper bound. + * @return {number} The clamped number. + */ +Blockly.utils.math.clamp = function(lowerBound, number, upperBound) { + if (upperBound < lowerBound) { + var temp = upperBound; + upperBound = lowerBound; + lowerBound = temp; + } + return Math.max(lowerBound, Math.min(number, upperBound)); +}; diff --git a/core/utils/rect.js b/core/utils/rect.js new file mode 100644 index 00000000000..ff09cd44fa8 --- /dev/null +++ b/core/utils/rect.js @@ -0,0 +1,68 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Utility methods for rectangle manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @author fraser@google.com (Neil Fraser) + */ +'use strict'; + +/** + * @name Blockly.utils.Rect + * @namespace + */ +goog.provide('Blockly.utils.Rect'); + + +/** + * Class for representing rectangular regions. + * @param {number} top Top. + * @param {number} bottom Bottom. + * @param {number} left Left. + * @param {number} right Right. + * @struct + * @constructor + */ +Blockly.utils.Rect = function(top, bottom, left, right) { + /** @type {number} */ + this.top = top; + + /** @type {number} */ + this.bottom = bottom; + + /** @type {number} */ + this.left = left; + + /** @type {number} */ + this.right = right; +}; + +/** + * Tests whether this rectangle contains a x/y coordinate. + * + * @param {number} x The x coordinate to test for containment. + * @param {number} y The y coordinate to test for containment. + * @return {boolean} Whether this rectangle contains given coordinate. + */ +Blockly.utils.Rect.prototype.contains = function(x, y) { + return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom; +}; diff --git a/core/utils/string.js b/core/utils/string.js new file mode 100644 index 00000000000..75425f7071c --- /dev/null +++ b/core/utils/string.js @@ -0,0 +1,298 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Utility methods for string manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @author fraser@google.com (Neil Fraser) + */ +'use strict'; + +/** + * @name Blockly.utils.string + * @namespace + */ +goog.provide('Blockly.utils.string'); + + +/** + * Fast prefix-checker. + * Copied from Closure's goog.string.startsWith. + * @param {string} str The string to check. + * @param {string} prefix A string to look for at the start of `str`. + * @return {boolean} True if `str` begins with `prefix`. + */ +Blockly.utils.string.startsWith = function(str, prefix) { + return str.lastIndexOf(prefix, 0) == 0; +}; + +/** + * Given an array of strings, return the length of the shortest one. + * @param {!Array.} array Array of strings. + * @return {number} Length of shortest string. + */ +Blockly.utils.string.shortestStringLength = function(array) { + if (!array.length) { + return 0; + } + return array.reduce(function(a, b) { + return a.length < b.length ? a : b; + }).length; +}; + +/** + * Given an array of strings, return the length of the common prefix. + * Words may not be split. Any space after a word is included in the length. + * @param {!Array.} array Array of strings. + * @param {number=} opt_shortest Length of shortest string. + * @return {number} Length of common prefix. + */ +Blockly.utils.string.commonWordPrefix = function(array, opt_shortest) { + if (!array.length) { + return 0; + } else if (array.length == 1) { + return array[0].length; + } + var wordPrefix = 0; + var max = opt_shortest || Blockly.utils.string.shortestStringLength(array); + for (var len = 0; len < max; len++) { + var letter = array[0][len]; + for (var i = 1; i < array.length; i++) { + if (letter != array[i][len]) { + return wordPrefix; + } + } + if (letter == ' ') { + wordPrefix = len + 1; + } + } + for (var i = 1; i < array.length; i++) { + var letter = array[i][len]; + if (letter && letter != ' ') { + return wordPrefix; + } + } + return max; +}; + +/** + * Given an array of strings, return the length of the common suffix. + * Words may not be split. Any space after a word is included in the length. + * @param {!Array.} array Array of strings. + * @param {number=} opt_shortest Length of shortest string. + * @return {number} Length of common suffix. + */ +Blockly.utils.string.commonWordSuffix = function(array, opt_shortest) { + if (!array.length) { + return 0; + } else if (array.length == 1) { + return array[0].length; + } + var wordPrefix = 0; + var max = opt_shortest || Blockly.utils.string.shortestStringLength(array); + for (var len = 0; len < max; len++) { + var letter = array[0].substr(-len - 1, 1); + for (var i = 1; i < array.length; i++) { + if (letter != array[i].substr(-len - 1, 1)) { + return wordPrefix; + } + } + if (letter == ' ') { + wordPrefix = len + 1; + } + } + for (var i = 1; i < array.length; i++) { + var letter = array[i].charAt(array[i].length - len - 1); + if (letter && letter != ' ') { + return wordPrefix; + } + } + return max; +}; + +/** + * Wrap text to the specified width. + * @param {string} text Text to wrap. + * @param {number} limit Width to wrap each line. + * @return {string} Wrapped text. + */ +Blockly.utils.string.wrap = function(text, limit) { + var lines = text.split('\n'); + for (var i = 0; i < lines.length; i++) { + lines[i] = Blockly.utils.string.wrapLine_(lines[i], limit); + } + return lines.join('\n'); +}; + +/** + * Wrap single line of text to the specified width. + * @param {string} text Text to wrap. + * @param {number} limit Width to wrap each line. + * @return {string} Wrapped text. + * @private + */ +Blockly.utils.string.wrapLine_ = function(text, limit) { + if (text.length <= limit) { + // Short text, no need to wrap. + return text; + } + // Split the text into words. + var words = text.trim().split(/\s+/); + // Set limit to be the length of the largest word. + for (var i = 0; i < words.length; i++) { + if (words[i].length > limit) { + limit = words[i].length; + } + } + + var lastScore; + var score = -Infinity; + var lastText; + var lineCount = 1; + do { + lastScore = score; + lastText = text; + // Create a list of booleans representing if a space (false) or + // a break (true) appears after each word. + var wordBreaks = []; + // Seed the list with evenly spaced linebreaks. + var steps = words.length / lineCount; + var insertedBreaks = 1; + for (var i = 0; i < words.length - 1; i++) { + if (insertedBreaks < (i + 1.5) / steps) { + insertedBreaks++; + wordBreaks[i] = true; + } else { + wordBreaks[i] = false; + } + } + wordBreaks = Blockly.utils.string.wrapMutate_(words, wordBreaks, limit); + score = Blockly.utils.string.wrapScore_(words, wordBreaks, limit); + text = Blockly.utils.string.wrapToText_(words, wordBreaks); + lineCount++; + } while (score > lastScore); + return lastText; +}; + +/** + * Compute a score for how good the wrapping is. + * @param {!Array.} words Array of each word. + * @param {!Array.} wordBreaks Array of line breaks. + * @param {number} limit Width to wrap each line. + * @return {number} Larger the better. + * @private + */ +Blockly.utils.string.wrapScore_ = function(words, wordBreaks, limit) { + // If this function becomes a performance liability, add caching. + // Compute the length of each line. + var lineLengths = [0]; + var linePunctuation = []; + for (var i = 0; i < words.length; i++) { + lineLengths[lineLengths.length - 1] += words[i].length; + if (wordBreaks[i] === true) { + lineLengths.push(0); + linePunctuation.push(words[i].charAt(words[i].length - 1)); + } else if (wordBreaks[i] === false) { + lineLengths[lineLengths.length - 1]++; + } + } + var maxLength = Math.max.apply(Math, lineLengths); + + var score = 0; + for (var i = 0; i < lineLengths.length; i++) { + // Optimize for width. + // -2 points per char over limit (scaled to the power of 1.5). + score -= Math.pow(Math.abs(limit - lineLengths[i]), 1.5) * 2; + // Optimize for even lines. + // -1 point per char smaller than max (scaled to the power of 1.5). + score -= Math.pow(maxLength - lineLengths[i], 1.5); + // Optimize for structure. + // Add score to line endings after punctuation. + if ('.?!'.indexOf(linePunctuation[i]) != -1) { + score += limit / 3; + } else if (',;)]}'.indexOf(linePunctuation[i]) != -1) { + score += limit / 4; + } + } + // All else being equal, the last line should not be longer than the + // previous line. For example, this looks wrong: + // aaa bbb + // ccc ddd eee + if (lineLengths.length > 1 && lineLengths[lineLengths.length - 1] <= + lineLengths[lineLengths.length - 2]) { + score += 0.5; + } + return score; +}; + +/** + * Mutate the array of line break locations until an optimal solution is found. + * No line breaks are added or deleted, they are simply moved around. + * @param {!Array.} words Array of each word. + * @param {!Array.} wordBreaks Array of line breaks. + * @param {number} limit Width to wrap each line. + * @return {!Array.} New array of optimal line breaks. + * @private + */ +Blockly.utils.string.wrapMutate_ = function(words, wordBreaks, limit) { + var bestScore = Blockly.utils.string.wrapScore_(words, wordBreaks, limit); + var bestBreaks; + // Try shifting every line break forward or backward. + for (var i = 0; i < wordBreaks.length - 1; i++) { + if (wordBreaks[i] == wordBreaks[i + 1]) { + continue; + } + var mutatedWordBreaks = [].concat(wordBreaks); + mutatedWordBreaks[i] = !mutatedWordBreaks[i]; + mutatedWordBreaks[i + 1] = !mutatedWordBreaks[i + 1]; + var mutatedScore = + Blockly.utils.string.wrapScore_(words, mutatedWordBreaks, limit); + if (mutatedScore > bestScore) { + bestScore = mutatedScore; + bestBreaks = mutatedWordBreaks; + } + } + if (bestBreaks) { + // Found an improvement. See if it may be improved further. + return Blockly.utils.string.wrapMutate_(words, bestBreaks, limit); + } + // No improvements found. Done. + return wordBreaks; +}; + +/** + * Reassemble the array of words into text, with the specified line breaks. + * @param {!Array.} words Array of each word. + * @param {!Array.} wordBreaks Array of line breaks. + * @return {string} Plain text. + * @private + */ +Blockly.utils.string.wrapToText_ = function(words, wordBreaks) { + var text = []; + for (var i = 0; i < words.length; i++) { + text.push(words[i]); + if (wordBreaks[i] !== undefined) { + text.push(wordBreaks[i] ? '\n' : ' '); + } + } + return text.join(''); +}; + diff --git a/core/utils/svg_paths.js b/core/utils/svg_paths.js new file mode 100644 index 00000000000..3674830b9f2 --- /dev/null +++ b/core/utils/svg_paths.js @@ -0,0 +1,156 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Methods for creating parts of SVG path strings. See + * developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths + * @author fenichel@google.com (Rachel Fenichel) + */ +'use strict'; + +/** + * @name Blockly.utils.svgPaths + * @namespace + */ +goog.provide('Blockly.utils.svgPaths'); + + +/** + * Create a string representing the given x, y pair. It does not matter whether + * the coordinate is relative or absolute. The result has leading + * and trailing spaces, and separates the x and y coordinates with a comma but + * no space. + * @param {number} x The x coordinate. + * @param {number} y The y coordinate. + * @return {string} A string of the format ' x,y ' + * @public + */ +Blockly.utils.svgPaths.point = function(x, y) { + return ' ' + x + ',' + y + ' '; +}; + +/** + * Draw a curbic or quadratic curve. See + * developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Cubic_B%C3%A9zier_Curve + * These coordinates are unitless and hence in the user coordinate system. + * @param {string} command The command to use. + * Should be one of: c, C, s, S, q, Q. + * @param {string} points An array containing all of the points to pass to the + * curve command, in order. The points are represented as strings of the + * format ' x, y '. + * @return {string} A string defining one or more Bezier curves. See the MDN + * documentation for exact format. + * @public + */ +Blockly.utils.svgPaths.curve = function(command, points) { + return ' ' + command + points.join(''); +}; + +/** + * Move the cursor to the given position without drawing a line. + * The coordinates are absolute. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {number} x The absolute x coordinate. + * @param {number} y The absolute y coordinate. + * @return {string} A string of the format ' M x,y ' + * @public + */ +Blockly.utils.svgPaths.moveTo = function(x, y) { + return ' M ' + x + ',' + y + ' '; +}; + +/** + * Move the cursor to the given position without drawing a line. + * Coordinates are relative. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {number} dx The relative x coordinate. + * @param {number} dy The relative y coordinate. + * @return {string} A string of the format ' m dx,dy ' + * @public + */ +Blockly.utils.svgPaths.moveBy = function(dx, dy) { + return ' m ' + dx + ',' + dy + ' '; +}; + +/** + * Draw a line from the current point to the end point, which is the current + * point shifted by dx along the x-axis and dy along the y-axis. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {number} dx The relative x coordinate. + * @param {number} dy The relative y coordinate. + * @return {string} A string of the format ' l dx,dy ' + * @public + */ +Blockly.utils.svgPaths.lineTo = function(dx, dy) { + return ' l ' + dx + ',' + dy + ' '; +}; + +/** + * Draw multiple lines connecting all of the given points in order. This is + * equivalent to a series of 'l' commands. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {!Array.} points An array containing all of the points to + * draw lines to, in order. The points are represented as strings of the + * format ' dx,dy '. + * @return {string} A string of the format ' l (dx,dy)+ ' + * @public + */ +Blockly.utils.svgPaths.line = function(points) { + return ' l' + points.join(''); +}; + +/** + * Draw a horizontal or vertical line. + * The first argument specifies the direction and whether the given position is + * relative or absolute. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#LineTo_path_commands + * @param {string} command The command to prepend to the coordinate. This + * should be one of: V, v, H, h. + * @param {number} val The coordinate to pass to the command. It may be + * absolute or relative. + * @return {string} A string of the format ' command val ' + * @public + */ +Blockly.utils.svgPaths.lineOnAxis = function(command, val) { + return ' ' + command + ' ' + val + ' '; +}; + +/** + * Draw an elliptical arc curve. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Elliptical_Arc_Curve + * @param {string} command The command string. Either 'a' or 'A'. + * @param {string} flags The flag string. See the MDN documentation for a + * description and examples. + * @param {number} radius The radius of the arc to draw. + * @param {string} point The point to move the cursor to after drawing the arc, + * specified either in absolute or relative coordinates depending on the + * command. + * @return {string} A string of the format 'command radius radius flags point' + * @public + */ +Blockly.utils.svgPaths.arc = function(command, flags, radius, point) { + return command + ' ' + radius + ' ' + radius + ' ' + flags + point; +}; diff --git a/core/utils/useragent.js b/core/utils/useragent.js new file mode 100644 index 00000000000..56d95aa7fe0 --- /dev/null +++ b/core/utils/useragent.js @@ -0,0 +1,82 @@ +/** + * @license + * Visual Blocks Editor + * + * Copyright 2019 Google Inc. + * https://developers.google.com/blockly/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Useragent detection. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @author fraser@google.com (Neil Fraser) + */ +'use strict'; + +/** + * @name Blockly.utils.userAgent + * @namespace + */ +goog.provide('Blockly.utils.userAgent'); + + +(function(raw) { + Blockly.utils.userAgent.raw = raw; + var rawUpper = Blockly.utils.userAgent.raw.toUpperCase(); + /** + * Case-insensitive test of whether name is in the useragent string. + * @param {string} name Name to test. + * @return {boolean} True if name is present. + */ + function has(name) { + return rawUpper.indexOf(name.toUpperCase()) != -1; + } + + // Browsers. Logic from: + // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/browser.js + Blockly.utils.userAgent.IE = has('Trident') || has('MSIE'); + Blockly.utils.userAgent.EDGE = has('Edge'); + // Useragent for JavaFX: + // Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.44 + // (KHTML, like Gecko) JavaFX/8.0 Safari/537.44 + Blockly.utils.userAgent.JAVA_FX = has('JavaFX'); + + // Engines. Logic from: + // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/engine.js + Blockly.utils.userAgent.WEBKIT = has('WebKit') && + !Blockly.utils.userAgent.EDGE; + Blockly.utils.userAgent.GECKO = has('Gecko') && + !Blockly.utils.userAgent.WEBKIT && + !Blockly.utils.userAgent.IE && + !Blockly.utils.userAgent.EDGE; + + // Platforms. Logic from: + // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/platform.js + Blockly.utils.userAgent.ANDROID = has('Android'); + Blockly.utils.userAgent.IPAD = has('iPad'); + Blockly.utils.userAgent.IPOD = has('iPod'); + Blockly.utils.userAgent.IPHONE = has('iPhone') && + !Blockly.utils.userAgent.IPAD && !Blockly.utils.userAgent.IPOD; + Blockly.utils.userAgent.MAC = has('Macintosh'); + + // Devices. Logic from: + // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/device.js + Blockly.utils.userAgent.TABLET = Blockly.utils.userAgent.IPAD || + (Blockly.utils.userAgent.ANDROID && !has('Mobile')) || has('Silk'); + Blockly.utils.userAgent.MOBILE = !Blockly.utils.userAgent.TABLET && + (Blockly.utils.userAgent.IPOD || Blockly.utils.userAgent.IPHONE || + Blockly.utils.userAgent.ANDROID || has('IEMobile')); +})((this.navigator && this.navigator.userAgent) || ''); diff --git a/core/xml_utils.js b/core/utils/xml.js similarity index 73% rename from core/xml_utils.js rename to core/utils/xml.js index 0e1a3d4a175..87854714c65 100644 --- a/core/xml_utils.js +++ b/core/utils/xml.js @@ -20,36 +20,41 @@ /** * @fileoverview XML element manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. * @author fraser@google.com (Neil Fraser) */ 'use strict'; /** - * @name Blockly.Xml.utils + * @name Blockly.utils.xml * @namespace */ -goog.provide('Blockly.Xml.utils'); +goog.provide('Blockly.utils.xml'); +/** + * Namespace for Blockly's XML. + */ +Blockly.utils.xml.NAME_SPACE = 'https://developers.google.com/blockly/xml'; /** * Create DOM element for XML. * @param {string} tagName Name of DOM element. * @return {!Element} New DOM element. - * @package + * @public */ -Blockly.Xml.utils.createElement = function(tagName) { - // TODO (#1978): Namespace this element. +Blockly.utils.xml.createElement = function(tagName) { // TODO (#2082): Support node.js. - return document.createElement(tagName); + return document.createElementNS(Blockly.utils.xml.NAME_SPACE, tagName); }; /** * Create text element for XML. * @param {string} text Text content. * @return {!Node} New DOM node. - * @package + * @public */ -Blockly.Xml.utils.createTextNode = function(text) { +Blockly.utils.xml.createTextNode = function(text) { // TODO (#2082): Support node.js. return document.createTextNode(text); }; @@ -58,11 +63,11 @@ Blockly.Xml.utils.createTextNode = function(text) { * Converts an XML string into a DOM tree. This method will be overridden in * the Node.js build of Blockly. See gulpfile.js, blockly_javascript_en task. * @param {string} text XML string. - * @return {!Element} The DOM document. + * @return {Document} The DOM document. * @throws if XML doesn't parse. - * @package + * @public */ -Blockly.Xml.utils.textToDomDocument = function(text) { +Blockly.utils.xml.textToDomDocument = function(text) { var oParser = new DOMParser(); return oParser.parseFromString(text, 'text/xml'); }; @@ -72,9 +77,9 @@ Blockly.Xml.utils.textToDomDocument = function(text) { * Currently the text format is fairly ugly: all one line with no whitespace. * @param {!Element} dom A tree of XML elements. * @return {string} Text representation. - * @package + * @public */ -Blockly.Xml.utils.domToText = function(dom) { +Blockly.utils.xml.domToText = function(dom) { // TODO (#2082): Support node.js. var oSerializer = new XMLSerializer(); return oSerializer.serializeToString(dom); diff --git a/core/variable_map.js b/core/variable_map.js index 642cf6a95c4..aeb5adcbaac 100644 --- a/core/variable_map.js +++ b/core/variable_map.js @@ -26,8 +26,10 @@ goog.provide('Blockly.VariableMap'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.VarDelete'); goog.require('Blockly.Events.VarRename'); +goog.require('Blockly.Msg'); goog.require('Blockly.utils'); @@ -46,7 +48,7 @@ Blockly.VariableMap = function(workspace) { * @type {!Object.>} * @private */ - this.variableMap_ = {}; + this.variableMap_ = Object.create(null); /** * The workspace this map belongs to. @@ -59,7 +61,7 @@ Blockly.VariableMap = function(workspace) { * Clear the variable map. */ Blockly.VariableMap.prototype.clear = function() { - this.variableMap_ = new Object(null); + this.variableMap_ = Object.create(null); }; /* Begin functions for renaming variables. */ @@ -164,10 +166,10 @@ Blockly.VariableMap.prototype.renameVariableWithConflict_ = function(variable, * Create a variable with a given name, optional type, and optional ID. * @param {string} name The name of the variable. This must be unique across * variables and procedures. - * @param {string=} opt_type The type of the variable like 'int' or 'string'. + * @param {?string=} opt_type The type of the variable like 'int' or 'string'. * Does not need to be unique. Field_variable can filter variables based on * their type. This will default to '' which is a specific type. - * @param {string=} opt_id The unique ID of the variable. This will default to + * @param {?string=} opt_id The unique ID of the variable. This will default to * a UUID. * @return {Blockly.VariableModel} The newly created variable. */ @@ -186,17 +188,18 @@ Blockly.VariableMap.prototype.createVariable = function(name, if (opt_id && this.getVariableById(opt_id)) { throw Error('Variable id, "' + opt_id + '", is already in use.'); } - opt_id = opt_id || Blockly.utils.genUid(); - opt_type = opt_type || ''; + var id = opt_id || Blockly.utils.genUid(); + var type = opt_type || ''; + variable = new Blockly.VariableModel(this.workspace, name, type, id); + + var variables = this.variableMap_[type] || []; + variables.push(variable); + // Delete the list of variables of this type, and re-add it so that + // the most recent addition is at the end. + // This is used so the toolbox's set block is set to the most recent variable. + delete this.variableMap_[type]; + this.variableMap_[type] = variables; - variable = new Blockly.VariableModel(this.workspace, name, opt_type, opt_id); - // If opt_type is not a key, create a new list. - if (!this.variableMap_[opt_type]) { - this.variableMap_[opt_type] = [variable]; - } else { - // Else append the variable to the preexisting list. - this.variableMap_[opt_type].push(variable); - } return variable; }; @@ -346,12 +349,20 @@ Blockly.VariableMap.prototype.getVariablesOfType = function(type) { }; /** - * Return all variable types. This list always contains the empty string. + * Return all variable and potential variable types. This list always contains + * the empty string. + * @param {?Blockly.Workspace} ws The workspace used to look for potential + * variables. This can be different than the workspace stored on this object + * if the passed in ws is a flyout workspace. * @return {!Array.} List of variable types. * @package */ -Blockly.VariableMap.prototype.getVariableTypes = function() { - var types = Object.keys(this.variableMap_); +Blockly.VariableMap.prototype.getVariableTypes = function(ws) { + var potentialTypes = []; + if (ws && ws.getPotentialVariableMap()) { + potentialTypes = Object.keys(ws.getPotentialVariableMap().variableMap_); + } + var types = Object.keys(this.variableMap_).concat(potentialTypes); var hasEmpty = false; for (var i = 0; i < types.length; i++) { if (types[i] == '') { @@ -370,9 +381,8 @@ Blockly.VariableMap.prototype.getVariableTypes = function() { */ Blockly.VariableMap.prototype.getAllVariables = function() { var all_variables = []; - var keys = Object.keys(this.variableMap_); - for (var i = 0; i < keys.length; i++ ) { - all_variables = all_variables.concat(this.variableMap_[keys[i]]); + for (var key in this.variableMap_) { + all_variables = all_variables.concat(this.variableMap_[key]); } return all_variables; }; diff --git a/core/variable_model.js b/core/variable_model.js index e41dd209172..af1230ed71e 100644 --- a/core/variable_model.js +++ b/core/variable_model.js @@ -26,6 +26,7 @@ goog.provide('Blockly.VariableModel'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.VarCreate'); goog.require('Blockly.utils'); diff --git a/core/variables.js b/core/variables.js index cec5132fe39..26f117182d5 100644 --- a/core/variables.js +++ b/core/variables.js @@ -31,13 +31,11 @@ goog.provide('Blockly.Variables'); goog.require('Blockly.Blocks'); -goog.require('Blockly.constants'); +goog.require('Blockly.Msg'); +goog.require('Blockly.utils.xml'); goog.require('Blockly.VariableModel'); -goog.require('Blockly.Workspace'); goog.require('Blockly.Xml'); -goog.require('goog.string'); - /** * Constant to separate variable names from procedures and generated functions @@ -171,44 +169,38 @@ Blockly.Variables.flyoutCategoryBlocks = function(workspace) { var xmlList = []; if (variableModelList.length > 0) { // New variables are added to the end of the variableModelList. - var mostRecentVariableFieldXmlString = - Blockly.Variables.generateVariableFieldXmlString( - variableModelList[variableModelList.length - 1]); + var mostRecentVariable = variableModelList[variableModelList.length - 1]; if (Blockly.Blocks['variables_set']) { - var gap = Blockly.Blocks['math_change'] ? 8 : 24; - var blockText = '' + - '' + - mostRecentVariableFieldXmlString + - '' + - ''; - var block = Blockly.Xml.textToDom(blockText).firstChild; + var block = Blockly.utils.xml.createElement('block'); + block.setAttribute('type', 'variables_set'); + block.setAttribute('gap', Blockly.Blocks['math_change'] ? 8 : 24); + block.appendChild( + Blockly.Variables.generateVariableFieldDom(mostRecentVariable)); xmlList.push(block); } if (Blockly.Blocks['math_change']) { - var gap = Blockly.Blocks['variables_get'] ? 20 : 8; - var blockText = '' + - '' + - mostRecentVariableFieldXmlString + + var block = Blockly.utils.xml.createElement('block'); + block.setAttribute('type', 'math_change'); + block.setAttribute('gap', Blockly.Blocks['variables_get'] ? 20 : 8); + block.appendChild( + Blockly.Variables.generateVariableFieldDom(mostRecentVariable)); + var value = Blockly.Xml.textToDom( '' + '' + '1' + '' + - '' + - '' + - ''; - var block = Blockly.Xml.textToDom(blockText).firstChild; + ''); + block.appendChild(value); xmlList.push(block); } if (Blockly.Blocks['variables_get']) { variableModelList.sort(Blockly.VariableModel.compareByName); for (var i = 0, variable; variable = variableModelList[i]; i++) { - var blockText = '' + - '' + - Blockly.Variables.generateVariableFieldXmlString(variable) + - '' + - ''; - var block = Blockly.Xml.textToDom(blockText).firstChild; + var block = Blockly.utils.xml.createElement('block'); + block.setAttribute('type', 'variables_get'); + block.setAttribute('gap', 8); + block.appendChild(Blockly.Variables.generateVariableFieldDom(variable)); xmlList.push(block); } } @@ -267,7 +259,7 @@ Blockly.Variables.generateUniqueName = function(workspace) { /** * Handles "Create Variable" button in the default variables toolbox category. - * It will prompt the user for a varibale name, including re-prompts if a name + * It will prompt the user for a variable name, including re-prompts if a name * is already in use among the workspace's variables. * * Custom button handlers can delegate to this function, allowing variables @@ -400,7 +392,7 @@ Blockly.Variables.promptName = function(promptText, defaultText, callback) { // Merge runs of whitespace. Strip leading and trailing whitespace. // Beyond this, all names are legal. if (newVar) { - newVar = newVar.replace(/[\s\xa0]+/g, ' ').replace(/^ | $/g, ''); + newVar = newVar.replace(/[\s\xa0]+/g, ' ').trim(); if (newVar == Blockly.Msg['RENAME_VARIABLE'] || newVar == Blockly.Msg['NEW_VARIABLE']) { // Ok, not ALL names are legal... @@ -455,26 +447,6 @@ Blockly.Variables.nameUsedWithAnyType_ = function(name, workspace) { return null; }; -/** - * Generate XML string for variable field. - * @param {!Blockly.VariableModel} variableModel The variable model to generate - * an XML string from. - * @return {string} The generated XML. - * @package - */ -Blockly.Variables.generateVariableFieldXmlString = function(variableModel) { - // The variable name may be user input, so it may contain characters that - // need to be escaped to create valid XML. - var typeString = variableModel.type; - if (typeString == '') { - typeString = '\'\''; - } - var text = '' + goog.string.htmlEscape(variableModel.name) + ''; - return text; -}; - /** * Generate DOM objects representing a variable field. * @param {!Blockly.VariableModel} variableModel The variable model to @@ -483,12 +455,16 @@ Blockly.Variables.generateVariableFieldXmlString = function(variableModel) { * @public */ Blockly.Variables.generateVariableFieldDom = function(variableModel) { - var xmlFieldString = - Blockly.Variables.generateVariableFieldXmlString(variableModel); - var text = '' + xmlFieldString + ''; - var dom = Blockly.Xml.textToDom(text); - var fieldDom = dom.firstChild; - return fieldDom; + /* Generates the following XML: + * foo + */ + var field = Blockly.utils.xml.createElement('field'); + field.setAttribute('name', 'VAR'); + field.setAttribute('id', variableModel.getId()); + field.setAttribute('variabletype', variableModel.type); + var name = Blockly.utils.xml.createTextNode(variableModel.name); + field.appendChild(name); + return field; }; /** @@ -527,7 +503,7 @@ Blockly.Variables.getOrCreateVariablePackage = function(workspace, id, opt_name, * Only used if lookup by ID fails. * @return {Blockly.VariableModel} The variable corresponding to the given ID * or name + type combination, or null if not found. - * @package + * @public */ Blockly.Variables.getVariable = function(workspace, id, opt_name, opt_type) { var potentialVariableMap = workspace.getPotentialVariableMap(); diff --git a/core/variables_dynamic.js b/core/variables_dynamic.js index d09c2aa0c74..a17c79e2a82 100644 --- a/core/variables_dynamic.js +++ b/core/variables_dynamic.js @@ -29,10 +29,9 @@ goog.provide('Blockly.VariablesDynamic'); goog.require('Blockly.Variables'); goog.require('Blockly.Blocks'); -goog.require('Blockly.constants'); +goog.require('Blockly.Msg'); +goog.require('Blockly.utils.xml'); goog.require('Blockly.VariableModel'); -// TODO Fix circular dependencies -// goog.require('Blockly.Workspace'); goog.require('Blockly.Xml'); @@ -94,24 +93,20 @@ Blockly.VariablesDynamic.flyoutCategoryBlocks = function(workspace) { if (variableModelList.length > 0) { if (Blockly.Blocks['variables_set_dynamic']) { var firstVariable = variableModelList[variableModelList.length - 1]; - var gap = 24; - var blockText = '' + - '' + - Blockly.Variables.generateVariableFieldXmlString(firstVariable) + - '' + - ''; - var block = Blockly.Xml.textToDom(blockText).firstChild; + var block = Blockly.utils.xml.createElement('block'); + block.setAttribute('type', 'variables_set_dynamic'); + block.setAttribute('gap', 24); + block.appendChild( + Blockly.Variables.generateVariableFieldDom(firstVariable)); xmlList.push(block); } if (Blockly.Blocks['variables_get_dynamic']) { variableModelList.sort(Blockly.VariableModel.compareByName); for (var i = 0, variable; variable = variableModelList[i]; i++) { - var blockText = '' + - '' + - Blockly.Variables.generateVariableFieldXmlString(variable) + - '' + - ''; - var block = Blockly.Xml.textToDom(blockText).firstChild; + var block = Blockly.utils.xml.createElement('block'); + block.setAttribute('type', 'variables_get_dynamic'); + block.setAttribute('gap', 8); + block.appendChild(Blockly.Variables.generateVariableFieldDom(variable)); xmlList.push(block); } } diff --git a/core/warning.js b/core/warning.js index 9ae3c7ea031..dae39898c54 100644 --- a/core/warning.js +++ b/core/warning.js @@ -27,9 +27,10 @@ goog.provide('Blockly.Warning'); goog.require('Blockly.Bubble'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.Icon'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); /** @@ -58,7 +59,7 @@ Blockly.Warning.prototype.collapseHidden = false; */ Blockly.Warning.prototype.drawIcon_ = function(group) { // Triangle with rounded corners. - Blockly.utils.createSvgElement('path', + Blockly.utils.dom.createSvgElement('path', { 'class': 'blocklyIconShape', 'd': 'M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z' @@ -67,14 +68,14 @@ Blockly.Warning.prototype.drawIcon_ = function(group) { // Can't use a real '!' text character since different browsers and operating // systems render it differently. // Body of exclamation point. - Blockly.utils.createSvgElement('path', + Blockly.utils.dom.createSvgElement('path', { 'class': 'blocklyIconSymbol', 'd': 'm7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z' }, group); // Dot of exclamation point. - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', { 'class': 'blocklyIconSymbol', 'x': '7', 'y': '11', 'height': '2', 'width': '2' @@ -90,7 +91,7 @@ Blockly.Warning.prototype.drawIcon_ = function(group) { */ Blockly.Warning.textToDom_ = function(text) { var paragraph = /** @type {!SVGTextElement} */ - (Blockly.utils.createSvgElement( + (Blockly.utils.dom.createSvgElement( 'text', { 'class': 'blocklyText blocklyBubbleText', @@ -100,7 +101,7 @@ Blockly.Warning.textToDom_ = function(text) { ); var lines = text.split('\n'); for (var i = 0; i < lines.length; i++) { - var tspanElement = Blockly.utils.createSvgElement('tspan', + var tspanElement = Blockly.utils.dom.createSvgElement('tspan', {'dy': '1em', 'x': Blockly.Bubble.BORDER_WIDTH}, paragraph); var textNode = document.createTextNode(lines[i]); tspanElement.appendChild(textNode); diff --git a/core/widgetdiv.js b/core/widgetdiv.js index 9fc80d82f37..4690b66ad04 100644 --- a/core/widgetdiv.js +++ b/core/widgetdiv.js @@ -33,6 +33,7 @@ goog.provide('Blockly.WidgetDiv'); goog.require('Blockly.Css'); + goog.require('goog.style'); diff --git a/core/workspace.js b/core/workspace.js index 4dd5d2a51a0..117804fe9ba 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -26,9 +26,12 @@ goog.provide('Blockly.Workspace'); +goog.require('Blockly.Events'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.math'); goog.require('Blockly.VariableMap'); goog.require('Blockly.WorkspaceComment'); +goog.require('Blockly.Themes.Classic'); /** @@ -111,6 +114,12 @@ Blockly.Workspace = function(opt_options) { * @private */ this.potentialVariableMap_ = null; + + // Set the default theme. This is for headless workspaces. This will get + // overwritten by the theme passed into the inject call for rendered workspaces. + if (!Blockly.getTheme()) { + Blockly.setTheme(Blockly.Themes.Classic); + } }; /** @@ -133,6 +142,12 @@ Blockly.Workspace.prototype.isClearing = false; */ Blockly.Workspace.prototype.MAX_UNDO = 1024; +/** + * Set of databases for rapid lookup of connection locations. + * @type {Array.} + */ +Blockly.Workspace.prototype.connectionDBList = null; + /** * Dispose of this workspace. * Unlink from all DOM elements to prevent memory leaks. @@ -199,7 +214,7 @@ Blockly.Workspace.prototype.getTopBlocks = function(ordered) { var blocks = [].concat(this.topBlocks_); if (ordered && blocks.length > 1) { this.sortObjects_.offset = - Math.sin(Blockly.utils.toRadians(Blockly.Workspace.SCAN_ANGLE)); + Math.sin(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)); if (this.RTL) { this.sortObjects_.offset *= -1; } @@ -245,7 +260,7 @@ Blockly.Workspace.prototype.getBlocksByType = function(type, ordered) { var blocks = this.typedBlocksDB_[type].slice(0); if (ordered && blocks.length > 1) { this.sortObjects_.offset = - Math.sign(Blockly.utils.toRadians(Blockly.Workspace.SCAN_ANGLE)); + Math.sign(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)); if (this.RTL) { this.sortObjects_.offset *= -1; } @@ -298,7 +313,7 @@ Blockly.Workspace.prototype.getTopComments = function(ordered) { var comments = [].concat(this.topComments_); if (ordered && comments.length > 1) { this.sortObjects_.offset = - Math.sin(Blockly.utils.toRadians(Blockly.Workspace.SCAN_ANGLE)); + Math.sin(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)); if (this.RTL) { this.sortObjects_.offset *= -1; } @@ -381,10 +396,10 @@ Blockly.Workspace.prototype.renameVariableById = function(id, newName) { * Create a variable with a given name, optional type, and optional ID. * @param {string} name The name of the variable. This must be unique across * variables and procedures. - * @param {string=} opt_type The type of the variable like 'int' or 'string'. + * @param {?string=} opt_type The type of the variable like 'int' or 'string'. * Does not need to be unique. Field_variable can filter variables based on * their type. This will default to '' which is a specific type. - * @param {string=} opt_id The unique ID of the variable. This will default to + * @param {?string=} opt_id The unique ID of the variable. This will default to * a UUID. * @return {Blockly.VariableModel} The newly created variable. */ @@ -476,7 +491,7 @@ Blockly.Workspace.prototype.getVariablesOfType = function(type) { * @package */ Blockly.Workspace.prototype.getVariableTypes = function() { - return this.variableMap_.getVariableTypes(); + return this.variableMap_.getVariableTypes(this); }; /** diff --git a/core/workspace_audio.js b/core/workspace_audio.js index 8b7089f9166..8e7029f4bc0 100644 --- a/core/workspace_audio.js +++ b/core/workspace_audio.js @@ -27,7 +27,8 @@ goog.provide('Blockly.WorkspaceAudio'); -goog.require('goog.userAgent'); +goog.require('Blockly.utils'); +goog.require('Blockly.utils.userAgent'); /** @@ -82,7 +83,7 @@ Blockly.WorkspaceAudio.prototype.load = function(filenames, name) { return; } try { - var audioTest = new window['Audio'](); + var audioTest = new Blockly.utils.global['Audio'](); } catch (e) { // No browser support for Audio. // IE can throw an error even if the Audio object exists. @@ -94,7 +95,7 @@ Blockly.WorkspaceAudio.prototype.load = function(filenames, name) { var ext = filename.match(/\.(\w+)$/); if (ext && audioTest.canPlayType('audio/' + ext[1])) { // Found an audio format we can play. - sound = new window['Audio'](filename); + sound = new Blockly.utils.global['Audio'](filename); break; } } @@ -115,7 +116,7 @@ Blockly.WorkspaceAudio.prototype.preload = function() { sound.pause(); // iOS can only process one sound at a time. Trying to load more than one // corrupts the earlier ones. Just load one and leave the others uncached. - if (goog.userAgent.IPAD || goog.userAgent.IPHONE) { + if (Blockly.utils.userAgent.IPAD || Blockly.utils.userAgent.IPHONE) { break; } } @@ -138,11 +139,9 @@ Blockly.WorkspaceAudio.prototype.play = function(name, opt_volume) { } this.lastSound_ = now; var mySound; - var ie9 = goog.userAgent.DOCUMENT_MODE && - goog.userAgent.DOCUMENT_MODE === 9; - if (ie9 || goog.userAgent.IPAD || goog.userAgent.ANDROID) { - // Creating a new audio node causes lag in IE9, Android and iPad. Android - // and IE9 refetch the file from the server, iPad uses a singleton audio + if (Blockly.utils.userAgent.IPAD || Blockly.utils.userAgent.ANDROID) { + // Creating a new audio node causes lag in Android and iPad. Android + // refetches the file from the server, iPad uses a singleton audio // node which must be deleted and recreated for each new audio tag. mySound = sound; } else { diff --git a/core/workspace_comment.js b/core/workspace_comment.js index fa1b7313077..ec9735c0c6d 100644 --- a/core/workspace_comment.js +++ b/core/workspace_comment.js @@ -26,14 +26,14 @@ goog.provide('Blockly.WorkspaceComment'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.CommentChange'); goog.require('Blockly.Events.CommentCreate'); goog.require('Blockly.Events.CommentDelete'); goog.require('Blockly.Events.CommentMove'); goog.require('Blockly.utils'); -goog.require('Blockly.Xml.utils'); - -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.xml'); /** @@ -56,10 +56,10 @@ Blockly.WorkspaceComment = function(workspace, content, height, width, opt_id) { /** * The comment's position in workspace units. (0, 0) is at the workspace's * origin; scale does not change this value. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @protected */ - this.xy_ = new goog.math.Coordinate(0, 0); + this.xy_ = new Blockly.utils.Coordinate(0, 0); /** * The comment's height in workspace units. Scale does not change this value. @@ -173,12 +173,12 @@ Blockly.WorkspaceComment.prototype.setWidth = function(width) { /** * Get stored location. - * @return {!goog.math.Coordinate} The comment's stored location. This is not - * valid if the comment is currently being dragged. + * @return {!Blockly.utils.Coordinate} The comment's stored location. + * This is not valid if the comment is currently being dragged. * @package */ Blockly.WorkspaceComment.prototype.getXY = function() { - return this.xy_.clone(); + return new Blockly.utils.Coordinate(this.xy_.x, this.xy_.y); }; /** @@ -278,9 +278,9 @@ Blockly.WorkspaceComment.prototype.toXmlWithXY = function(opt_noId) { * @package */ Blockly.WorkspaceComment.prototype.toXml = function(opt_noId) { - var commentElement = Blockly.Xml.utils.createElement('comment'); + var commentElement = Blockly.utils.xml.createElement('comment'); if (!opt_noId) { - commentElement.setAttribute('id', this.id); + commentElement.id = this.id; } commentElement.textContent = this.getContent(); return commentElement; diff --git a/core/workspace_comment_render_svg.js b/core/workspace_comment_render_svg.js index 51fb738bbc8..de5bdec3abb 100644 --- a/core/workspace_comment_render_svg.js +++ b/core/workspace_comment_render_svg.js @@ -27,10 +27,10 @@ goog.provide('Blockly.WorkspaceCommentSvg.render'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); goog.require('Blockly.WorkspaceCommentSvg'); -goog.require('goog.math.Coordinate'); - /** * Size of the resize icon. @@ -89,14 +89,14 @@ Blockly.WorkspaceCommentSvg.prototype.render = function() { this.createEditor_(); this.svgGroup_.appendChild(this.foreignObject_); - this.svgHandleTarget_ = Blockly.utils.createSvgElement('rect', + this.svgHandleTarget_ = Blockly.utils.dom.createSvgElement('rect', { 'class': 'blocklyCommentHandleTarget', 'x': 0, 'y': 0 }); this.svgGroup_.appendChild(this.svgHandleTarget_); - this.svgRectTarget_ = Blockly.utils.createSvgElement('rect', + this.svgRectTarget_ = Blockly.utils.dom.createSvgElement('rect', { 'class': 'blocklyCommentTarget', 'x': 0, @@ -150,7 +150,7 @@ Blockly.WorkspaceCommentSvg.prototype.createEditor_ = function() { */ - this.foreignObject_ = Blockly.utils.createSvgElement( + this.foreignObject_ = Blockly.utils.dom.createSvgElement( 'foreignObject', { 'x': 0, @@ -158,10 +158,10 @@ Blockly.WorkspaceCommentSvg.prototype.createEditor_ = function() { 'class': 'blocklyCommentForeignObject' }, null); - var body = document.createElementNS(Blockly.HTML_NS, 'body'); - body.setAttribute('xmlns', Blockly.HTML_NS); + var body = document.createElementNS(Blockly.utils.dom.HTML_NS, 'body'); + body.setAttribute('xmlns', Blockly.utils.dom.HTML_NS); body.className = 'blocklyMinimalBody'; - var textarea = document.createElementNS(Blockly.HTML_NS, 'textarea'); + var textarea = document.createElementNS(Blockly.utils.dom.HTML_NS, 'textarea'); textarea.className = 'blocklyCommentTextarea'; textarea.setAttribute('dir', this.RTL ? 'RTL' : 'LTR'); body.appendChild(textarea); @@ -184,25 +184,25 @@ Blockly.WorkspaceCommentSvg.prototype.createEditor_ = function() { * @private */ Blockly.WorkspaceCommentSvg.prototype.addResizeDom_ = function() { - this.resizeGroup_ = Blockly.utils.createSvgElement( + this.resizeGroup_ = Blockly.utils.dom.createSvgElement( 'g', { 'class': this.RTL ? 'blocklyResizeSW' : 'blocklyResizeSE' }, this.svgGroup_); var resizeSize = Blockly.WorkspaceCommentSvg.RESIZE_SIZE; - Blockly.utils.createSvgElement( + Blockly.utils.dom.createSvgElement( 'polygon', {'points': '0,x x,x x,0'.replace(/x/g, resizeSize.toString())}, this.resizeGroup_); - Blockly.utils.createSvgElement( + Blockly.utils.dom.createSvgElement( 'line', { 'class': 'blocklyResizeLine', 'x1': resizeSize / 3, 'y1': resizeSize - 1, 'x2': resizeSize - 1, 'y2': resizeSize / 3 }, this.resizeGroup_); - Blockly.utils.createSvgElement( + Blockly.utils.dom.createSvgElement( 'line', { 'class': 'blocklyResizeLine', @@ -216,13 +216,13 @@ Blockly.WorkspaceCommentSvg.prototype.addResizeDom_ = function() { * @private */ Blockly.WorkspaceCommentSvg.prototype.addDeleteDom_ = function() { - this.deleteGroup_ = Blockly.utils.createSvgElement( + this.deleteGroup_ = Blockly.utils.dom.createSvgElement( 'g', { 'class': 'blocklyCommentDeleteIcon' }, this.svgGroup_); - this.deleteIconBorder_ = Blockly.utils.createSvgElement('circle', + this.deleteIconBorder_ = Blockly.utils.dom.createSvgElement('circle', { 'class': 'blocklyDeleteIconShape', 'r': '7', @@ -231,7 +231,7 @@ Blockly.WorkspaceCommentSvg.prototype.addDeleteDom_ = function() { }, this.deleteGroup_); // x icon. - Blockly.utils.createSvgElement( + Blockly.utils.dom.createSvgElement( 'line', { 'x1': '5', 'y1': '10', @@ -240,7 +240,7 @@ Blockly.WorkspaceCommentSvg.prototype.addDeleteDom_ = function() { 'stroke-width': '2' }, this.deleteGroup_); - Blockly.utils.createSvgElement( + Blockly.utils.dom.createSvgElement( 'line', { 'x1': '5', 'y1': '5', @@ -265,7 +265,7 @@ Blockly.WorkspaceCommentSvg.prototype.resizeMouseDown_ = function(e) { return; } // Left-click (or middle click) - this.workspace.startDrag(e, new goog.math.Coordinate( + this.workspace.startDrag(e, new Blockly.utils.Coordinate( this.workspace.RTL ? -this.width_ : this.width_, this.height_)); this.onMouseUpWrapper_ = Blockly.bindEventWithChecks_( @@ -284,7 +284,7 @@ Blockly.WorkspaceCommentSvg.prototype.resizeMouseDown_ = function(e) { */ Blockly.WorkspaceCommentSvg.prototype.deleteMouseDown_ = function(e) { // Highlight the delete icon. - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.deleteIconBorder_), 'blocklyDeleteIconHighlighted'); // This event has been handled. No need to bubble up to the document. @@ -293,12 +293,12 @@ Blockly.WorkspaceCommentSvg.prototype.deleteMouseDown_ = function(e) { /** * Handle a mouse-out on comment's delete icon. - * @param {!Event} e Mouse out event. + * @param {!Event} _e Mouse out event. * @private */ -Blockly.WorkspaceCommentSvg.prototype.deleteMouseOut_ = function(/*e*/) { +Blockly.WorkspaceCommentSvg.prototype.deleteMouseOut_ = function(_e) { // Restore highlight on the delete icon. - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.deleteIconBorder_), 'blocklyDeleteIconHighlighted'); }; @@ -442,9 +442,9 @@ Blockly.WorkspaceCommentSvg.prototype.setFocus = function() { } comment.textarea_.focus(); comment.addFocus(); - Blockly.utils.addClass( + Blockly.utils.dom.addClass( comment.svgRectTarget_, 'blocklyCommentTargetFocused'); - Blockly.utils.addClass( + Blockly.utils.dom.addClass( comment.svgHandleTarget_, 'blocklyCommentHandleTargetFocused'); }, 0); }; @@ -464,9 +464,9 @@ Blockly.WorkspaceCommentSvg.prototype.blurFocus = function() { comment.textarea_.blur(); comment.removeFocus(); - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( comment.svgRectTarget_, 'blocklyCommentTargetFocused'); - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( comment.svgHandleTarget_, 'blocklyCommentHandleTargetFocused'); }, 0); }; diff --git a/core/workspace_comment_svg.js b/core/workspace_comment_svg.js index 61a1655bf89..b93331c6aaa 100644 --- a/core/workspace_comment_svg.js +++ b/core/workspace_comment_svg.js @@ -26,14 +26,17 @@ goog.provide('Blockly.WorkspaceCommentSvg'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.CommentCreate'); goog.require('Blockly.Events.CommentDelete'); goog.require('Blockly.Events.CommentMove'); +goog.require('Blockly.Events.Ui'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.Rect'); goog.require('Blockly.WorkspaceComment'); -goog.require('goog.math.Coordinate'); - /** * Class for a workspace comment's SVG representation. @@ -53,11 +56,11 @@ Blockly.WorkspaceCommentSvg = function(workspace, content, height, width, * @type {SVGElement} * @private */ - this.svgGroup_ = Blockly.utils.createSvgElement( + this.svgGroup_ = Blockly.utils.dom.createSvgElement( 'g', {'class': 'blocklyComment'}, null); this.svgGroup_.translate_ = ''; - this.svgRect_ = Blockly.utils.createSvgElement( + this.svgRect_ = Blockly.utils.dom.createSvgElement( 'rect', { 'class': 'blocklyCommentRect', @@ -117,7 +120,7 @@ Blockly.WorkspaceCommentSvg.prototype.dispose = function() { Blockly.Events.fire(new Blockly.Events.CommentDelete(this)); } - Blockly.utils.removeNode(this.svgGroup_); + Blockly.utils.dom.removeNode(this.svgGroup_); // Sever JavaScript to DOM connections. this.svgGroup_ = null; this.svgRect_ = null; @@ -232,7 +235,7 @@ Blockly.WorkspaceCommentSvg.prototype.unselect = function() { * @package */ Blockly.WorkspaceCommentSvg.prototype.addSelect = function() { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklySelected'); this.setFocus(); }; @@ -242,7 +245,7 @@ Blockly.WorkspaceCommentSvg.prototype.addSelect = function() { * @package */ Blockly.WorkspaceCommentSvg.prototype.removeSelect = function() { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklySelected'); this.blurFocus(); }; @@ -252,7 +255,7 @@ Blockly.WorkspaceCommentSvg.prototype.removeSelect = function() { * @package */ Blockly.WorkspaceCommentSvg.prototype.addFocus = function() { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyFocused'); }; @@ -261,7 +264,7 @@ Blockly.WorkspaceCommentSvg.prototype.addFocus = function() { * @package */ Blockly.WorkspaceCommentSvg.prototype.removeFocus = function() { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyFocused'); }; @@ -271,7 +274,7 @@ Blockly.WorkspaceCommentSvg.prototype.removeFocus = function() { * If the comment is on the workspace, (0, 0) is the origin of the workspace * coordinate system. * This does not change with workspace scale. - * @return {!goog.math.Coordinate} Object with .x and .y properties in + * @return {!Blockly.utils.Coordinate} Object with .x and .y properties in * workspace coordinates. * @package */ @@ -302,7 +305,7 @@ Blockly.WorkspaceCommentSvg.prototype.getRelativeToSurfaceXY = function() { } while (element && element != this.workspace.getBubbleCanvas() && element != dragSurfaceGroup); } - this.xy_ = new goog.math.Coordinate(x, y); + this.xy_ = new Blockly.utils.Coordinate(x, y); return this.xy_; }; @@ -317,7 +320,7 @@ Blockly.WorkspaceCommentSvg.prototype.moveBy = function(dx, dy) { // TODO: Do I need to look up the relative to surface XY position here? var xy = this.getRelativeToSurfaceXY(); this.translate(xy.x + dx, xy.y + dy); - this.xy_ = new goog.math.Coordinate(xy.x + dx, xy.y + dy); + this.xy_ = new Blockly.utils.Coordinate(xy.x + dx, xy.y + dy); event.recordNew(); Blockly.Events.fire(event); this.workspace.resizeContents(); @@ -331,7 +334,7 @@ Blockly.WorkspaceCommentSvg.prototype.moveBy = function(dx, dy) { * @package */ Blockly.WorkspaceCommentSvg.prototype.translate = function(x, y) { - this.xy_ = new goog.math.Coordinate(x, y); + this.xy_ = new Blockly.utils.Coordinate(x, y); this.getSvgRoot().setAttribute('transform', 'translate(' + x + ',' + y + ')'); }; @@ -361,7 +364,7 @@ Blockly.WorkspaceCommentSvg.prototype.moveToDragSurface_ = function() { * Move this comment back to the workspace block canvas. * Generally should be called at the same time as setDragging(false). * Does nothing if useDragSurface_ is false. - * @param {!goog.math.Coordinate} newXY The position the comment should take on + * @param {!Blockly.utils.Coordinate} newXY The position the comment should take on * on the workspace canvas, in workspace coordinates. * @private */ @@ -379,7 +382,7 @@ Blockly.WorkspaceCommentSvg.prototype.moveOffDragSurface_ = function(newXY) { * drag surface to translate blocks. * @param {Blockly.BlockDragSurfaceSvg} dragSurface The surface that carries * rendered items during a drag, or null if no drag surface is in use. - * @param {!goog.math.Coordinate} newLoc The location to translate to, in + * @param {!Blockly.utils.Coordinate} newLoc The location to translate to, in * workspace coordinates. * @package */ @@ -410,37 +413,34 @@ Blockly.WorkspaceCommentSvg.prototype.moveTo = function(x, y) { * @private */ Blockly.WorkspaceCommentSvg.prototype.clearTransformAttributes_ = function() { - Blockly.utils.removeAttribute(this.getSvgRoot(), 'transform'); + this.getSvgRoot().removeAttribute('transform'); }; /** * Returns the coordinates of a bounding box describing the dimensions of this * comment. * Coordinate system: workspace coordinates. - * @return {!{topLeft: goog.math.Coordinate, bottomRight: goog.math.Coordinate}} - * Object with top left and bottom right coordinates of the bounding box. + * @return {!Blockly.utils.Rect} Object with coordinates of the bounding box. * @package */ Blockly.WorkspaceCommentSvg.prototype.getBoundingRectangle = function() { var blockXY = this.getRelativeToSurfaceXY(); var commentBounds = this.getHeightWidth(); - var topLeft; - var bottomRight; + var top = blockXY.y; + var bottom = blockXY.y + commentBounds.height; + var left, right; if (this.RTL) { - topLeft = new goog.math.Coordinate(blockXY.x - (commentBounds.width), - blockXY.y); + left = blockXY.x - commentBounds.width; // Add the width of the tab/puzzle piece knob to the x coordinate // since X is the corner of the rectangle, not the whole puzzle piece. - bottomRight = new goog.math.Coordinate(blockXY.x, - blockXY.y + commentBounds.height); + right = blockXY.x; } else { // Subtract the width of the tab/puzzle piece knob to the x coordinate // since X is the corner of the rectangle, not the whole puzzle piece. - topLeft = new goog.math.Coordinate(blockXY.x, blockXY.y); - bottomRight = new goog.math.Coordinate(blockXY.x + commentBounds.width, - blockXY.y + commentBounds.height); + left = blockXY.x; + right = blockXY.x + commentBounds.width; } - return {topLeft: topLeft, bottomRight: bottomRight}; + return new Blockly.utils.Rect(top, bottom, left, right); }; /** @@ -449,10 +449,10 @@ Blockly.WorkspaceCommentSvg.prototype.getBoundingRectangle = function() { */ Blockly.WorkspaceCommentSvg.prototype.updateMovable = function() { if (this.isMovable()) { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable'); } else { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable'); } }; @@ -477,10 +477,10 @@ Blockly.WorkspaceCommentSvg.prototype.setDragging = function(adding) { var group = this.getSvgRoot(); group.translate_ = ''; group.skew_ = ''; - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDragging'); } else { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDragging'); } }; @@ -523,10 +523,10 @@ Blockly.WorkspaceCommentSvg.prototype.setContent = function(content) { */ Blockly.WorkspaceCommentSvg.prototype.setDeleteStyle = function(enable) { if (enable) { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete'); } else { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete'); } }; diff --git a/core/workspace_drag_surface_svg.js b/core/workspace_drag_surface_svg.js index b1123987431..27cd1d200ac 100644 --- a/core/workspace_drag_surface_svg.js +++ b/core/workspace_drag_surface_svg.js @@ -21,7 +21,7 @@ /** * @fileoverview An SVG that floats on top of the workspace. * Blocks are moved into this SVG during a drag, improving performance. - * The entire SVG is translated using css translation instead of SVG so the + * The entire SVG is translated using CSS translation instead of SVG so the * blocks are never repainted during drag improving performance. * @author katelyn@google.com (Katelyn Mann) */ @@ -31,11 +31,12 @@ goog.provide('Blockly.WorkspaceDragSurfaceSvg'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); /** * Blocks are moved into this SVG during a drag, improving performance. - * The entire SVG is translated using css transforms instead of SVG so the + * The entire SVG is translated using CSS transforms instead of SVG so the * blocks are never repainted during drag improving performance. * @param {!Element} container Containing element. * @constructor @@ -85,11 +86,11 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.createDom = function() { * /g> * */ - this.SVG_ = Blockly.utils.createSvgElement('svg', + this.SVG_ = Blockly.utils.dom.createSvgElement('svg', { - 'xmlns': Blockly.SVG_NS, - 'xmlns:html': Blockly.HTML_NS, - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + 'xmlns': Blockly.utils.dom.SVG_NS, + 'xmlns:html': Blockly.utils.dom.HTML_NS, + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'class': 'blocklyWsDragSurface blocklyOverflowVisible' }, null); @@ -112,14 +113,14 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.translateSurface = function(x, y) { var fixedY = y.toFixed(0); this.SVG_.style.display = 'block'; - Blockly.utils.setCssTransform( + Blockly.utils.dom.setCssTransform( this.SVG_, 'translate3d(' + fixedX + 'px, ' + fixedY + 'px, 0px)'); }; /** * Reports the surface translation in scaled workspace coordinates. * Use this when finishing a drag to return blocks to the correct position. - * @return {!goog.math.Coordinate} Current translation of the surface + * @return {!Blockly.utils.Coordinate} Current translation of the surface * @package */ Blockly.WorkspaceDragSurfaceSvg.prototype.getSurfaceTranslation = function() { @@ -141,8 +142,8 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.clearAndHide = function(newSurface) { var blockCanvas = this.SVG_.childNodes[0]; var bubbleCanvas = this.SVG_.childNodes[1]; if (!blockCanvas || !bubbleCanvas || - !Blockly.utils.hasClass(blockCanvas, 'blocklyBlockCanvas') || - !Blockly.utils.hasClass(bubbleCanvas, 'blocklyBubbleCanvas')) { + !Blockly.utils.dom.hasClass(blockCanvas, 'blocklyBlockCanvas') || + !Blockly.utils.dom.hasClass(bubbleCanvas, 'blocklyBubbleCanvas')) { throw Error('Couldn\'t clear and hide the drag surface. ' + 'A node was missing.'); } @@ -150,19 +151,19 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.clearAndHide = function(newSurface) { // If there is a previous sibling, put the blockCanvas back right afterwards, // otherwise insert it as the first child node in newSurface. if (this.previousSibling_ != null) { - Blockly.utils.insertAfter(blockCanvas, this.previousSibling_); + Blockly.utils.dom.insertAfter(blockCanvas, this.previousSibling_); } else { newSurface.insertBefore(blockCanvas, newSurface.firstChild); } // Reattach the bubble canvas after the blockCanvas. - Blockly.utils.insertAfter(bubbleCanvas, blockCanvas); + Blockly.utils.dom.insertAfter(bubbleCanvas, blockCanvas); // Hide the drag surface. this.SVG_.style.display = 'none'; if (this.SVG_.childNodes.length) { throw Error('Drag surface was not cleared.'); } - Blockly.utils.setCssTransform(this.SVG_, ''); + Blockly.utils.dom.setCssTransform(this.SVG_, ''); this.previousSibling_ = null; }; diff --git a/core/workspace_dragger.js b/core/workspace_dragger.js index 00c28818738..ce3288e5cb8 100644 --- a/core/workspace_dragger.js +++ b/core/workspace_dragger.js @@ -26,7 +26,7 @@ goog.provide('Blockly.WorkspaceDragger'); -goog.require('goog.math.Coordinate'); +goog.require('Blockly.utils.Coordinate'); /** @@ -48,10 +48,10 @@ Blockly.WorkspaceDragger = function(workspace) { /** * The scroll position of the workspace at the beginning of the drag. * Coordinate system: pixel coordinates. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @private */ - this.startScrollXY_ = new goog.math.Coordinate( + this.startScrollXY_ = new Blockly.utils.Coordinate( workspace.scrollX, workspace.scrollY); }; @@ -76,7 +76,7 @@ Blockly.WorkspaceDragger.prototype.startDrag = function() { /** * Finish dragging the workspace and put everything back where it belongs. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at the start of the drag, in pixel coordinates. * @package */ @@ -88,11 +88,11 @@ Blockly.WorkspaceDragger.prototype.endDrag = function(currentDragDeltaXY) { /** * Move the workspace based on the most recent mouse movements. - * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has + * @param {!Blockly.utils.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at the start of the drag, in pixel coordinates. * @package */ Blockly.WorkspaceDragger.prototype.drag = function(currentDragDeltaXY) { - var newXY = goog.math.Coordinate.sum(this.startScrollXY_, currentDragDeltaXY); + var newXY = Blockly.utils.Coordinate.sum(this.startScrollXY_, currentDragDeltaXY); this.workspace_.scroll(newXY.x, newXY.y); }; diff --git a/core/workspace_events.js b/core/workspace_events.js index b4c78e2defc..02b4a9cd666 100644 --- a/core/workspace_events.js +++ b/core/workspace_events.js @@ -29,6 +29,7 @@ goog.provide('Blockly.Events.FinishedLoading'); goog.require('Blockly.Events'); goog.require('Blockly.Events.Abstract'); + /** * Class for a finished loading event. * Used to notify the developer when the workspace has finished loading (i.e diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 74896cbac74..7ce83434154 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -30,15 +30,20 @@ goog.provide('Blockly.WorkspaceSvg'); //goog.require('Blockly.BlockSvg'); goog.require('Blockly.ConnectionDB'); goog.require('Blockly.constants'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockCreate'); goog.require('Blockly.Gesture'); goog.require('Blockly.Grid'); +goog.require('Blockly.Msg'); goog.require('Blockly.Options'); goog.require('Blockly.ScrollbarPair'); goog.require('Blockly.Touch'); goog.require('Blockly.TouchGesture'); goog.require('Blockly.Trashcan'); goog.require('Blockly.utils'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.Rect'); goog.require('Blockly.VariablesDynamic'); goog.require('Blockly.Workspace'); goog.require('Blockly.WorkspaceAudio'); @@ -49,9 +54,6 @@ goog.require('Blockly.WorkspaceDragSurfaceSvg'); goog.require('Blockly.Xml'); goog.require('Blockly.ZoomControls'); -goog.require('goog.dom'); -goog.require('goog.math.Coordinate'); - /** * Class for a workspace. This is an onscreen area with optional trashcan, @@ -72,7 +74,7 @@ Blockly.WorkspaceSvg = function(options, this.setMetrics = options.setMetrics || Blockly.WorkspaceSvg.setTopLevelWorkspaceMetrics_; - Blockly.ConnectionDB.init(this); + this.connectionDBList = Blockly.ConnectionDB.init(); if (opt_blockDragSurface) { this.blockDragSurface_ = opt_blockDragSurface; @@ -249,7 +251,7 @@ Blockly.WorkspaceSvg.prototype.startScrollY = 0; /** * Distance from mouse to object being dragged. - * @type {goog.math.Coordinate} + * @type {Blockly.utils.Coordinate} * @private */ Blockly.WorkspaceSvg.prototype.dragDeltaXY_ = null; @@ -272,6 +274,21 @@ Blockly.WorkspaceSvg.prototype.trashcan = null; */ Blockly.WorkspaceSvg.prototype.scrollbar = null; +/** + * Fixed flyout providing blocks which may be dragged into this workspace. + * @type {Blockly.Flyout} + * @private + */ +Blockly.WorkspaceSvg.prototype.flyout_ = null; + +/** + * Category-based toolbox providing blocks which may be dragged into this + * workspace. + * @type {Blockly.Toolbox} + * @private + */ +Blockly.WorkspaceSvg.prototype.toolbox_ = null; + /** * The current gesture in progress on this workspace, if any. * @type {Blockly.TouchGesture} @@ -323,7 +340,7 @@ Blockly.WorkspaceSvg.prototype.injectionDiv_ = null; * Last known position of the page scroll. * This is used to determine whether we have recalculated screen coordinate * stuff since the page scrolled. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} * @private */ Blockly.WorkspaceSvg.prototype.lastRecordedPageScroll_ = null; @@ -413,15 +430,15 @@ Blockly.WorkspaceSvg.prototype.isVisible = function() { * scales that after canvas SVG element, if it's a descendant. * The origin (0,0) is the top-left corner of the Blockly SVG. * @param {!Element} element Element to find the coordinates of. - * @return {!goog.math.Coordinate} Object with .x and .y properties. + * @return {!Blockly.utils.Coordinate} Object with .x and .y properties. * @private */ Blockly.WorkspaceSvg.prototype.getSvgXY = function(element) { var x = 0; var y = 0; var scale = 1; - if (Blockly.utils.containsNode(this.getCanvas(), element) || - Blockly.utils.containsNode(this.getBubbleCanvas(), element)) { + if (Blockly.utils.dom.containsNode(this.getCanvas(), element) || + Blockly.utils.dom.containsNode(this.getBubbleCanvas(), element)) { // Before the SVG canvas, scale the coordinates. scale = this.scale; } @@ -437,7 +454,7 @@ Blockly.WorkspaceSvg.prototype.getSvgXY = function(element) { y += xy.y * scale; element = element.parentNode; } while (element && element != this.getParentSvg()); - return new goog.math.Coordinate(x, y); + return new Blockly.utils.Coordinate(x, y); }; /** @@ -445,7 +462,7 @@ Blockly.WorkspaceSvg.prototype.getSvgXY = function(element) { * origin in pixels. * The workspace origin is where a block would render at position (0, 0). * It is not the upper left corner of the workspace SVG. - * @return {!goog.math.Coordinate} Offset in pixels. + * @return {!Blockly.utils.Coordinate} Offset in pixels. * @package */ Blockly.WorkspaceSvg.prototype.getOriginOffsetInPixels = function() { @@ -499,7 +516,7 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) { * * @type {SVGElement} */ - this.svgGroup_ = Blockly.utils.createSvgElement('g', + this.svgGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyWorkspace'}, null); // Note that a alone does not receive mouse events--it must have a @@ -507,7 +524,7 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) { // flyout, the workspace will not receive mouse events. if (opt_backgroundClass) { /** @type {SVGElement} */ - this.svgBackground_ = Blockly.utils.createSvgElement('rect', + this.svgBackground_ = Blockly.utils.dom.createSvgElement('rect', {'height': '100%', 'width': '100%', 'class': opt_backgroundClass}, this.svgGroup_); @@ -517,10 +534,10 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) { } } /** @type {SVGElement} */ - this.svgBlockCanvas_ = Blockly.utils.createSvgElement('g', + this.svgBlockCanvas_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyBlockCanvas'}, this.svgGroup_); /** @type {SVGElement} */ - this.svgBubbleCanvas_ = Blockly.utils.createSvgElement('g', + this.svgBubbleCanvas_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyBubbleCanvas'}, this.svgGroup_); if (!this.isFlyout) { @@ -533,10 +550,6 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) { // Determine if there needs to be a category tree, or a simple list of // blocks. This cannot be changed later, since the UI is very different. if (this.options.hasCategories) { - /** - * @type {Blockly.Toolbox} - * @private - */ this.toolbox_ = new Blockly.Toolbox(this); } if (this.grid_) { @@ -558,7 +571,7 @@ Blockly.WorkspaceSvg.prototype.dispose = function() { } Blockly.WorkspaceSvg.superClass_.dispose.call(this); if (this.svgGroup_) { - Blockly.utils.removeNode(this.svgGroup_); + Blockly.utils.dom.removeNode(this.svgGroup_); this.svgGroup_ = null; } this.svgBlockCanvas_ = null; @@ -594,6 +607,8 @@ Blockly.WorkspaceSvg.prototype.dispose = function() { this.grid_ = null; } + this.connectionDBList = null; + this.toolboxCategoryCallbacks_ = null; this.flyoutButtonCallbacks_ = null; @@ -602,7 +617,7 @@ Blockly.WorkspaceSvg.prototype.dispose = function() { // SVG is injected into (i.e. injectionDiv). var div = this.getParentSvg().parentNode; if (div) { - Blockly.utils.removeNode(div); + Blockly.utils.dom.removeNode(div); } } if (this.resizeHandlerWrapper_) { @@ -660,11 +675,6 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function(tagName) { horizontalLayout: this.horizontalLayout, toolboxPosition: this.options.toolboxPosition }; - /** - * @type {!Blockly.Flyout} - * @private - */ - this.flyout_ = null; if (this.horizontalLayout) { this.flyout_ = new Blockly.HorizontalFlyout(workspaceOptions); } else { @@ -672,7 +682,7 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function(tagName) { } this.flyout_.autoClose = false; - // Return the element so that callers can place it in their desired + // Return the element so that callers can place it in their desired // spot in the DOM. For example, mutator flyouts do not go in the same place // as main workspace flyouts. return this.flyout_.createDom(tagName); @@ -766,9 +776,9 @@ Blockly.WorkspaceSvg.prototype.resize = function() { Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled = function() { /* eslint-disable indent */ - var currScroll = goog.dom.getDocumentScroll(); - if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_, - currScroll)) { + var currScroll = Blockly.utils.getDocumentScroll(); + if (!Blockly.utils.Coordinate.equals( + this.lastRecordedPageScroll_, currScroll)) { this.lastRecordedPageScroll_ = currScroll; this.updateScreenCalculations_(); } @@ -1057,7 +1067,7 @@ Blockly.WorkspaceSvg.prototype.pasteBlock_ = function(xmlBlock) { var connections = block.getConnections_(false); for (var i = 0, connection; connection = connections[i]; i++) { var neighbour = connection.closest(Blockly.SNAP_RADIUS, - new goog.math.Coordinate(blockX, blockY)); + new Blockly.utils.Coordinate(blockX, blockY)); if (neighbour.connection) { collide = true; break; @@ -1195,11 +1205,12 @@ Blockly.WorkspaceSvg.prototype.recordDeleteAreas = function() { * which delete area the event is over. */ Blockly.WorkspaceSvg.prototype.isDeleteArea = function(e) { - var xy = new goog.math.Coordinate(e.clientX, e.clientY); - if (this.deleteAreaTrash_ && this.deleteAreaTrash_.contains(xy)) { + if (this.deleteAreaTrash_ && + this.deleteAreaTrash_.contains(e.clientX, e.clientY)) { return Blockly.DELETE_AREA_TRASH; } - if (this.deleteAreaToolbox_ && this.deleteAreaToolbox_.contains(xy)) { + if (this.deleteAreaToolbox_ && + this.deleteAreaToolbox_.contains(e.clientX, e.clientY)) { return Blockly.DELETE_AREA_TOOLBOX; } return Blockly.DELETE_AREA_NONE; @@ -1220,7 +1231,7 @@ Blockly.WorkspaceSvg.prototype.onMouseDown_ = function(e) { /** * Start tracking a drag of an object on this workspace. * @param {!Event} e Mouse down event. - * @param {!goog.math.Coordinate} xy Starting location of object. + * @param {!Blockly.utils.Coordinate} xy Starting location of object. */ Blockly.WorkspaceSvg.prototype.startDrag = function(e, xy) { // Record the starting offset between the bubble's location and the mouse. @@ -1229,13 +1240,13 @@ Blockly.WorkspaceSvg.prototype.startDrag = function(e, xy) { // Fix scale of mouse event. point.x /= this.scale; point.y /= this.scale; - this.dragDeltaXY_ = goog.math.Coordinate.difference(xy, point); + this.dragDeltaXY_ = Blockly.utils.Coordinate.difference(xy, point); }; /** * Track a drag of an object on this workspace. * @param {!Event} e Mouse move event. - * @return {!goog.math.Coordinate} New location of object. + * @return {!Blockly.utils.Coordinate} New location of object. */ Blockly.WorkspaceSvg.prototype.moveDrag = function(e) { var point = Blockly.utils.mouseToSvg(e, this.getParentSvg(), @@ -1243,7 +1254,7 @@ Blockly.WorkspaceSvg.prototype.moveDrag = function(e) { // Fix scale of mouse event. point.x /= this.scale; point.y /= this.scale; - return goog.math.Coordinate.sum(this.dragDeltaXY_, point); + return Blockly.utils.Coordinate.sum(this.dragDeltaXY_, point); }; /** @@ -1344,8 +1355,8 @@ Blockly.WorkspaceSvg.prototype.onMouseWheel_ = function(e) { * Calculate the bounding box for the blocks on the workspace. * Coordinate system: workspace coordinates. * - * @return {Object} Contains the position and size of the bounding box - * containing the blocks on the workspace. + * @return {!Blockly.utils.Rect} Contains the position and size of the + * bounding box containing the blocks on the workspace. */ Blockly.WorkspaceSvg.prototype.getBlocksBoundingBox = function() { var topBlocks = this.getTopBlocks(false); @@ -1353,34 +1364,29 @@ Blockly.WorkspaceSvg.prototype.getBlocksBoundingBox = function() { var topElements = topBlocks.concat(topComments); // There are no blocks, return empty rectangle. if (!topElements.length) { - return {x: 0, y: 0, width: 0, height: 0}; + return new Blockly.utils.Rect(0, 0, 0, 0); } // Initialize boundary using the first block. var boundary = topElements[0].getBoundingRectangle(); - // Start at 1 since the 0th block was used for initialization + // Start at 1 since the 0th block was used for initialization. for (var i = 1; i < topElements.length; i++) { var blockBoundary = topElements[i].getBoundingRectangle(); - if (blockBoundary.topLeft.x < boundary.topLeft.x) { - boundary.topLeft.x = blockBoundary.topLeft.x; + if (blockBoundary.top < boundary.top) { + boundary.top = blockBoundary.top; } - if (blockBoundary.bottomRight.x > boundary.bottomRight.x) { - boundary.bottomRight.x = blockBoundary.bottomRight.x; + if (blockBoundary.bottom > boundary.bottom) { + boundary.bottom = blockBoundary.bottom; } - if (blockBoundary.topLeft.y < boundary.topLeft.y) { - boundary.topLeft.y = blockBoundary.topLeft.y; + if (blockBoundary.left < boundary.left) { + boundary.left = blockBoundary.left; } - if (blockBoundary.bottomRight.y > boundary.bottomRight.y) { - boundary.bottomRight.y = blockBoundary.bottomRight.y; + if (blockBoundary.right > boundary.right) { + boundary.right = blockBoundary.right; } } - return { - x: boundary.topLeft.x, - y: boundary.topLeft.y, - width: boundary.bottomRight.x - boundary.topLeft.x, - height: boundary.bottomRight.y - boundary.topLeft.y - }; + return boundary; }; /** @@ -1672,7 +1678,7 @@ Blockly.WorkspaceSvg.prototype.zoom = function(x, y, amount) { // Find the new scrollX/scrollY so that the center remains in the same // position (relative to the center) after we zoom. // newScale and matrix.a should be identical (within a rounding error). - var matrix = matrix.translate(x * (1 - scaleChange), y * (1 - scaleChange)) + matrix = matrix.translate(x * (1 - scaleChange), y * (1 - scaleChange)) .scale(scaleChange); // scrollX and scrollY are in pixels. // The scrollX and scrollY still need to have absoluteLeft and absoluteTop @@ -1718,8 +1724,8 @@ Blockly.WorkspaceSvg.prototype.zoomToFit = function() { var workspaceWidth = metrics.viewWidth; var workspaceHeight = metrics.viewHeight; var blocksBox = this.getBlocksBoundingBox(); - var blocksWidth = blocksBox.width; - var blocksHeight = blocksBox.height; + var blocksWidth = blocksBox.right - blocksBox.left; + var blocksHeight = blocksBox.bottom - blocksBox.top; if (!blocksWidth) { return; // Prevents zooming to infinity. } @@ -1752,10 +1758,10 @@ Blockly.WorkspaceSvg.prototype.zoomToFit = function() { * @package */ Blockly.WorkspaceSvg.prototype.beginCanvasTransition = function() { - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!SVGElement} */ (this.svgBlockCanvas_), 'blocklyCanvasTransitioning'); - Blockly.utils.addClass( + Blockly.utils.dom.addClass( /** @type {!SVGElement} */ (this.svgBubbleCanvas_), 'blocklyCanvasTransitioning'); }; @@ -1765,10 +1771,10 @@ Blockly.WorkspaceSvg.prototype.beginCanvasTransition = function() { * @package */ Blockly.WorkspaceSvg.prototype.endCanvasTransition = function() { - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!SVGElement} */ (this.svgBlockCanvas_), 'blocklyCanvasTransitioning'); - Blockly.utils.removeClass( + Blockly.utils.dom.removeClass( /** @type {!SVGElement} */ (this.svgBubbleCanvas_), 'blocklyCanvasTransitioning'); }; @@ -1909,6 +1915,8 @@ Blockly.WorkspaceSvg.prototype.setScale = function(newScale) { * @package */ Blockly.WorkspaceSvg.prototype.scroll = function(x, y) { + Blockly.hideChaff(/* opt_allowToolbox */ true); + // Keep scrolling within the bounds of the content. var metrics = this.getMetrics(); // This is the offset of the top-left corner of the view from the @@ -1941,10 +1949,6 @@ Blockly.WorkspaceSvg.prototype.scroll = function(x, y) { this.scrollbar.vScroll.setHandlePosition(-(y + metrics.contentTop) * this.scrollbar.vScroll.ratio_); } - - // Hide the WidgetDiv without animation. This is to prevent a disposal - // animation from happening in the wrong location. - Blockly.WidgetDiv.hide(true); // We have to shift the translation so that when the canvas is at 0, 0 the // workspace origin is not underneath the toolbox. x += metrics.absoluteLeft; @@ -2010,18 +2014,18 @@ Blockly.WorkspaceSvg.getContentDimensionsExact_ = function(ws) { var scale = ws.scale; // Convert to pixels. - var width = blockBox.width * scale; - var height = blockBox.height * scale; - var left = blockBox.x * scale; - var top = blockBox.y * scale; + var top = blockBox.top * scale; + var bottom = blockBox.bottom * scale; + var left = blockBox.left * scale; + var right = blockBox.right * scale; return { - left: left, top: top, - right: left + width, - bottom: top + height, - width: width, - height: height + bottom: bottom, + left: left, + right: right, + width: right - left, + height: bottom - top }; }; diff --git a/core/ws_comment_events.js b/core/ws_comment_events.js index cc71a036811..953f1a7d332 100644 --- a/core/ws_comment_events.js +++ b/core/ws_comment_events.js @@ -32,10 +32,9 @@ goog.provide('Blockly.Events.CommentMove'); goog.require('Blockly.Events'); goog.require('Blockly.Events.Abstract'); +goog.require('Blockly.utils.Coordinate'); +goog.require('Blockly.utils.xml'); goog.require('Blockly.Xml'); -goog.require('Blockly.Xml.utils'); - -goog.require('goog.math.Coordinate'); /** @@ -208,7 +207,7 @@ Blockly.Events.CommentCreate.prototype.toJson = function() { */ Blockly.Events.CommentCreate.prototype.fromJson = function(json) { Blockly.Events.CommentCreate.superClass_.fromJson.call(this, json); - this.xml = Blockly.Xml.textToDom('' + json['xml'] + '').firstChild; + this.xml = Blockly.Xml.textToDom(json['xml']); }; /** @@ -228,7 +227,7 @@ Blockly.Events.CommentCreate.prototype.run = function(forward) { Blockly.Events.CommentCreateDeleteHelper = function(event, create) { var workspace = event.getEventWorkspace_(); if (create) { - var xml = Blockly.Xml.utils.createElement('xml'); + var xml = Blockly.utils.xml.createElement('xml'); xml.appendChild(event.xml); Blockly.Xml.domToWorkspace(xml, workspace); } else { @@ -312,13 +311,13 @@ Blockly.Events.CommentMove = function(comment) { /** * The location before the move, in workspace coordinates. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} */ this.oldCoordinate_ = comment.getXY(); /** * The location after the move, in workspace coordinates. - * @type {!goog.math.Coordinate} + * @type {!Blockly.utils.Coordinate} */ this.newCoordinate_ = null; }; @@ -346,7 +345,7 @@ Blockly.Events.CommentMove.prototype.type = Blockly.Events.COMMENT_MOVE; /** * Override the location before the move. Use this if you don't create the * event until the end of the move, but you know the original location. - * @param {!goog.math.Coordinate} xy The location before the move, in workspace + * @param {!Blockly.utils.Coordinate} xy The location before the move, in workspace * coordinates. */ Blockly.Events.CommentMove.prototype.setOldCoordinate = function(xy) { @@ -377,7 +376,7 @@ Blockly.Events.CommentMove.prototype.fromJson = function(json) { if (json['newCoordinate']) { var xy = json['newCoordinate'].split(','); this.newCoordinate_ = - new goog.math.Coordinate(parseFloat(xy[0]), parseFloat(xy[1])); + new Blockly.utils.Coordinate(parseFloat(xy[0]), parseFloat(xy[1])); } }; @@ -386,7 +385,7 @@ Blockly.Events.CommentMove.prototype.fromJson = function(json) { * @return {boolean} False if something changed. */ Blockly.Events.CommentMove.prototype.isNull = function() { - return goog.math.Coordinate.equals(this.oldCoordinate_, this.newCoordinate_); + return Blockly.utils.Coordinate.equals(this.oldCoordinate_, this.newCoordinate_); }; /** diff --git a/core/xml.js b/core/xml.js index e30fb684c3b..345e2353437 100644 --- a/core/xml.js +++ b/core/xml.js @@ -30,10 +30,13 @@ */ goog.provide('Blockly.Xml'); +goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockCreate'); goog.require('Blockly.Events.FinishedLoading'); goog.require('Blockly.Events.VarCreate'); -goog.require('Blockly.Xml.utils'); +goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.xml'); /** @@ -43,7 +46,7 @@ goog.require('Blockly.Xml.utils'); * @return {!Element} XML document. */ Blockly.Xml.workspaceToDom = function(workspace, opt_noId) { - var xml = Blockly.Xml.utils.createElement('xml'); + var xml = Blockly.utils.xml.createElement('xml'); var variablesElement = Blockly.Xml.variablesToDom( Blockly.Variables.allUsedVarModels(workspace)); if (variablesElement.hasChildNodes()) { @@ -67,12 +70,14 @@ Blockly.Xml.workspaceToDom = function(workspace, opt_noId) { * @return {!Element} List of XML elements. */ Blockly.Xml.variablesToDom = function(variableList) { - var variables = Blockly.Xml.utils.createElement('variables'); + var variables = Blockly.utils.xml.createElement('variables'); for (var i = 0, variable; variable = variableList[i]; i++) { - var element = Blockly.Xml.utils.createElement('variable'); - element.appendChild(Blockly.Xml.utils.createTextNode(variable.name)); - element.setAttribute('type', variable.type); - element.setAttribute('id', variable.getId()); + var element = Blockly.utils.xml.createElement('variable'); + element.appendChild(Blockly.utils.xml.createTextNode(variable.name)); + if (variable.type) { + element.setAttribute('type', variable.type); + } + element.id = variable.getId(); variables.appendChild(element); } return variables; @@ -97,41 +102,6 @@ Blockly.Xml.blockToDomWithXY = function(block, opt_noId) { return element; }; -/** - * Encode a variable field as XML. - * @param {!Blockly.FieldVariable} field The field to encode. - * @return {Element} XML element, or null if the field did not need to be - * serialized. - * @private - */ -Blockly.Xml.fieldToDomVariable_ = function(field) { - var id = field.getValue(); - // The field had not been initialized fully before being serialized. - // This can happen if a block is created directly through a call to - // workspace.newBlock instead of from XML. - // The new block will be serialized for the first time when firing a block - // creation event. - if (id == null) { - field.initModel(); - id = field.getValue(); - } - // Get the variable directly from the field, instead of doing a lookup. This - // will work even if the variable has already been deleted. This can happen - // because the flyout defers deleting blocks until the next time the flyout - // is opened. - var variable = field.getVariable(); - - if (!variable) { - throw Error('Tried to serialize a variable field with no variable.'); - } - var container = Blockly.Xml.utils.createElement('field'); - container.appendChild(Blockly.Xml.utils.createTextNode(variable.name)); - container.setAttribute('name', field.name); - container.setAttribute('id', variable.getId()); - container.setAttribute('variabletype', variable.type); - return container; -}; - /** * Encode a field as XML. * @param {!Blockly.Field} field The field to encode. @@ -140,15 +110,10 @@ Blockly.Xml.fieldToDomVariable_ = function(field) { * @private */ Blockly.Xml.fieldToDom_ = function(field) { - if (field.name && field.EDITABLE) { - if (field.referencesVariables()) { - return Blockly.Xml.fieldToDomVariable_(field); - } else { - var container = Blockly.Xml.utils.createElement('field'); - container.appendChild(Blockly.Xml.utils.createTextNode(field.getValue())); - container.setAttribute('name', field.name); - return container; - } + if (field.isSerializable()) { + var container = Blockly.utils.xml.createElement('field'); + container.setAttribute('name', field.name); + return field.toXml(container); } return null; }; @@ -180,10 +145,10 @@ Blockly.Xml.allFieldsToDom_ = function(block, element) { */ Blockly.Xml.blockToDom = function(block, opt_noId) { var element = - Blockly.Xml.utils.createElement(block.isShadow() ? 'shadow' : 'block'); + Blockly.utils.xml.createElement(block.isShadow() ? 'shadow' : 'block'); element.setAttribute('type', block.type); if (!opt_noId) { - element.setAttribute('id', block.id); + element.id = block.id; } if (block.mutationToDom) { // Custom data for an advanced block. @@ -197,8 +162,8 @@ Blockly.Xml.blockToDom = function(block, opt_noId) { var commentText = block.getCommentText(); if (commentText) { - var commentElement = Blockly.Xml.utils.createElement('comment'); - commentElement.appendChild(Blockly.Xml.utils.createTextNode(commentText)); + var commentElement = Blockly.utils.xml.createElement('comment'); + commentElement.appendChild(Blockly.utils.xml.createTextNode(commentText)); if (typeof block.comment == 'object') { commentElement.setAttribute('pinned', block.comment.isVisible()); var hw = block.comment.getBubbleSize(); @@ -209,8 +174,8 @@ Blockly.Xml.blockToDom = function(block, opt_noId) { } if (block.data) { - var dataElement = Blockly.Xml.utils.createElement('data'); - dataElement.appendChild(Blockly.Xml.utils.createTextNode(block.data)); + var dataElement = Blockly.utils.xml.createElement('data'); + dataElement.appendChild(Blockly.utils.xml.createTextNode(block.data)); element.appendChild(dataElement); } @@ -222,13 +187,13 @@ Blockly.Xml.blockToDom = function(block, opt_noId) { } else { var childBlock = input.connection.targetBlock(); if (input.type == Blockly.INPUT_VALUE) { - container = Blockly.Xml.utils.createElement('value'); + container = Blockly.utils.xml.createElement('value'); } else if (input.type == Blockly.NEXT_STATEMENT) { - container = Blockly.Xml.utils.createElement('statement'); + container = Blockly.utils.xml.createElement('statement'); } var shadow = input.connection.getShadowDom(); if (shadow && (!childBlock || !childBlock.isShadow())) { - container.appendChild(Blockly.Xml.cloneShadow_(shadow)); + container.appendChild(Blockly.Xml.cloneShadow_(shadow, opt_noId)); } if (childBlock) { container.appendChild(Blockly.Xml.blockToDom(childBlock, opt_noId)); @@ -240,13 +205,14 @@ Blockly.Xml.blockToDom = function(block, opt_noId) { element.appendChild(container); } } - if (block.inputsInlineDefault != block.inputsInline) { + if (block.inputsInline != undefined && + block.inputsInline != block.inputsInlineDefault) { element.setAttribute('inline', block.inputsInline); } if (block.isCollapsed()) { element.setAttribute('collapsed', true); } - if (block.disabled) { + if (!block.isEnabled()) { element.setAttribute('disabled', true); } if (!block.isDeletable() && !block.isShadow()) { @@ -261,13 +227,13 @@ Blockly.Xml.blockToDom = function(block, opt_noId) { var nextBlock = block.getNextBlock(); if (nextBlock) { - var container = Blockly.Xml.utils.createElement('next'); + var container = Blockly.utils.xml.createElement('next'); container.appendChild(Blockly.Xml.blockToDom(nextBlock, opt_noId)); element.appendChild(container); } var shadow = block.nextConnection && block.nextConnection.getShadowDom(); if (shadow && (!nextBlock || !nextBlock.isShadow())) { - container.appendChild(Blockly.Xml.cloneShadow_(shadow)); + container.appendChild(Blockly.Xml.cloneShadow_(shadow, opt_noId)); } return element; @@ -276,33 +242,39 @@ Blockly.Xml.blockToDom = function(block, opt_noId) { /** * Deeply clone the shadow's DOM so that changes don't back-wash to the block. * @param {!Element} shadow A tree of XML elements. + * @param {boolean=} opt_noId True if the encoder should skip the block ID. * @return {!Element} A tree of XML elements. * @private */ -Blockly.Xml.cloneShadow_ = function(shadow) { +Blockly.Xml.cloneShadow_ = function(shadow, opt_noId) { shadow = shadow.cloneNode(true); // Walk the tree looking for whitespace. Don't prune whitespace in a tag. var node = shadow; var textNode; while (node) { + if (opt_noId && node.nodeName == 'shadow') { + // Strip off IDs from shadow blocks. There should never be a 'block' as + // a child of a 'shadow', so no need to check that. + node.removeAttribute('id'); + } if (node.firstChild) { node = node.firstChild; } else { while (node && !node.nextSibling) { textNode = node; node = node.parentNode; - if (textNode.nodeType == 3 && textNode.data.trim() == '' && - node.firstChild != textNode) { + if (textNode.nodeType == Node.TEXT_NODE && + textNode.data.trim() == '' && node.firstChild != textNode) { // Prune whitespace after a tag. - Blockly.utils.removeNode(textNode); + Blockly.utils.dom.removeNode(textNode); } } if (node) { textNode = node; node = node.nextSibling; - if (textNode.nodeType == 3 && textNode.data.trim() == '') { + if (textNode.nodeType == Node.TEXT_NODE && textNode.data.trim() == '') { // Prune whitespace before a tag. - Blockly.utils.removeNode(textNode); + Blockly.utils.dom.removeNode(textNode); } } } @@ -317,7 +289,7 @@ Blockly.Xml.cloneShadow_ = function(shadow) { * @return {string} Text representation. */ Blockly.Xml.domToText = function(dom) { - return Blockly.Xml.utils.domToText(dom); + return Blockly.utils.xml.domToText(dom); }; /** @@ -352,20 +324,17 @@ Blockly.Xml.domToPrettyText = function(dom) { }; /** - * Converts an XML string into a DOM structure. It requires the XML to have a - * root element of . Other XML string will result in throwing an error. + * Converts an XML string into a DOM structure. * @param {string} text An XML string. * @return {!Element} A DOM object representing the singular child of the * document element. - * @throws if XML doesn't parse or is not the expected structure. + * @throws if the text doesn't parse. */ Blockly.Xml.textToDom = function(text) { - var doc = Blockly.Xml.utils.textToDomDocument(text); - // This function only accepts documents. + var doc = Blockly.utils.xml.textToDomDocument(text); if (!doc || !doc.documentElement || - doc.documentElement.nodeName.toLowerCase() != 'xml') { - // Whatever we got back from the parser is not the expected structure. - throw TypeError('Blockly.Xml.textToDom expected an document.'); + doc.getElementsByTagName('parsererror').length) { + throw Error('textToDom was unable to parse: ' + text); } return doc.documentElement; }; @@ -389,11 +358,13 @@ Blockly.Xml.clearWorkspaceAndLoadFromXml = function(xml, workspace) { * Decode an XML DOM and create blocks on the workspace. * @param {!Element} xml XML DOM. * @param {!Blockly.Workspace} workspace The workspace. - * @return {Array.} An array containing new block IDs. + * @return {!Array.} An array containing new block IDs. */ Blockly.Xml.domToWorkspace = function(xml, workspace) { if (xml instanceof Blockly.Workspace) { var swap = xml; + // Closure Compiler complains here because the arguments are reversed. + /** @suppress {checkTypes} */ xml = workspace; workspace = swap; console.warn('Deprecated call to Blockly.Xml.domToWorkspace, ' + @@ -494,11 +465,11 @@ Blockly.Xml.appendDomToWorkspace = function(xml, workspace) { } // Load the new blocks into the workspace and get the IDs of the new blocks. var newBlockIds = Blockly.Xml.domToWorkspace(xml,workspace); - if (bbox && bbox.height) { // check if any previous block + if (bbox && bbox.top != bbox.bottom) { // check if any previous block var offsetY = 0; // offset to add to y of the new block var offsetX = 0; - var farY = bbox.y + bbox.height; // bottom position - var topX = bbox.x; // x of bounding box + var farY = bbox.bottom; // bottom position + var topX = bbox.left; // x of bounding box // Check position of the new blocks. var newX = Infinity; // x of top corner var newY = Infinity; // y of top corner @@ -537,6 +508,8 @@ Blockly.Xml.appendDomToWorkspace = function(xml, workspace) { Blockly.Xml.domToBlock = function(xmlBlock, workspace) { if (xmlBlock instanceof Blockly.Workspace) { var swap = xmlBlock; + // Closure Compiler complains here because the arguments are reversed. + /** @suppress {checkTypes} */ xmlBlock = workspace; workspace = swap; console.warn('Deprecated call to Blockly.Xml.domToBlock, ' + @@ -602,16 +575,13 @@ Blockly.Xml.domToBlock = function(xmlBlock, workspace) { */ Blockly.Xml.domToVariables = function(xmlVariables, workspace) { for (var i = 0, xmlChild; xmlChild = xmlVariables.childNodes[i]; i++) { - if (xmlChild.nodeType != Element.ELEMENT_NODE) { + if (xmlChild.nodeType != Node.ELEMENT_NODE) { continue; // Skip text nodes. } var type = xmlChild.getAttribute('type'); var id = xmlChild.getAttribute('id'); var name = xmlChild.textContent; - if (type == null) { - throw Error('Variable with id, ' + id + ' is without a type'); - } workspace.createVariable(name, type, id); } }; @@ -635,7 +605,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { var blockChild = null; for (var i = 0, xmlChild; xmlChild = xmlBlock.childNodes[i]; i++) { - if (xmlChild.nodeType == 3) { + if (xmlChild.nodeType == Node.TEXT_NODE) { // Ignore any text at the level. It's all whitespace anyway. continue; } @@ -645,7 +615,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { var childBlockElement = null; var childShadowElement = null; for (var j = 0, grandchild; grandchild = xmlChild.childNodes[j]; j++) { - if (grandchild.nodeType == 1) { + if (grandchild.nodeType == Node.ELEMENT_NODE) { if (grandchild.nodeName.toLowerCase() == 'block') { childBlockElement = /** @type {!Element} */ (grandchild); } else if (grandchild.nodeName.toLowerCase() == 'shadow') { @@ -754,7 +724,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { } var disabled = xmlBlock.getAttribute('disabled'); if (disabled) { - block.setDisabled(disabled == 'true' || disabled == 'disabled'); + block.setEnabled(disabled != 'true' && disabled != 'disabled'); } var deletable = xmlBlock.getAttribute('deletable'); if (deletable) { @@ -789,37 +759,6 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { return block; }; -/** - * Decode an XML variable field tag and set the value of that field. - * @param {!Blockly.Workspace} workspace The workspace that is currently being - * deserialized. - * @param {!Element} xml The field tag to decode. - * @param {string} text The text content of the XML tag. - * @param {!Blockly.FieldVariable} field The field on which the value will be - * set. - * @private - */ -Blockly.Xml.domToFieldVariable_ = function(workspace, xml, text, field) { - var type = xml.getAttribute('variabletype') || ''; - // TODO (fenichel): Does this need to be explicit or not? - if (type == '\'\'') { - type = ''; - } - - var variable = Blockly.Variables.getOrCreateVariablePackage(workspace, xml.id, - text, type); - - // This should never happen :) - if (type != null && type !== variable.type) { - throw Error('Serialized variable type with id \'' + - variable.getId() + '\' had type ' + variable.type + ', and ' + - 'does not match variable field that references it: ' + - Blockly.Xml.domToText(xml) + '.'); - } - - field.setValue(variable.getId()); -}; - /** * Decode an XML field tag and set the value of that field on the given block. * @param {!Blockly.Block} block The block that is currently being deserialized. @@ -831,17 +770,10 @@ Blockly.Xml.domToField_ = function(block, fieldName, xml) { var field = block.getField(fieldName); if (!field) { console.warn('Ignoring non-existent field ' + fieldName + ' in block ' + - block.type); + block.type); return; } - - var workspace = block.workspace; - var text = xml.textContent; - if (field.referencesVariables()) { - Blockly.Xml.domToFieldVariable_(workspace, xml, text, field); - } else { - field.setValue(text); - } + field.fromXml(xml); }; /** @@ -858,13 +790,15 @@ Blockly.Xml.deleteNext = function(xmlBlock) { }; // Export symbols that would otherwise be renamed by Closure compiler. -if (!goog.global['Blockly']) { - goog.global['Blockly'] = {}; +if (!Blockly.utils.global['Blockly']) { + Blockly.utils.global['Blockly'] = {}; } -if (!goog.global['Blockly']['Xml']) { - goog.global['Blockly']['Xml'] = {}; +if (!Blockly.utils.global['Blockly']['Xml']) { + Blockly.utils.global['Blockly']['Xml'] = {}; } -goog.global['Blockly']['Xml']['domToText'] = Blockly.Xml.domToText; -goog.global['Blockly']['Xml']['domToWorkspace'] = Blockly.Xml.domToWorkspace; -goog.global['Blockly']['Xml']['textToDom'] = Blockly.Xml.textToDom; -goog.global['Blockly']['Xml']['workspaceToDom'] = Blockly.Xml.workspaceToDom; +Blockly.utils.global['Blockly']['Xml']['domToText'] = Blockly.Xml.domToText; +Blockly.utils.global['Blockly']['Xml']['domToWorkspace'] = + Blockly.Xml.domToWorkspace; +Blockly.utils.global['Blockly']['Xml']['textToDom'] = Blockly.Xml.textToDom; +Blockly.utils.global['Blockly']['Xml']['workspaceToDom'] = + Blockly.Xml.workspaceToDom; diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 7a4fccb94b2..46566b441a9 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -27,7 +27,7 @@ goog.provide('Blockly.ZoomControls'); goog.require('Blockly.Touch'); -goog.require('Blockly.utils'); +goog.require('Blockly.utils.dom'); /** @@ -94,7 +94,7 @@ Blockly.ZoomControls.prototype.top_ = 0; */ Blockly.ZoomControls.prototype.createDom = function() { this.svgGroup_ = - Blockly.utils.createSvgElement('g', {}, null); + Blockly.utils.dom.createSvgElement('g', {}, null); // Each filter/pattern needs a unique ID for the case of multiple Blockly // instances on a page. Browser behaviour becomes undefined otherwise. @@ -128,7 +128,7 @@ Blockly.ZoomControls.prototype.init = function(verticalSpacing) { */ Blockly.ZoomControls.prototype.dispose = function() { if (this.svgGroup_) { - Blockly.utils.removeNode(this.svgGroup_); + Blockly.utils.dom.removeNode(this.svgGroup_); this.svgGroup_ = null; } this.workspace_ = null; @@ -194,20 +194,20 @@ Blockly.ZoomControls.prototype.createZoomOutSvg_ = function(rnd) { */ var ws = this.workspace_; - this.zoomOutGroup_ = Blockly.utils.createSvgElement('g', + this.zoomOutGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyZoom'}, this.svgGroup_); - var clip = Blockly.utils.createSvgElement('clipPath', + var clip = Blockly.utils.dom.createSvgElement('clipPath', { 'id': 'blocklyZoomoutClipPath' + rnd }, this.zoomOutGroup_); - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', { 'width': 32, 'height': 32, }, clip); - var zoomoutSvg = Blockly.utils.createSvgElement('image', + var zoomoutSvg = Blockly.utils.dom.createSvgElement('image', { 'width': Blockly.SPRITE.width, 'height': Blockly.SPRITE.height, @@ -216,7 +216,7 @@ Blockly.ZoomControls.prototype.createZoomOutSvg_ = function(rnd) { 'clip-path': 'url(#blocklyZoomoutClipPath' + rnd + ')' }, this.zoomOutGroup_); - zoomoutSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + zoomoutSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', ws.options.pathToMedia + Blockly.SPRITE.url); // Attach listener. @@ -247,20 +247,20 @@ Blockly.ZoomControls.prototype.createZoomInSvg_ = function(rnd) { */ var ws = this.workspace_; - this.zoomInGroup_ = Blockly.utils.createSvgElement('g', + this.zoomInGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyZoom'}, this.svgGroup_); - var clip = Blockly.utils.createSvgElement('clipPath', + var clip = Blockly.utils.dom.createSvgElement('clipPath', { 'id': 'blocklyZoominClipPath' + rnd }, this.zoomInGroup_); - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', { 'width': 32, 'height': 32, }, clip); - var zoominSvg = Blockly.utils.createSvgElement('image', + var zoominSvg = Blockly.utils.dom.createSvgElement('image', { 'width': Blockly.SPRITE.width, 'height': Blockly.SPRITE.height, @@ -269,7 +269,7 @@ Blockly.ZoomControls.prototype.createZoomInSvg_ = function(rnd) { 'clip-path': 'url(#blocklyZoominClipPath' + rnd + ')' }, this.zoomInGroup_); - zoominSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + zoominSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', ws.options.pathToMedia + Blockly.SPRITE.url); // Attach listener. @@ -300,20 +300,20 @@ Blockly.ZoomControls.prototype.createZoomResetSvg_ = function(rnd) { */ var ws = this.workspace_; - this.zoomResetGroup_ = Blockly.utils.createSvgElement('g', + this.zoomResetGroup_ = Blockly.utils.dom.createSvgElement('g', {'class': 'blocklyZoom'}, this.svgGroup_); - var clip = Blockly.utils.createSvgElement('clipPath', + var clip = Blockly.utils.dom.createSvgElement('clipPath', { 'id': 'blocklyZoomresetClipPath' + rnd }, this.zoomResetGroup_); - Blockly.utils.createSvgElement('rect', + Blockly.utils.dom.createSvgElement('rect', { 'width': 32, 'height': 32 }, clip); - var zoomresetSvg = Blockly.utils.createSvgElement('image', + var zoomresetSvg = Blockly.utils.dom.createSvgElement('image', { 'width': Blockly.SPRITE.width, 'height': Blockly.SPRITE.height, @@ -321,7 +321,7 @@ Blockly.ZoomControls.prototype.createZoomResetSvg_ = function(rnd) { 'clip-path': 'url(#blocklyZoomresetClipPath' + rnd + ')' }, this.zoomResetGroup_); - zoomresetSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + zoomresetSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', ws.options.pathToMedia + Blockly.SPRITE.url); // Attach event listeners. diff --git a/dart_compressed.js b/dart_compressed.js index 7d40c412372..6b1c195d96b 100644 --- a/dart_compressed.js +++ b/dart_compressed.js @@ -9,10 +9,10 @@ Blockly.Dart.init=function(a){Blockly.Dart.definitions_=Object.create(null);Bloc for(d=0;dc&&(a=a+" - "+-c,g=Blockly.Dart.ORDER_ADDITIVE); -d&&(a=c?"-("+a+")":"-"+a,g=Blockly.Dart.ORDER_UNARY_PREFIX);g=Math.floor(g);e=Math.floor(e);g&&e>=g&&(a="("+a+")")}return a};Blockly.Dart.colour={};Blockly.Dart.addReservedWords("Math");Blockly.Dart.colour_picker=function(a){return["'"+a.getFieldValue("COLOUR")+"'",Blockly.Dart.ORDER_ATOMIC]}; +d&&(a=c?"-("+a+")":"-"+a,g=Blockly.Dart.ORDER_UNARY_PREFIX);g=Math.floor(g);e=Math.floor(e);g&&e>=g&&(a="("+a+")")}return a};Blockly.Dart.colour={};Blockly.Dart.addReservedWords("Math");Blockly.Dart.colour_picker=function(a){return[Blockly.Dart.quote_(a.getFieldValue("COLOUR")),Blockly.Dart.ORDER_ATOMIC]}; Blockly.Dart.colour_random=function(a){Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[Blockly.Dart.provideFunction_("colour_random",["String "+Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"() {"," String hex = '0123456789abcdef';"," var rnd = new Math.Random();"," return '#${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'"," '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'"," '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}';","}"])+"()",Blockly.Dart.ORDER_UNARY_POSTFIX]}; Blockly.Dart.colour_rgb=function(a){var b=Blockly.Dart.valueToCode(a,"RED",Blockly.Dart.ORDER_NONE)||0,c=Blockly.Dart.valueToCode(a,"GREEN",Blockly.Dart.ORDER_NONE)||0;a=Blockly.Dart.valueToCode(a,"BLUE",Blockly.Dart.ORDER_NONE)||0;Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[Blockly.Dart.provideFunction_("colour_rgb",["String "+Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num r, num g, num b) {"," num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();"," String rs = rn.toInt().toRadixString(16);", " rs = '0$rs';"," rs = rs.substring(rs.length - 2);"," num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();"," String gs = gn.toInt().toRadixString(16);"," gs = '0$gs';"," gs = gs.substring(gs.length - 2);"," num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();"," String bs = bn.toInt().toRadixString(16);"," bs = '0$bs';"," bs = bs.substring(bs.length - 2);"," return '#$rs$gs$bs';","}"])+"("+b+", "+c+", "+a+")",Blockly.Dart.ORDER_UNARY_POSTFIX]}; @@ -39,17 +39,20 @@ Blockly.Dart.ORDER_UNARY_POSTFIX]}; Blockly.Dart.lists_sort=function(a){var b=Blockly.Dart.valueToCode(a,"LIST",Blockly.Dart.ORDER_NONE)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[Blockly.Dart.provideFunction_("lists_sort",["List "+Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List list, String type, int direction) {"," var compareFuncs = {",' "NUMERIC": (a, b) => (direction * a.compareTo(b)).toInt(),',' "TEXT": (a, b) => direction * a.toString().compareTo(b.toString()),',' "IGNORE_CASE": ', " (a, b) => direction * "," a.toString().toLowerCase().compareTo(b.toString().toLowerCase())"," };"," list = new List.from(list);"," var compare = compareFuncs[type];"," list.sort(compare);"," return list;","}"])+"("+b+', "'+a+'", '+c+")",Blockly.Dart.ORDER_UNARY_POSTFIX]}; Blockly.Dart.lists_split=function(a){var b=Blockly.Dart.valueToCode(a,"INPUT",Blockly.Dart.ORDER_UNARY_POSTFIX),c=Blockly.Dart.valueToCode(a,"DELIM",Blockly.Dart.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"==a)b||(b="''"),a="split";else if("JOIN"==a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+a);return[b+"."+a+"("+c+")",Blockly.Dart.ORDER_UNARY_POSTFIX]}; -Blockly.Dart.lists_reverse=function(a){return["new List.from("+(Blockly.Dart.valueToCode(a,"LIST",Blockly.Dart.ORDER_NONE)||"[]")+".reversed)",Blockly.Dart.ORDER_UNARY_POSTFIX]};Blockly.Dart.logic={};Blockly.Dart.controls_if=function(a){var b=0,c="";do{var d=Blockly.Dart.valueToCode(a,"IF"+b,Blockly.Dart.ORDER_NONE)||"false";var e=Blockly.Dart.statementToCode(a,"DO"+b);c+=(0",GTE:">="}[a.getFieldValue("OP")],c="=="==b||"!="==b?Blockly.Dart.ORDER_EQUALITY:Blockly.Dart.ORDER_RELATIONAL,d=Blockly.Dart.valueToCode(a,"A",c)||"0";a=Blockly.Dart.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]}; Blockly.Dart.logic_operation=function(a){var b="AND"==a.getFieldValue("OP")?"&&":"||",c="&&"==b?Blockly.Dart.ORDER_LOGICAL_AND:Blockly.Dart.ORDER_LOGICAL_OR,d=Blockly.Dart.valueToCode(a,"A",c);a=Blockly.Dart.valueToCode(a,"B",c);if(d||a){var e="&&"==b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};Blockly.Dart.logic_negate=function(a){var b=Blockly.Dart.ORDER_UNARY_PREFIX;return["!"+(Blockly.Dart.valueToCode(a,"BOOL",b)||"true"),b]}; Blockly.Dart.logic_boolean=function(a){return["TRUE"==a.getFieldValue("BOOL")?"true":"false",Blockly.Dart.ORDER_ATOMIC]};Blockly.Dart.logic_null=function(a){return["null",Blockly.Dart.ORDER_ATOMIC]};Blockly.Dart.logic_ternary=function(a){var b=Blockly.Dart.valueToCode(a,"IF",Blockly.Dart.ORDER_CONDITIONAL)||"false",c=Blockly.Dart.valueToCode(a,"THEN",Blockly.Dart.ORDER_CONDITIONAL)||"null";a=Blockly.Dart.valueToCode(a,"ELSE",Blockly.Dart.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,Blockly.Dart.ORDER_CONDITIONAL]};Blockly.Dart.loops={}; -Blockly.Dart.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):Blockly.Dart.valueToCode(a,"TIMES",Blockly.Dart.ORDER_ASSIGNMENT)||"0",c=Blockly.Dart.statementToCode(a,"DO");c=Blockly.Dart.addLoopTrap(c,a.id);a="";var d=Blockly.Dart.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE),e=b;b.match(/^\w+$/)||Blockly.isNumber(b)||(e=Blockly.Dart.variableDB_.getDistinctName("repeat_end",Blockly.Variables.NAME_TYPE),a+="var "+e+" = "+b+";\n"); -return a+("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};Blockly.Dart.controls_repeat=Blockly.Dart.controls_repeat_ext;Blockly.Dart.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=Blockly.Dart.valueToCode(a,"BOOL",b?Blockly.Dart.ORDER_UNARY_PREFIX:Blockly.Dart.ORDER_NONE)||"false",d=Blockly.Dart.statementToCode(a,"DO");d=Blockly.Dart.addLoopTrap(d,a.id);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"}; -Blockly.Dart.controls_for=function(a){var b=Blockly.Dart.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.Dart.valueToCode(a,"FROM",Blockly.Dart.ORDER_ASSIGNMENT)||"0",d=Blockly.Dart.valueToCode(a,"TO",Blockly.Dart.ORDER_ASSIGNMENT)||"0",e=Blockly.Dart.valueToCode(a,"BY",Blockly.Dart.ORDER_ASSIGNMENT)||"1",f=Blockly.Dart.statementToCode(a,"DO");f=Blockly.Dart.addLoopTrap(f,a.id);if(Blockly.isNumber(c)&&Blockly.isNumber(d)&&Blockly.isNumber(e)){var g=parseFloat(c)<= -parseFloat(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(parseFloat(e));a=(1==b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||Blockly.isNumber(c)||(g=Blockly.Dart.variableDB_.getDistinctName(b+"_start",Blockly.Variables.NAME_TYPE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||Blockly.isNumber(d)||(c=Blockly.Dart.variableDB_.getDistinctName(b+"_end",Blockly.Variables.NAME_TYPE),a+="var "+c+" = "+d+";\n"),d=Blockly.Dart.variableDB_.getDistinctName(b+ +Blockly.Dart.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):Blockly.Dart.valueToCode(a,"TIMES",Blockly.Dart.ORDER_ASSIGNMENT)||"0",c=Blockly.Dart.statementToCode(a,"DO");c=Blockly.Dart.addLoopTrap(c,a);a="";var d=Blockly.Dart.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE),e=b;b.match(/^\w+$/)||Blockly.isNumber(b)||(e=Blockly.Dart.variableDB_.getDistinctName("repeat_end",Blockly.Variables.NAME_TYPE),a+="var "+e+" = "+b+";\n");return a+ +("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};Blockly.Dart.controls_repeat=Blockly.Dart.controls_repeat_ext;Blockly.Dart.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=Blockly.Dart.valueToCode(a,"BOOL",b?Blockly.Dart.ORDER_UNARY_PREFIX:Blockly.Dart.ORDER_NONE)||"false",d=Blockly.Dart.statementToCode(a,"DO");d=Blockly.Dart.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"}; +Blockly.Dart.controls_for=function(a){var b=Blockly.Dart.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.Dart.valueToCode(a,"FROM",Blockly.Dart.ORDER_ASSIGNMENT)||"0",d=Blockly.Dart.valueToCode(a,"TO",Blockly.Dart.ORDER_ASSIGNMENT)||"0",e=Blockly.Dart.valueToCode(a,"BY",Blockly.Dart.ORDER_ASSIGNMENT)||"1",f=Blockly.Dart.statementToCode(a,"DO");f=Blockly.Dart.addLoopTrap(f,a);if(Blockly.isNumber(c)&&Blockly.isNumber(d)&&Blockly.isNumber(e)){var g=parseFloat(c)<=parseFloat(d); +a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(parseFloat(e));a=(1==b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||Blockly.isNumber(c)||(g=Blockly.Dart.variableDB_.getDistinctName(b+"_start",Blockly.Variables.NAME_TYPE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||Blockly.isNumber(d)||(c=Blockly.Dart.variableDB_.getDistinctName(b+"_end",Blockly.Variables.NAME_TYPE),a+="var "+c+" = "+d+";\n"),d=Blockly.Dart.variableDB_.getDistinctName(b+ "_inc",Blockly.Variables.NAME_TYPE),a+="num "+d+" = ",a=Blockly.isNumber(e)?a+(Math.abs(e)+";\n"):a+("("+e+").abs();\n"),a=a+("if ("+g+" > "+c+") {\n")+(Blockly.Dart.INDENT+d+" = -"+d+";\n"),a+="}\n",a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n";return a}; -Blockly.Dart.controls_forEach=function(a){var b=Blockly.Dart.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.Dart.valueToCode(a,"LIST",Blockly.Dart.ORDER_ASSIGNMENT)||"[]",d=Blockly.Dart.statementToCode(a,"DO");d=Blockly.Dart.addLoopTrap(d,a.id);return"for (var "+b+" in "+c+") {\n"+d+"}\n"}; -Blockly.Dart.controls_flow_statements=function(a){switch(a.getFieldValue("FLOW")){case "BREAK":return"break;\n";case "CONTINUE":return"continue;\n"}throw Error("Unknown flow statement.");};Blockly.Dart.math={};Blockly.Dart.addReservedWords("Math");Blockly.Dart.math_number=function(a){a=parseFloat(a.getFieldValue("NUM"));if(Infinity==a){a="double.infinity";var b=Blockly.Dart.ORDER_UNARY_POSTFIX}else-Infinity==a?(a="-double.infinity",b=Blockly.Dart.ORDER_UNARY_PREFIX):b=0>a?Blockly.Dart.ORDER_UNARY_PREFIX:Blockly.Dart.ORDER_ATOMIC;return[a,b]}; +Blockly.Dart.controls_forEach=function(a){var b=Blockly.Dart.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.Dart.valueToCode(a,"LIST",Blockly.Dart.ORDER_ASSIGNMENT)||"[]",d=Blockly.Dart.statementToCode(a,"DO");d=Blockly.Dart.addLoopTrap(d,a);return"for (var "+b+" in "+c+") {\n"+d+"}\n"}; +Blockly.Dart.controls_flow_statements=function(a){var b="";Blockly.Dart.STATEMENT_PREFIX&&(b+=Blockly.Dart.injectId(Blockly.Dart.STATEMENT_PREFIX,a));Blockly.Dart.STATEMENT_SUFFIX&&(b+=Blockly.Dart.injectId(Blockly.Dart.STATEMENT_SUFFIX,a));if(Blockly.Dart.STATEMENT_PREFIX){var c=Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.getSurroundLoop(a);c&&!c.suppressPrefixSuffix&&(b+=Blockly.Dart.injectId(Blockly.Dart.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break;\n"; +case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");};Blockly.Dart.math={};Blockly.Dart.addReservedWords("Math");Blockly.Dart.math_number=function(a){a=parseFloat(a.getFieldValue("NUM"));if(Infinity==a){a="double.infinity";var b=Blockly.Dart.ORDER_UNARY_POSTFIX}else-Infinity==a?(a="-double.infinity",b=Blockly.Dart.ORDER_UNARY_PREFIX):b=0>a?Blockly.Dart.ORDER_UNARY_PREFIX:Blockly.Dart.ORDER_ATOMIC;return[a,b]}; Blockly.Dart.math_arithmetic=function(a){var b={ADD:[" + ",Blockly.Dart.ORDER_ADDITIVE],MINUS:[" - ",Blockly.Dart.ORDER_ADDITIVE],MULTIPLY:[" * ",Blockly.Dart.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",Blockly.Dart.ORDER_MULTIPLICATIVE],POWER:[null,Blockly.Dart.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=Blockly.Dart.valueToCode(a,"A",b)||"0";a=Blockly.Dart.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:(Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",["Math.pow("+d+", "+ a+")",Blockly.Dart.ORDER_UNARY_POSTFIX])}; Blockly.Dart.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"==b)return a=Blockly.Dart.valueToCode(a,"NUM",Blockly.Dart.ORDER_UNARY_PREFIX)||"0","-"==a[0]&&(a=" "+a),["-"+a,Blockly.Dart.ORDER_UNARY_PREFIX];Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";a="ABS"==b||"ROUND"==b.substring(0,5)?Blockly.Dart.valueToCode(a,"NUM",Blockly.Dart.ORDER_UNARY_POSTFIX)||"0":"SIN"==b||"COS"==b||"TAN"==b?Blockly.Dart.valueToCode(a,"NUM",Blockly.Dart.ORDER_MULTIPLICATIVE)||"0": @@ -74,11 +77,10 @@ Blockly.Dart.math_constrain=function(a){Blockly.Dart.definitions_.import_dart_ma Blockly.Dart.math_random_int=function(a){Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=Blockly.Dart.valueToCode(a,"FROM",Blockly.Dart.ORDER_NONE)||"0";a=Blockly.Dart.valueToCode(a,"TO",Blockly.Dart.ORDER_NONE)||"0";return[Blockly.Dart.provideFunction_("math_random_int",["int "+Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num a, num b) {"," if (a > b) {"," // Swap a and b to ensure a is smaller."," num c = a;"," a = b;"," b = c;"," }"," return new Math.Random().nextInt(b - a + 1) + a;", "}"])+"("+b+", "+a+")",Blockly.Dart.ORDER_UNARY_POSTFIX]};Blockly.Dart.math_random_float=function(a){Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return["new Math.Random().nextDouble()",Blockly.Dart.ORDER_UNARY_POSTFIX]}; Blockly.Dart.math_atan2=function(a){Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=Blockly.Dart.valueToCode(a,"X",Blockly.Dart.ORDER_NONE)||"0";return["Math.atan2("+(Blockly.Dart.valueToCode(a,"Y",Blockly.Dart.ORDER_NONE)||"0")+", "+b+") / Math.pi * 180",Blockly.Dart.ORDER_MULTIPLICATIVE]};Blockly.Dart.procedures={}; -Blockly.Dart.procedures_defreturn=function(a){var b=Blockly.Dart.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=Blockly.Dart.statementToCode(a,"STACK");if(Blockly.Dart.STATEMENT_PREFIX){var d=a.id.replace(/\$/g,"$$$$");c=Blockly.Dart.prefixLines(Blockly.Dart.STATEMENT_PREFIX.replace(/%1/g,"'"+d+"'"),Blockly.Dart.INDENT)+c}Blockly.Dart.INFINITE_LOOP_TRAP&&(c=Blockly.Dart.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);(d=Blockly.Dart.valueToCode(a,"RETURN",Blockly.Dart.ORDER_NONE)|| -"")&&(d=Blockly.Dart.INDENT+"return "+d+";\n");for(var e=d?"dynamic":"void",f=[],g=0;g - - Accessible Blockly Demo - - - - - - - - - - - - - - - - + -

    - Blockly > - Demos > Accessible Blockly -

    - -

    - This is a demo of a version of Blockly designed for screen readers, - optimized for NVDA on Firefox. It allows users to create programs in a - workspace by manipulating groups of blocks. -

      -
    • To explore a group of blocks, use the arrow keys.
    • -
    • To navigate between groups, use Tab or Shift-Tab.
    • -
    • To add new blocks, use the buttons in the menu on the right.
    • -
    • To delete or add links to existing blocks, press Enter while you're on that block.
    • -
    -

    - - - - - - - - - + +

    This demo has moved to a new repository.

    + diff --git a/demos/blockfactory/app_controller.js b/demos/blockfactory/app_controller.js index 4902f760e28..d6e8cd2568f 100644 --- a/demos/blockfactory/app_controller.js +++ b/demos/blockfactory/app_controller.js @@ -26,8 +26,6 @@ * @author quachtina96 (Tina Quach) */ -goog.require('goog.dom.xml'); // Used to detect Closure - /** * Controller for the Blockly Factory * @constructor @@ -152,7 +150,7 @@ AppController.prototype.exportBlockLibraryToFile = function() { */ AppController.prototype.formatBlockLibraryForExport_ = function(blockXmlMap) { // Create DOM for XML. - var xmlDom = document.createElementNS('http://www.w3.org/1999/xhtml', 'xml'); + var xmlDom = Blockly.utils.xml.createElement('xml'); // Append each block node to XML DOM. for (var blockType in blockXmlMap) { @@ -187,8 +185,7 @@ AppController.prototype.formatBlockLibraryForImport_ = function(xmlText) { // Add outer XML tag to the block for proper injection in to the // main workspace. // Create DOM for XML. - var editorWorkspaceXml = - document.createElementNS('http://www.w3.org/1999/xhtml', 'xml'); + var editorWorkspaceXml = Blockly.utils.xml.createElement('xml'); editorWorkspaceXml.appendChild(blockNode); xmlText = Blockly.Xml.domToText(editorWorkspaceXml); @@ -678,20 +675,6 @@ AppController.prototype.modalName_ = null; * Initialize Blockly and layout. Called on page load. */ AppController.prototype.init = function() { - // Block Factory has a dependency on bits of Closure that core Blockly - // doesn't have. When you run this from file:// without a copy of Closure, - // it breaks it non-obvious ways. Warning about this for now until the - // dependency is broken. - // TODO: #668. - if (!window.goog.dom.xml) { - alert('Sorry: Closure dependency not found. We are working on removing ' + - 'this dependency. In the meantime, you can use our hosted demo\n ' + - 'https://blockly-demo.appspot.com/static/demos/blockfactory/index.html' + - '\nor use these instructions to continue running locally:\n' + - 'https://developers.google.com/blockly/guides/modify/web/closure'); - return; - } - var self = this; // Handle Blockly Storage with App Engine. if ('BlocklyStorage' in window) { @@ -718,6 +701,8 @@ AppController.prototype.init = function() { BlockFactory.mainWorkspace = Blockly.inject('blockly', {collapse: false, toolbox: toolbox, + comments: false, + disable: false, media: '../../media/'}); // Add tab handlers for switching between Block Factory and Block Exporter. diff --git a/demos/blockfactory/block_definition_extractor.js b/demos/blockfactory/block_definition_extractor.js index 6c75a70cf43..fb21499a534 100644 --- a/demos/blockfactory/block_definition_extractor.js +++ b/demos/blockfactory/block_definition_extractor.js @@ -39,10 +39,8 @@ var BlockDefinitionExtractor = BlockDefinitionExtractor || Object.create(null); * workspace. */ BlockDefinitionExtractor.buildBlockFactoryWorkspace = function(block) { - var workspaceXml = document.createElement('xml'); - workspaceXml.append( - BlockDefinitionExtractor.factoryBase_(block, block.type)); - + var workspaceXml = Blockly.utils.xml.createElement('xml'); + workspaceXml.append(BlockDefinitionExtractor.factoryBase_(block, block.type)); return workspaceXml; }; @@ -58,7 +56,7 @@ BlockDefinitionExtractor.buildBlockFactoryWorkspace = function(block) { */ BlockDefinitionExtractor.newDomElement_ = function(name, opt_attrs, opt_text) { // Avoid createDom(..)'s attributes argument for being too HTML specific. - var elem = document.createElement(name); + var elem = Blockly.utils.xml.createElement(name); if (opt_attrs) { for (var key in opt_attrs) { elem.setAttribute(key, opt_attrs[key]); diff --git a/demos/blockfactory/block_library_controller.js b/demos/blockfactory/block_library_controller.js index 843e98c33f4..11744906f13 100644 --- a/demos/blockfactory/block_library_controller.js +++ b/demos/blockfactory/block_library_controller.js @@ -136,7 +136,7 @@ BlockLibraryController.prototype.saveToBlockLibrary = function() { } // Create block XML. - var xmlElement = document.createElement('xml'); + var xmlElement = Blockly.utils.xml.createElement('xml'); var block = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace); xmlElement.appendChild(Blockly.Xml.blockToDomWithXY(block)); diff --git a/demos/blockfactory/block_library_storage.js b/demos/blockfactory/block_library_storage.js index 257cd98c6de..f1e292a9316 100644 --- a/demos/blockfactory/block_library_storage.js +++ b/demos/blockfactory/block_library_storage.js @@ -118,7 +118,7 @@ BlockLibraryStorage.prototype.getBlockXml = function(blockType) { * @return {!Object} Map of block type to corresponding XML. */ BlockLibraryStorage.prototype.getBlockXmlMap = function(blockTypes) { - var blockXmlMap = {}; + var blockXmlMap = Object.create(null); for (var i = 0; i < blockTypes.length; i++) { var blockType = blockTypes[i]; var xml = this.getBlockXml(blockType); diff --git a/demos/blockfactory/blocks.js b/demos/blockfactory/blocks.js index 15a7f2a41a2..59e0b25e7ae 100644 --- a/demos/blockfactory/blocks.js +++ b/demos/blockfactory/blocks.js @@ -46,9 +46,9 @@ Blockly.Blocks['factory_base'] = { ['↑ top connection', 'TOP'], ['↓ bottom connection', 'BOTTOM']], function(option) { - this.sourceBlock_.updateShape_(option); + this.getSourceBlock().updateShape_(option); // Connect a shadow block to this new input. - this.sourceBlock_.spawnOutputShadow_(option); + this.getSourceBlock().spawnOutputShadow_(option); }); this.appendDummyInput() .appendField(dropdown, 'CONNECTIONS'); @@ -67,7 +67,7 @@ Blockly.Blocks['factory_base'] = { 'https://developers.google.com/blockly/guides/create-custom-blocks/block-factory'); }, mutationToDom: function() { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('connections', this.getFieldValue('CONNECTIONS')); return container; }, @@ -244,13 +244,33 @@ Blockly.Blocks['field_static'] = { // Text value. init: function() { this.setColour(160); - this.appendDummyInput() + this.appendDummyInput('FIRST') .appendField('text') .appendField(new Blockly.FieldTextInput(''), 'TEXT'); this.setPreviousStatement(true, 'Field'); this.setNextStatement(true, 'Field'); this.setTooltip('Static text that serves as a label.'); this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=88'); + }, +}; + +Blockly.Blocks['field_label_serializable'] = { + // Text value that is saved to XML. + init: function() { + this.setColour(160); + this.appendDummyInput('FIRST') + .appendField('text') + .appendField(new Blockly.FieldTextInput(''), 'TEXT') + .appendField(',') + .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME'); + this.setPreviousStatement(true, 'Field'); + this.setNextStatement(true, 'Field'); + this.setTooltip('Static text that serves as a label, and is saved to' + + ' XML. Use only if you want to modify this label at runtime.'); + this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=88'); + }, + onchange: function() { + fieldNameCheck(this); } }; @@ -336,7 +356,7 @@ Blockly.Blocks['field_dropdown'] = { }, mutationToDom: function(workspace) { // Create XML to represent menu options. - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('options', JSON.stringify(this.optionList_)); return container; }, @@ -628,7 +648,7 @@ Blockly.Blocks['type_group'] = { }, mutationToDom: function(workspace) { // Create XML to represent a group of types. - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('types', this.typeCount_); return container; }, @@ -843,11 +863,11 @@ Blockly.Blocks['colour_hue'] = { // Update the current block's colour to match. var hue = parseInt(text, 10); if (!isNaN(hue)) { - this.sourceBlock_.setColour(hue); + this.getSourceBlock().setColour(hue); } }, mutationToDom: function(workspace) { - var container = document.createElement('mutation'); + var container = Blockly.utils.xml.createElement('mutation'); container.setAttribute('colour', this.getColour()); return container; }, diff --git a/demos/blockfactory/cp.css b/demos/blockfactory/cp.css new file mode 100644 index 00000000000..508533e1627 --- /dev/null +++ b/demos/blockfactory/cp.css @@ -0,0 +1,46 @@ +.cp_swatch { + border: outset 3px #888; + display: inline-block; + font-family: sans-serif; + height: 20px; + line-height: 1.4; + margin: 1px; + text-align: center; + width: 30px; + vertical-align: bottom; +} + +#cp_popup { + cursor: default; + font-family: sans-serif; + left: 0; + position: absolute; + text-align: center; + top: 0; + user-select: none; +} + +#cp_popup>table { + border: 2px solid #808080; + background-color: #808080; + border-collapse: collapse; +} + +#cp_popup>table>tbody>tr>td { + border: 1px solid #808080; + background-color: #fff; + width: 20px; + padding: 0; +} + +#cp_popup>table>tbody>tr>td>div { + border: 1px solid #808080; +} + +#cp_popup>table>tbody>tr>td>div:hover { + border-color: #fff; +} + +#cp_popup>table>tbody>tr>td>div.cp_current { + border: 1px solid #000; +} diff --git a/demos/blockfactory/cp.js b/demos/blockfactory/cp.js new file mode 100644 index 00000000000..9ba012d4c6c --- /dev/null +++ b/demos/blockfactory/cp.js @@ -0,0 +1,190 @@ +/** + * Colour Picker v2.0 + * + * Copyright 2006 Neil Fraser + * https://neil.fraser.name/software/colourpicker/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Include at the top of your page: +// +// +// Call with: +// +// + +var cp_grid = [ + ['ffffff', 'ffcccc', 'ffcc99', 'ffff99', 'ffffcc', '99ff99', '99ffff', 'ccffff', 'ccccff', 'ffccff'], + ['cccccc', 'ff6666', 'ff9966', 'ffff66', 'ffff33', '66ff99', '33ffff', '66ffff', '9999ff', 'ff99ff'], + ['c0c0c0', 'ff0000', 'ff9900', 'ffcc66', 'ffff00', '33ff33', '66cccc', '33ccff', '6666cc', 'cc66cc'], + ['999999', 'cc0000', 'ff6600', 'ffcc33', 'ffcc00', '33cc00', '00cccc', '3366ff', '6633ff', 'cc33cc'], + ['666666', '990000', 'cc6600', 'cc9933', '999900', '009900', '339999', '3333ff', '6600cc', '993399'], + ['333333', '660000', '993300', '996633', '666600', '006600', '336666', '000099', '333399', '663366'], + ['000000', '330000', '663300', '663333', '333300', '003300', '003333', '000066', '330099', '330033'], + [''] +]; + +var cp_popupDom = null; +var cp_activeSwatch = null; +var cp_closePid = null; + +function cp_init(id) { + var input = document.getElementById(id); + if (!input) { + throw Error('Colour picker can\'t find "' + id + '"'); + } + if (!input.cp_swatch) { + // Hide the input. + input.type = 'hidden'; + // + var swatch = document.createElement('span'); + swatch.className = 'cp_swatch'; + swatch.addEventListener('click', cp_open); + swatch.addEventListener('mouseover', cp_cancelclose); + swatch.addEventListener('mouseout', cp_closesoon); + input.parentNode.insertBefore(swatch, input); + // Cross-link the swatch and input. + swatch.cp_input = input; + input.cp_swatch = swatch; + } + cp_updateSwatch(input.cp_swatch); +} + +function cp_updateSwatch(swatch) { + var colour = swatch.cp_input.value; + if (colour) { + swatch.style.backgroundColor = '#' + colour; + swatch.textContent = '\xa0'; + } else { + swatch.style.backgroundColor = '#fff'; + swatch.innerHTML = 'X'; + } +} + +function cp_open(e) { + // Create a table of colours. + if (cp_popupDom) { + cp_close(); + return; + } + cp_activeSwatch = e.currentTarget; + var currentColour = cp_activeSwatch.cp_input.value.toLowerCase(); + var element = cp_activeSwatch; + var posX = 0; + var posY = element.offsetHeight; + while (element) { + posX += element.offsetLeft; + posY += element.offsetTop; + element = element.offsetParent; + } + cp_popupDom = document.createElement('div'); + cp_popupDom.id = 'cp_popup'; + var table = document.createElement('table'); + table.addEventListener('mouseover', cp_cancelclose); + table.addEventListener('mouseout', cp_closesoon); + table.addEventListener('click', cp_onclick); + var tbody = document.createElement('tbody'); + var row, cell, div; + for (var y = 0; y < cp_grid.length; y++) { + row = document.createElement('tr'); + tbody.appendChild(row); + for (var x = 0; x < cp_grid[y].length; x++) { + var colour = cp_grid[y][x]; + if (colour === undefined) continue; + cell = document.createElement('td'); + row.appendChild(cell); + div = document.createElement('div'); + cell.appendChild(div); + cell.cp_colour = colour; + if (colour) { + div.style.backgroundColor = '#' + colour; + div.innerHTML = '\xa0'; + } else { + div.innerHTML = 'X'; + } + if (currentColour == colour.toLowerCase()) { + div.className = 'cp_current' + } + } + } + table.appendChild(tbody); + cp_popupDom.appendChild(table); + + document.body.appendChild(cp_popupDom); + // Don't widen the screen. + var rightOverhang = (posX + cp_popupDom.offsetWidth) - + (window.innerWidth + window.scrollX) + 15; // Scrollbar is 15px. + if (rightOverhang > 0) { + posX -= rightOverhang; + } + // Flip to above swatch if no room below. + if (posY + cp_popupDom.offsetHeight >= window.innerHeight + window.scrollY) { + posY -= cp_popupDom.offsetHeight + cp_activeSwatch.offsetHeight; + if (posY < window.scrollY) { + posY = window.scrollY; + } + } + cp_popupDom.style.left = posX + 'px'; + cp_popupDom.style.top = posY + 'px'; +} + +function cp_close() { + // Close the table now. + cp_cancelclose(); + if (cp_popupDom) { + document.body.removeChild(cp_popupDom) + } + cp_popupDom = null; + cp_activeSwatch = null; +} + +function cp_closesoon() { + // Close the table a split-second from now. + cp_closePid = setTimeout(cp_close, 250); +} + +function cp_cancelclose() { + // Don't close the colour table after all. + if (cp_closePid) { + clearTimeout(cp_closePid); + } +} + +function cp_onclick(e) { + // Clicked on a colour. + var element = e.target; + var colour; + // Walk up the DOM, looking for a colour. + while (element) { + colour = element.cp_colour; + if (colour !== undefined) { + break; + } + element = element.parentNode; + } + if (colour !== undefined) { + // Set the colour. + cp_activeSwatch.cp_input.value = colour; + cp_updateSwatch(cp_activeSwatch); + // Fire a change event. + var evt = document.createEvent('HTMLEvents'); + evt.initEvent('change', false, true); + cp_activeSwatch.cp_input.dispatchEvent(evt); + } + // Close the table. + cp_close(); +} diff --git a/demos/blockfactory/factory.css b/demos/blockfactory/factory.css index 6661c139c87..e4b6ec258b3 100644 --- a/demos/blockfactory/factory.css +++ b/demos/blockfactory/factory.css @@ -56,11 +56,11 @@ td { p { display: block; - -webkit-margin-before: 0em; - -webkit-margin-after: 0em; - -webkit-margin-start: 0px; - -webkit-margin-end: 0px; - padding: 5px 0px; + -webkit-margin-before: 0; + -webkit-margin-after: 0; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + padding: 5px 0; } #factoryHeader { @@ -233,7 +233,7 @@ button, .buttonStyle { } .subsettings { - margin: 0px 25px; + margin: 0 25px; } #exporterHiddenWorkspace { @@ -511,53 +511,10 @@ td.taboff:hover { right: 0; bottom: 0; left: 0; - background: rgba(0, 0, 0, 0.05); + background: rgba(0, 0, 0, 0.1); z-index: 100; } -/* Rules for Closure popup color picker */ -.goog-palette { - outline: none; - cursor: default; -} - -.goog-palette-cell { - height: 13px; - width: 15px; - margin: 0; - border: 0; - text-align: center; - vertical-align: middle; - border-right: 1px solid #000; - font-size: 1px; -} - -.goog-palette-colorswatch { - border: 1px solid #000; - height: 13px; - position: relative; - width: 15px; -} - -.goog-palette-cell-hover .goog-palette-colorswatch { - border: 1px solid #fff; -} - -.goog-palette-cell-selected .goog-palette-colorswatch { - border: 1px solid #000; - color: #fff; -} - -.goog-palette-table { - border: 1px solid #000; - border-collapse: collapse; -} - -.goog-popupcolorpicker { - position: absolute; - z-index: 101; /* On top of the modal Shadow. */ -} - /* The container
    - needed to position the dropdown content */ .dropdown { display: inline-block; @@ -566,7 +523,7 @@ td.taboff:hover { /* Dropdown Content (Hidden by Default) */ .dropdown-content { background-color: #fff; - box-shadow: 0px 8px 16px 0px rgba(0,0,0,.2); + box-shadow: 0 8px 16px 0 rgba(0,0,0,.2); display: none; min-width: 170px; opacity: 1; @@ -598,6 +555,22 @@ td.taboff:hover { display: block; } +#dropdownDiv_editCategory { + padding: 0 1ex; +} + +#dropdownDiv_editCategory>img { + vertical-align: middle; +} + +.cp_swatch { + vertical-align: middle !important; +} + +#cp_popup { + z-index: 999; +} + .shadowBlock>.blocklyPath { fill-opacity: .5; stroke-opacity: .5; diff --git a/demos/blockfactory/factory.js b/demos/blockfactory/factory.js index 5edf90c22b2..e3df005b28a 100644 --- a/demos/blockfactory/factory.js +++ b/demos/blockfactory/factory.js @@ -78,8 +78,9 @@ BlockFactory.updateBlocksFlagDelayed = false; * The starting XML for the Block Factory main workspace. Contains the * unmovable, undeletable factory_base block. */ -BlockFactory.STARTER_BLOCK_XML_TEXT = '' + +BlockFactory.STARTER_BLOCK_XML_TEXT = + '' + + '' + '' + '' + '' + diff --git a/demos/blockfactory/factory_utils.js b/demos/blockfactory/factory_utils.js index 4006d43087d..ee1b32807c7 100644 --- a/demos/blockfactory/factory_utils.js +++ b/demos/blockfactory/factory_utils.js @@ -151,11 +151,12 @@ FactoryUtils.getGeneratorStub = function(block, generatorLanguage) { } } } - // Most languages end lines with a semicolon. Python does not. + // Most languages end lines with a semicolon. Python & Lua do not. var lineEnd = { 'JavaScript': ';', 'Python': '', 'PHP': ';', + 'Lua': '', 'Dart': ';' }; code.push(" // TODO: Assemble " + language + " into code variable."); @@ -406,6 +407,12 @@ FactoryUtils.getFieldsJs_ = function(block) { // Result: 'hello' fields.push(JSON.stringify(block.getFieldValue('TEXT'))); break; + case 'field_label_serializable': + // Result: new Blockly.FieldLabelSerializable('Hello'), 'GREET' + fields.push('new Blockly.FieldLabelSerializable(' + + JSON.stringify(block.getFieldValue('TEXT')) + '), ' + + JSON.stringify(block.getFieldValue('FIELDNAME'))); + break; case 'field_input': // Result: new Blockly.FieldTextInput('Hello'), 'GREET' fields.push('new Blockly.FieldTextInput(' + @@ -511,6 +518,13 @@ FactoryUtils.getFieldsJson_ = function(block) { // Result: 'hello' fields.push(block.getFieldValue('TEXT')); break; + case 'field_label_serializable': + fields.push({ + type: block.type, + name: block.getFieldValue('FIELDNAME'), + text: block.getFieldValue('TEXT') + }); + break; case 'field_input': fields.push({ type: block.type, @@ -766,7 +780,7 @@ FactoryUtils.getBlockTypeFromJsDefinition = function(blockDef) { */ FactoryUtils.generateCategoryXml = function(blocks, categoryName) { // Create category DOM element. - var categoryElement = document.createElement('category'); + var categoryElement = Blockly.utils.xml.createElement('category'); categoryElement.setAttribute('name', categoryName); // For each block, add block element to category. diff --git a/demos/blockfactory/index.html b/demos/blockfactory/index.html index c3b3bb80b0e..868d2054238 100644 --- a/demos/blockfactory/index.html +++ b/demos/blockfactory/index.html @@ -8,12 +8,12 @@ - + @@ -30,6 +30,7 @@ + + + + + + + +

    Blockly > + Demos > Custom Fields

    + + +

    This is a demo of creating custom block fields. In this case the field + is used to define a turtle. +

    + +

    All of the custom field implementation is in + demos/custom-fields/field_turtle.js, including comments on each required + function. +

    + +

    Click on the blocks' comment icons to learn what they are demonstrating. + Use the buttons below to see how the fields react to changes. +

    + +

    + + + + + +

    + +

    + + +

    + + + + + + +
    + + +
    +
    + + + + + + diff --git a/demos/custom-fields/media/crown.svg b/demos/custom-fields/media/crown.svg new file mode 100644 index 00000000000..3eebccb9228 --- /dev/null +++ b/demos/custom-fields/media/crown.svg @@ -0,0 +1 @@ +crown \ No newline at end of file diff --git a/demos/custom-fields/media/fedora.svg b/demos/custom-fields/media/fedora.svg new file mode 100644 index 00000000000..4a354491bd8 --- /dev/null +++ b/demos/custom-fields/media/fedora.svg @@ -0,0 +1 @@ +fedora \ No newline at end of file diff --git a/demos/custom-fields/media/mask.svg b/demos/custom-fields/media/mask.svg new file mode 100644 index 00000000000..eb4fded1c7a --- /dev/null +++ b/demos/custom-fields/media/mask.svg @@ -0,0 +1 @@ +mask \ No newline at end of file diff --git a/demos/custom-fields/media/propeller.svg b/demos/custom-fields/media/propeller.svg new file mode 100644 index 00000000000..bf0a433fd2b --- /dev/null +++ b/demos/custom-fields/media/propeller.svg @@ -0,0 +1 @@ +propeller \ No newline at end of file diff --git a/demos/custom-fields/media/stovepipe.svg b/demos/custom-fields/media/stovepipe.svg new file mode 100644 index 00000000000..6971ff7fdb6 --- /dev/null +++ b/demos/custom-fields/media/stovepipe.svg @@ -0,0 +1 @@ +stovepipe \ No newline at end of file diff --git a/demos/fixed/index.html b/demos/fixed/index.html index ec68625df89..85d634608f4 100644 --- a/demos/fixed/index.html +++ b/demos/fixed/index.html @@ -27,7 +27,7 @@

    Blockly >
    -

    -