/*

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 JS Signals <http://millermedeiros.github.com/js-signals/>
 Released under the MIT license
 Author: Miller Medeiros
 Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM)

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.
 MIT

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.

 Copyright 2016 Google 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.
*/
var $jscomp={scope:{},getGlobal:function(h){return"undefined"!=typeof window&&window===h?h:"undefined"!=typeof global?global:h}};$jscomp.global=$jscomp.getGlobal(this);$jscomp.initSymbol=function(){$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol);$jscomp.initSymbol=function(){}};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(h){return"jscomp_symbol_"+h+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();$jscomp.global.Symbol.iterator||($jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));$jscomp.initSymbolIterator=function(){}};
$jscomp.makeIterator=function(h){$jscomp.initSymbolIterator();if(h[$jscomp.global.Symbol.iterator])return h[$jscomp.global.Symbol.iterator]();if(!(h instanceof Array||"string"==typeof h||h instanceof String))throw new TypeError(h+" is not iterable");var d=0;return{next:function(){return d==h.length?{done:!0}:{done:!1,value:h[d++]}}}};$jscomp.arrayFromIterator=function(h){for(var d,f=[];!(d=h.next()).done;)f.push(d.value);return f};
$jscomp.arrayFromIterable=function(h){return h instanceof Array?h:$jscomp.arrayFromIterator($jscomp.makeIterator(h))};$jscomp.arrayFromArguments=function(h){for(var d=[],f=0;f<h.length;f++)d.push(h[f]);return d};$jscomp.inherits=function(h,d){function f(){}f.prototype=d.prototype;h.prototype=new f;h.prototype.constructor=h;for(var g in d)if($jscomp.global.Object.defineProperties){var c=$jscomp.global.Object.getOwnPropertyDescriptor(d,g);$jscomp.global.Object.defineProperty(h,g,c)}else h[g]=d[g]};
$jscomp.array=$jscomp.array||{};$jscomp.array.done_=function(){return{done:!0,value:void 0}};$jscomp.array.arrayIterator_=function(h,d){h instanceof String&&(h=String(h));var f=0;$jscomp.initSymbol();$jscomp.initSymbolIterator();var g={},c=(g.next=function(){if(f<h.length){var a=f++;return{value:d(a,h[a]),done:!1}}c.next=$jscomp.array.done_;return $jscomp.array.done_()},g[Symbol.iterator]=function(){return c},g);return c};
$jscomp.array.findInternal_=function(h,d,f){h instanceof String&&(h=String(h));for(var g=h.length,c=0;c<g;c++){var a=h[c];if(d.call(f,a,c,h))return{i:c,v:a}}return{i:-1,v:void 0}};
$jscomp.array.from=function(h,d,f){d=void 0===d?function(a){return a}:d;var g=[];$jscomp.initSymbol();$jscomp.initSymbolIterator();if(h[Symbol.iterator]){$jscomp.initSymbol();$jscomp.initSymbolIterator();h=h[Symbol.iterator]();for(var c;!(c=h.next()).done;)g.push(d.call(f,c.value))}else{c=h.length;for(var a=0;a<c;a++)g.push(d.call(f,h[a]))}return g};$jscomp.array.of=function(h){for(var d=[],f=0;f<arguments.length;++f)d[f-0]=arguments[f];return $jscomp.array.from(d)};
$jscomp.array.entries=function(){return $jscomp.array.arrayIterator_(this,function(h,d){return[h,d]})};$jscomp.array.entries$install=function(){Array.prototype.entries||(Array.prototype.entries=$jscomp.array.entries)};$jscomp.array.keys=function(){return $jscomp.array.arrayIterator_(this,function(h){return h})};$jscomp.array.keys$install=function(){Array.prototype.keys||(Array.prototype.keys=$jscomp.array.keys)};$jscomp.array.values=function(){return $jscomp.array.arrayIterator_(this,function(h,d){return d})};
$jscomp.array.values$install=function(){Array.prototype.values||(Array.prototype.values=$jscomp.array.values)};$jscomp.array.copyWithin=function(h,d,f){var g=this.length;h=Number(h);d=Number(d);f=Number(null!=f?f:g);if(h<d)for(f=Math.min(f,g);d<f;)d in this?this[h++]=this[d++]:(delete this[h++],d++);else for(f=Math.min(f,g+d-h),h+=f-d;f>d;)--f in this?this[--h]=this[f]:delete this[h];return this};$jscomp.array.copyWithin$install=function(){Array.prototype.copyWithin||(Array.prototype.copyWithin=$jscomp.array.copyWithin)};
$jscomp.array.fill=function(h,d,f){null!=f&&h.length||(f=this.length||0);f=Number(f);for(d=Number((void 0===d?0:d)||0);d<f;d++)this[d]=h;return this};$jscomp.array.fill$install=function(){Array.prototype.fill||(Array.prototype.fill=$jscomp.array.fill)};$jscomp.array.find=function(h,d){return $jscomp.array.findInternal_(this,h,d).v};$jscomp.array.find$install=function(){Array.prototype.find||(Array.prototype.find=$jscomp.array.find)};
$jscomp.array.findIndex=function(h,d){return $jscomp.array.findInternal_(this,h,d).i};$jscomp.array.findIndex$install=function(){Array.prototype.findIndex||(Array.prototype.findIndex=$jscomp.array.findIndex)};$jscomp.Map=function(h){h=void 0===h?[]:h;this.data_={};this.head_=$jscomp.Map.createHead_();this.size=0;if(h){h=$jscomp.makeIterator(h);for(var d=h.next();!d.done;d=h.next())d=d.value,this.set(d[0],d[1])}};
$jscomp.Map.checkBrowserConformance_=function(){var h=$jscomp.global.Map;if(!h||!h.prototype.entries||!Object.seal)return!1;try{var d=Object.seal({x:4}),f=new h($jscomp.makeIterator([[d,"s"]]));if("s"!=f.get(d)||1!=f.size||f.get({x:4})||f.set({x:4},"t")!=f||2!=f.size)return!1;var g=f.entries(),c=g.next();if(c.done||c.value[0]!=d||"s"!=c.value[1])return!1;c=g.next();return c.done||4!=c.value[0].x||"t"!=c.value[1]||!g.next().done?!1:!0}catch(a){return!1}};
$jscomp.Map.createHead_=function(){var h={};return h.previous=h.next=h.head=h};$jscomp.Map.getId_=function(h){if(!(h instanceof Object))return String(h);$jscomp.Map.key_ in h||h instanceof Object&&Object.isExtensible&&Object.isExtensible(h)&&$jscomp.Map.defineProperty_(h,$jscomp.Map.key_,++$jscomp.Map.index_);return $jscomp.Map.key_ in h?h[$jscomp.Map.key_]:" "+h};
$jscomp.Map.prototype.set=function(h,d){var f=this.maybeGetEntry_(h),g=f.id,c=f.list,f=f.entry;c||(c=this.data_[g]=[]);f?f.value=d:(f={next:this.head_,previous:this.head_.previous,head:this.head_,key:h,value:d},c.push(f),this.head_.previous.next=f,this.head_.previous=f,this.size++);return this};
$jscomp.Map.prototype["delete"]=function(h){var d=this.maybeGetEntry_(h);h=d.id;var f=d.list,g=d.index;return(d=d.entry)&&f?(f.splice(g,1),f.length||delete this.data_[h],d.previous.next=d.next,d.next.previous=d.previous,d.head=null,this.size--,!0):!1};$jscomp.Map.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=$jscomp.Map.createHead_();this.size=0};$jscomp.Map.prototype.has=function(h){return!!this.maybeGetEntry_(h).entry};
$jscomp.Map.prototype.get=function(h){return(h=this.maybeGetEntry_(h).entry)&&h.value};$jscomp.Map.prototype.maybeGetEntry_=function(h){var d=$jscomp.Map.getId_(h),f=this.data_[d];if(f)for(var g=0;g<f.length;g++){var c=f[g];if(h!==h&&c.key!==c.key||h===c.key)return{id:d,list:f,index:g,entry:c}}return{id:d,list:f,index:-1,entry:void 0}};$jscomp.Map.prototype.entries=function(){return this.iter_(function(h){return[h.key,h.value]})};$jscomp.Map.prototype.keys=function(){return this.iter_(function(h){return h.key})};
$jscomp.Map.prototype.values=function(){return this.iter_(function(h){return h.value})};$jscomp.Map.prototype.forEach=function(h,d){for(var f=$jscomp.makeIterator(this.entries()),g=f.next();!g.done;g=f.next())g=g.value,h.call(d,g[1],g[0],this)};
$jscomp.Map.prototype.iter_=function(h){var d=this,f=this.head_;$jscomp.initSymbol();$jscomp.initSymbolIterator();var g={};return g.next=function(){if(f){for(;f.head!=d.head_;)f=f.previous;for(;f.next!=f.head;)return f=f.next,{done:!1,value:h(f)};f=null}return{done:!0,value:void 0}},g[Symbol.iterator]=function(){return this},g};$jscomp.Map.index_=0;$jscomp.Map.defineProperty_=Object.defineProperty?function(h,d,f){Object.defineProperty(h,d,{value:String(f)})}:function(h,d,f){h[d]=String(f)};
$jscomp.Map.Entry_=function(){};$jscomp.Map.ASSUME_NO_NATIVE=!1;$jscomp.Map$install=function(){$jscomp.initSymbol();$jscomp.initSymbolIterator();!$jscomp.Map.ASSUME_NO_NATIVE&&$jscomp.Map.checkBrowserConformance_()?$jscomp.Map=$jscomp.global.Map:($jscomp.initSymbol(),$jscomp.initSymbolIterator(),$jscomp.Map.prototype[Symbol.iterator]=$jscomp.Map.prototype.entries,$jscomp.initSymbol(),$jscomp.Map.key_=Symbol("map-id-key"));$jscomp.Map$install=function(){}};$jscomp.math=$jscomp.math||{};
$jscomp.math.clz32=function(h){h=Number(h)>>>0;if(0===h)return 32;var d=0;0===(h&4294901760)&&(h<<=16,d+=16);0===(h&4278190080)&&(h<<=8,d+=8);0===(h&4026531840)&&(h<<=4,d+=4);0===(h&3221225472)&&(h<<=2,d+=2);0===(h&2147483648)&&d++;return d};$jscomp.math.imul=function(h,d){h=Number(h);d=Number(d);var f=h&65535,g=d&65535;return f*g+((h>>>16&65535)*g+f*(d>>>16&65535)<<16>>>0)|0};$jscomp.math.sign=function(h){h=Number(h);return 0===h||isNaN(h)?h:0<h?1:-1};
$jscomp.math.log10=function(h){return Math.log(h)/Math.LN10};$jscomp.math.log2=function(h){return Math.log(h)/Math.LN2};$jscomp.math.log1p=function(h){h=Number(h);if(.25>h&&-.25<h){for(var d=h,f=1,g=h,c=0,a=1;c!=g;)d*=h,a*=-1,g=(c=g)+a*d/++f;return g}return Math.log(1+h)};$jscomp.math.expm1=function(h){h=Number(h);if(.25>h&&-.25<h){for(var d=h,f=1,g=h,c=0;c!=g;)d*=h/++f,g=(c=g)+d;return g}return Math.exp(h)-1};$jscomp.math.cosh=function(h){h=Number(h);return(Math.exp(h)+Math.exp(-h))/2};
$jscomp.math.sinh=function(h){h=Number(h);return 0===h?h:(Math.exp(h)-Math.exp(-h))/2};$jscomp.math.tanh=function(h){h=Number(h);if(0===h)return h;var d=Math.exp(2*-Math.abs(h)),d=(1-d)/(1+d);return 0>h?-d:d};$jscomp.math.acosh=function(h){h=Number(h);return Math.log(h+Math.sqrt(h*h-1))};$jscomp.math.asinh=function(h){h=Number(h);if(0===h)return h;var d=Math.log(Math.abs(h)+Math.sqrt(h*h+1));return 0>h?-d:d};
$jscomp.math.atanh=function(h){h=Number(h);return($jscomp.math.log1p(h)-$jscomp.math.log1p(-h))/2};
$jscomp.math.hypot=function(h,d,f){for(var g=[],c=2;c<arguments.length;++c)g[c-2]=arguments[c];h=Number(h);d=Number(d);for(var a=Math.max(Math.abs(h),Math.abs(d)),b=$jscomp.makeIterator(g),c=b.next();!c.done;c=b.next())a=Math.max(a,Math.abs(c.value));if(1E100<a||1E-100>a){h/=a;d/=a;b=h*h+d*d;g=$jscomp.makeIterator(g);for(c=g.next();!c.done;c=g.next())c=c.value,c=Number(c)/a,b+=c*c;return Math.sqrt(b)*a}a=h*h+d*d;g=$jscomp.makeIterator(g);for(c=g.next();!c.done;c=g.next())c=c.value,a+=c*c;return Math.sqrt(a)};
$jscomp.math.trunc=function(h){h=Number(h);if(isNaN(h)||Infinity===h||-Infinity===h||0===h)return h;var d=Math.floor(Math.abs(h));return 0>h?-d:d};$jscomp.math.cbrt=function(h){if(0===h)return h;h=Number(h);var d=Math.pow(Math.abs(h),1/3);return 0>h?-d:d};$jscomp.number=$jscomp.number||{};$jscomp.number.isFinite=function(h){return"number"!==typeof h?!1:!isNaN(h)&&Infinity!==h&&-Infinity!==h};$jscomp.number.isInteger=function(h){return $jscomp.number.isFinite(h)?h===Math.floor(h):!1};
$jscomp.number.isNaN=function(h){return"number"===typeof h&&isNaN(h)};$jscomp.number.isSafeInteger=function(h){return $jscomp.number.isInteger(h)&&Math.abs(h)<=$jscomp.number.MAX_SAFE_INTEGER};$jscomp.number.EPSILON=Math.pow(2,-52);$jscomp.number.MAX_SAFE_INTEGER=9007199254740991;$jscomp.number.MIN_SAFE_INTEGER=-9007199254740991;$jscomp.object=$jscomp.object||{};
$jscomp.object.assign=function(h,d){for(var f=[],g=1;g<arguments.length;++g)f[g-1]=arguments[g];f=$jscomp.makeIterator(f);for(g=f.next();!g.done;g=f.next()){var g=g.value,c;for(c in g)Object.prototype.hasOwnProperty.call(g,c)&&(h[c]=g[c])}return h};$jscomp.object.is=function(h,d){return h===d?0!==h||1/h===1/d:h!==h&&d!==d};$jscomp.Set=function(h){h=void 0===h?[]:h;this.map_=new $jscomp.Map;if(h){h=$jscomp.makeIterator(h);for(var d=h.next();!d.done;d=h.next())this.add(d.value)}this.size=this.map_.size};
$jscomp.Set.checkBrowserConformance_=function(){var h=$jscomp.global.Set;if(!h||!h.prototype.entries||!Object.seal)return!1;var d=Object.seal({x:4}),h=new h($jscomp.makeIterator([d]));if(h.has(d)||1!=h.size||h.add(d)!=h||1!=h.size||h.add({x:4})!=h||2!=h.size)return!1;var h=h.entries(),f=h.next();if(f.done||f.value[0]!=d||f.value[1]!=d)return!1;f=h.next();return f.done||f.value[0]==d||4!=f.value[0].x||f.value[1]!=f.value[0]?!1:h.next().done};
$jscomp.Set.prototype.add=function(h){this.map_.set(h,h);this.size=this.map_.size;return this};$jscomp.Set.prototype["delete"]=function(h){h=this.map_["delete"](h);this.size=this.map_.size;return h};$jscomp.Set.prototype.clear=function(){this.map_.clear();this.size=0};$jscomp.Set.prototype.has=function(h){return this.map_.has(h)};$jscomp.Set.prototype.entries=function(){return this.map_.entries()};$jscomp.Set.prototype.values=function(){return this.map_.values()};
$jscomp.Set.prototype.forEach=function(h,d){var f=this;this.map_.forEach(function(g){return h.call(d,g,g,f)})};$jscomp.Set.ASSUME_NO_NATIVE=!1;$jscomp.Set$install=function(){!$jscomp.Set.ASSUME_NO_NATIVE&&$jscomp.Set.checkBrowserConformance_()?$jscomp.Set=$jscomp.global.Set:($jscomp.Map$install(),$jscomp.initSymbol(),$jscomp.initSymbolIterator(),$jscomp.Set.prototype[Symbol.iterator]=$jscomp.Set.prototype.values);$jscomp.Set$install=function(){}};$jscomp.string=$jscomp.string||{};
$jscomp.string.noRegExp_=function(h,d){if(h instanceof RegExp)throw new TypeError("First argument to String.prototype."+d+" must not be a regular expression");};
$jscomp.string.fromCodePoint=function(h){for(var d=[],f=0;f<arguments.length;++f)d[f-0]=arguments[f];for(var f="",d=$jscomp.makeIterator(d),g=d.next();!g.done;g=d.next()){g=g.value;g=+g;if(0>g||1114111<g||g!==Math.floor(g))throw new RangeError("invalid_code_point "+g);65535>=g?f+=String.fromCharCode(g):(g-=65536,f+=String.fromCharCode(g>>>10&1023|55296),f+=String.fromCharCode(g&1023|56320))}return f};
$jscomp.string.repeat=function(h){var d=this.toString();if(0>h||1342177279<h)throw new RangeError("Invalid count value");h|=0;for(var f="";h;)if(h&1&&(f+=d),h>>>=1)d+=d;return f};$jscomp.string.repeat$install=function(){String.prototype.repeat||(String.prototype.repeat=$jscomp.string.repeat)};
$jscomp.string.codePointAt=function(h){var d=this.toString(),f=d.length;h=Number(h)||0;if(0<=h&&h<f){h|=0;var g=d.charCodeAt(h);if(55296>g||56319<g||h+1===f)return g;h=d.charCodeAt(h+1);return 56320>h||57343<h?g:1024*(g-55296)+h+9216}};$jscomp.string.codePointAt$install=function(){String.prototype.codePointAt||(String.prototype.codePointAt=$jscomp.string.codePointAt)};
$jscomp.string.includes=function(h,d){d=void 0===d?0:d;$jscomp.string.noRegExp_(h,"includes");return-1!==this.toString().indexOf(h,d)};$jscomp.string.includes$install=function(){String.prototype.includes||(String.prototype.includes=$jscomp.string.includes)};
$jscomp.string.startsWith=function(h,d){d=void 0===d?0:d;$jscomp.string.noRegExp_(h,"startsWith");var f=this.toString();h+="";for(var g=f.length,c=h.length,a=Math.max(0,Math.min(d|0,f.length)),b=0;b<c&&a<g;)if(f[a++]!=h[b++])return!1;return b>=c};$jscomp.string.startsWith$install=function(){String.prototype.startsWith||(String.prototype.startsWith=$jscomp.string.startsWith)};
$jscomp.string.endsWith=function(h,d){$jscomp.string.noRegExp_(h,"endsWith");var f=this.toString();h+="";void 0===d&&(d=f.length);for(var g=Math.max(0,Math.min(d|0,f.length)),c=h.length;0<c&&0<g;)if(f[--g]!=h[--c])return!1;return 0>=c};$jscomp.string.endsWith$install=function(){String.prototype.endsWith||(String.prototype.endsWith=$jscomp.string.endsWith)};
(function(h){function d(g){if(f[g])return f[g].exports;var c=f[g]={exports:{},id:g,loaded:!1};h[g].call(c.exports,c,c.exports,d);c.loaded=!0;return c.exports}var f={};d.m=h;d.c=f;d.p="";return d(0)})([function(h,d,f){f(1);f(73);f(74);f(76);f(77);f(79);h.exports=f(81)},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function b(a,b){return a.getChunkSource(H,u.stableStringify(b),function(){return new H(a,b)})}function e(a,b){var e=u.stableStringify({instance:a,key:b}),c=G.get(e);if(void 0!==c)return c;c=Promise.all([m.makeRequest(a,"GET",
"/v1beta2/volumes/"+b,"json"),m.makeRequest(a,"GET","/v1beta2/objects/"+b+"/meshes","json")]).then(function(e){e=k(e,2);return new E(a,b,e[0],e[1])});G.set(e,c);return c}function l(a){var b=R.get(a);if(void 0===b){var b=m.makeRequest(a,"GET","/v1beta2/volumes/","json").then(function(a){return new P(a)}),e="Google "+m.INSTANCE_NAMES[a]+" volume list";w.StatusMessage.forPromise(b,{delay:!0,initialMessage:"Retrieving "+e+".",errorPrefix:"Error retrieving "+e+": "});R.set(a,b)}return b}function r(a,b){return l(a).then(function(a){var e=
b.lastIndexOf(":")+1,c=b.substring(0,e),e=b.substring(e);a=a.hierarchicalVolumeIds.get(c);return void 0===a?null:{offset:c.length,completions:z.getPrefixMatches(e,a)}})}function n(a){var b="brainmaps";a!==m.PRODUCTION_INSTANCE&&(b+="-"+m.INSTANCE_IDENTIFIERS[a].toLowerCase());q.registerDataSourceFactory(b,{description:"Google "+m.INSTANCE_NAMES[a]+" API",getVolume:e.bind(void 0,a),volumeCompleter:r.bind(void 0,a)})}var k=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();
$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var e=[],c=!0,l=!1,k=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var d=a[Symbol.iterator](),r;!(c=(r=d.next()).done)&&(e.push(r.value),!b||e.length!==b);c=!0);}catch(n){l=!0,k=n}finally{try{if(!c&&d["return"])d["return"]()}finally{if(l)throw k;}}return e}throw new TypeError("Invalid attempt to destructure non-iterable instance");}}(),p=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=l.enumerable||
!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}();f(2);var m=f(13),t=f(16),q=f(17);h=f(19);var v=f(59),x=f(58),w=f(4),z=f(18),C=f(39),u=f(8),y=new Map;y.set("UINT8",v.DataType.UINT8);y.set("FLOAT",v.DataType.FLOAT32);y.set("UINT64",v.DataType.UINT64);var B=function Q(b){a(this,Q);try{u.verifyObject(b),this.numChannels=u.verifyPositiveInt(b.channelCount),this.dataType=u.verifyMapKey(b.channelType,y),
this.voxelSize=u.parseXYZ(C.vec3.create(),b.pixelSize,u.verifyFinitePositiveFloat),this.upperVoxelBound=u.parseXYZ(C.vec3.create(),b.volumeSize,u.verifyPositiveInt)}catch(e){throw Error("Failed to parse BrainMaps volume geometry: "+e.message);}};d.VolumeInfo=B;var A=function(b){function e(b,c,l){a(this,e);c=g(this,Object.getPrototypeOf(e).call(this,b,c));c.parameters=l;c.initializeCounterpart(b.rpc,{type:"brainmaps/VolumeChunkSource",parameters:l});return c}c(e,b);p(e,[{key:"toString",value:function(){return t.volumeSourceToString(this.parameters)}}]);
return e}(x.VolumeChunkSource);d.VolumeChunkSource=A;var D=function T(b){a(this,T);u.verifyObject(b);this.name=u.verifyObjectProperty(b,"name",u.verifyString);this.type=u.verifyObjectProperty(b,"type",u.verifyString)};d.MeshInfo=D;var E=function(){function e(b,c,l,k){a(this,e);this.instance=b;this.volume_id=c;try{u.verifyObject(l);var d=this.scales=u.verifyObjectProperty(l,"geometry",function(a){return u.parseArray(a,function(a){return new B(a)})});if(0===d.length)throw Error("Expected at least one scale.");
var r=d[0],n=this.numChannels=r.numChannels,p=this.dataType=r.dataType;b=1;for(var m=d.length;b<m;++b){var y=d[b];if(y.dataType!==p)throw Error("Scale "+b+" has data type "+v.DataType[y.dataType]+" but scale 0 has data type "+v.DataType[p]+".");if(y.numChannels!==n)throw Error("Scale "+b+" has "+y.numChannels+" channel(s) but scale 0 has "+n+" channels.");}var f=v.VolumeType.IMAGE;if(1===n)switch(p){case v.DataType.UINT64:f=v.VolumeType.SEGMENTATION}this.volumeType=f}catch(q){throw Error("Failed to parse BrainMaps multiscale volume specification: "+
q.message);}try{u.verifyObject(k),this.meshes=u.verifyObjectProperty(k,"meshes",function(a){return void 0===a?[]:u.parseArray(a,function(a){return new D(a)})})}catch(q){throw Error("Failed to parse BrainMaps meshes specification: "+q.message);}}p(e,[{key:"getSources",value:function(a){var b=this,e=t.VolumeChunkEncoding.RAW;this.volumeType===v.VolumeType.SEGMENTATION?e=t.VolumeChunkEncoding.COMPRESSED_SEGMENTATION:this.volumeType===v.VolumeType.IMAGE&&this.dataType===v.DataType.UINT8&&1===this.numChannels&&
(e=t.VolumeChunkEncoding.JPEG);return this.scales.map(function(c,l){return Array.from(v.VolumeChunkSpecification.getDefaults({voxelSize:c.voxelSize,dataType:c.dataType,numChannels:c.numChannels,lowerVoxelBound:C.vec3.fromValues(0,0,0),upperVoxelBound:c.upperVoxelBound,volumeType:b.volumeType})).map(function(c){var k={instance:b.instance,volume_id:b.volume_id,scaleIndex:l,encoding:e};return a.getChunkSource(A,u.stableStringify(k),function(){return new A(a,c,k)})})})}},{key:"getMeshSource",value:function(a){var e=
this.meshes.find(function(a){return"TRIANGLES"===a.type});return void 0===e?null:b(a,{instance:this.instance,volume_id:this.volume_id,mesh_name:e.name})}}]);return e}();d.MultiscaleVolumeChunkSource=E;var H=function(b){function e(b,c){a(this,e);var l=g(this,Object.getPrototypeOf(e).call(this,b));l.parameters=c;l.initializeCounterpart(l.chunkManager.rpc,{type:"brainmaps/MeshSource",parameters:c});return l}c(e,b);p(e,[{key:"toString",value:function(){return t.meshSourceToString(this.parameters)}}]);
return e}(h.MeshSource);d.MeshSource=H;d.getMeshSource=b;var G=new Map;d.getVolume=e;var P=function X(b){a(this,X);this.hierarchicalVolumeIds=new Map;try{u.verifyObject(b);var e=this.volumeIds=u.parseArray(b.volumeId,u.verifyString);e.sort();for(var c=new Map,l=$jscomp.makeIterator(e),d=l.next();!d.done;d=l.next()){var r=d.value;for(b=0;;){var n=r.indexOf(":",b);-1===n?n=void 0:++n;var p=r.substring(0,b),m=c.get(p);void 0===m&&(m=new Set,c.set(p,m));m.add(r.substring(b,n));if(void 0===n)break;b=n}}for(var y=
this.hierarchicalVolumeIds,q=$jscomp.makeIterator(c),f=q.next();!f.done;f=q.next()){var t=k(f.value,2);y.set(t[0],Array.from(t[1]))}}catch(B){throw Error("Failed to parse Brain Maps volume list reply: "+B.message);}};d.VolumeList=P;var R=new Map;d.getVolumeList=l;d.volumeCompleter=r;d.registerBrainmapsDataSource=n;n(m.PRODUCTION_INSTANCE)},function(h,d,f){var g=f(3),c=f(4),a=f(6),b=f(9);h=f(11);var e=0;g.implementation.getNewTokenPromise=function(){var l=new c.StatusMessage(!0),d=void 0,n=new Promise(function(c){function n(){var a=
1>=arguments.length||void 0===arguments[1]?"Request authorization.":arguments[1];l.setText((0>=arguments.length||void 0===arguments[0]?"Brain Maps authorization required.":arguments[0])+"  ");var b=document.createElement("button");b.textContent=a;l.element.appendChild(b);b.addEventListener("click",function(){m(!1)});l.setVisible(!0)}function m(l){void 0!==d&&b.cancelPromise(d);n("Waiting for Brain Maps authorization...","Retry");d=a.authenticateGoogleOAuth2({clientId:"639403125587-4k5hgdfumtrvur8v48e3pr7oo91d765k.apps.googleusercontent.com",
scopes:["https://www.googleapis.com/auth/brainmaps"],immediate:l,authUser:0});d.then(function(a){a.generationId=e++;c(a)},function(a){l?n():n("Brain Maps authorization failed: "+a+".","Retry")});b.callFinally(d,function(){d=void 0})}m(!0)});b.callFinally(n,function(){l.dispose()});return n};h.registerRPC("brainmaps.requestToken",function(a){var b=this;g.getToken(a.invalidToken).then(function(a){b.invoke("brainmaps.receiveToken",{authResult:a})})})},function(h,d){var f=function b(){if(!(this instanceof
b))throw new TypeError("Cannot call a class as a function");};d.Implementation=f;d.implementation=new f;var g=null,c=null;d.getToken=function(b){if(null!==g&&(null===c||null==b||b.generationId!==c.generationId))return g;c=null;g=d.implementation.getNewTokenPromise(b);g.then(function(b){c=b});return g}},function(h,d,f){var g=function(){function a(a,e){for(var c=0;c<e.length;c++){var d=e[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}
return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}();f(5);var c=null;d.DEFAULT_STATUS_DELAY=200;h=function(){function a(){var b=0>=arguments.length||void 0===arguments[0]?!1:arguments[0];if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");null===c&&(c=document.createElement("ul"),c.id="statusContainer",document.body.appendChild(c));var e=document.createElement("li");this.element=e;!0===b&&(b=d.DEFAULT_STATUS_DELAY);!1!==b?(this.setVisible(!1),this.timer=setTimeout(this.setVisible.bind(this,
!0),b)):this.timer=null;c.appendChild(e)}g(a,[{key:"dispose",value:function(){c.removeChild(this.element);this.element=void 0;null!==this.timer&&clearTimeout(this.timer)}},{key:"setText",value:function(a,e){this.element.textContent=a;e&&this.setVisible(!0)}},{key:"setHTML",value:function(a,e){this.element.innerHTML=a;e&&this.setVisible(!0)}},{key:"setVisible",value:function(a){this.timer=null;this.element.style.display=a?"block":"none"}}],[{key:"forPromise",value:function(b,e){var c=new a(e.delay);
c.setText(e.initialMessage);var d=c.dispose.bind(c);b.then(d,function(a){var b=void 0,b=a instanceof Error?a.message:""+a;a=e.errorPrefix;c.element.textContent=(void 0===a?"":a)+b+"  ";b=document.createElement("button");b.textContent="Dismiss";b.addEventListener("click",function(){c.dispose()});c.element.appendChild(b);c.setVisible(!0)});return b}}]);return a}();d.StatusMessage=h},function(h,d){},function(h,d,f){function g(a,b){var e=document.createElement("iframe");e.style.display="none";e.id=a;
e.name=a;e.src="https://accounts.google.com/o/oauth2/postmessageRelay?parent="+encodeURIComponent(location.origin)+"#rpctoken="+b;document.body.appendChild(e)}var c=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}(),a=f(7),b=f(8),e=f(9),l=f(10);d.AUTH_SERVER="https://accounts.google.com/o/oauth2/auth";d.embedRelayFrame=
g;var r=function(){function a(){var e=this;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.proxyName="postmessageRelay"+l.getRandomHexString();this.rpcToken=""+l.getRandomHexString();this.relayReadyService="oauth2relayReady:"+this.rpcToken;this.oauth2CallbackService="oauth2callback:"+this.rpcToken;this.pendingRequests=new Map;g(this.proxyName,this.rpcToken);this.relayReadyPromise=new Promise(function(a){addEventListener("message",function(c){if("https://accounts.google.com"===
c.origin)try{var l=b.verifyObject(JSON.parse(c.data)),d=b.verifyString(l.s);d===e.relayReadyService&&a();if(d===e.oauth2CallbackService){var k=b.parseArray(l.a,function(a){return a}),r=b.verifyString(k[0]),n=location.origin;if(!r.startsWith(n+"#")&&!r.startsWith(n+"?"))throw Error("oauth2callback: URL "+JSON.stringify(r)+" does not match current origin "+n+".");for(var f=r.substring(n.length+1).split("&"),u=new Map,y=$jscomp.makeIterator(f),B=y.next();!B.done;B=y.next()){var A=B.value.match("^([a-z_]+)=(.*)$");
if(null===A)throw Error("oauth2callback: URL part "+JSON.stringify(A)+" does not match expected pattern.");u.set(A[1],A[2])}var D=u.get("state");if(void 0===D)throw Error("oauth2callback: State argument is missing.");var g=e.pendingRequests.get(D);if(void 0!==g){var h=u.get("error");if(void 0!==h){e.pendingRequests.delete(D);var G=u.get("error_subtype"),l=h;void 0!==G&&(l+=": "+G);g.reject(l)}else{var P=u.get("access_token"),R=u.get("token_type"),W=u.get("expires_in"),Q=u.get("scope");if(void 0===
P||void 0===R||void 0===W||void 0===Q)throw Error("oauth2callback: URL lacks expected parameters.");e.pendingRequests.delete(D);g.resolve({accessToken:P,tokenType:R,expiresIn:W,scope:Q})}}}}catch(T){throw Error("Invalid message received from https://accounts.google.com: "+JSON.stringify(c.data)+": "+T.message+".");}})})}c(a,[{key:"getAuthPromise",value:function(a){var b=this,c=e.makeCancellablePromise(function(e,c){b.pendingRequests.set(a,{resolve:e,reject:c})});e.callFinally(c,function(){b.pendingRequests.delete(a)});
return c}},{key:"makeAuthRequestUrl",value:function(a){var b=d.AUTH_SERVER+"?client_id="+encodeURIComponent(a.clientId),b=b+"&redirect_uri=postmessage&response_type=token",e=a.origin,b=b+("&origin="+encodeURIComponent(void 0===e?location.origin:e)),b=b+("&proxy="+this.proxyName),b=b+"&include_granted_scopes=true",b=b+("&scope="+encodeURIComponent(a.scopes.join(" ")));a.state&&(b+="&state="+a.state);a.approvalPrompt&&(b+="&approval_prompt="+encodeURIComponent(a.approvalPrompt));a.loginHint&&(b+="&login_hint="+
encodeURIComponent(a.loginHint));a.immediate&&(b+="&immediate=true");void 0!==a.authUser&&(b+="&authuser="+a.authUser);return b}}]);return a}(),n=void 0;d.authenticateGoogleOAuth2=function(b){var c=l.getRandomHexString(),d;void 0===n&&(n=new r);d=n;var f=d.makeAuthRequestUrl({state:c,clientId:b.clientId,scopes:b.scopes,approvalPrompt:b.approvalPrompt,loginHint:b.loginHint,immediate:b.immediate,authUser:b.authUser}),q=d.getAuthPromise(c);b.immediate?d.relayReadyPromise.then(function(){var b=document.createElement("iframe");
b.src=f;b.style.display="none";document.body.appendChild(b);e.callFinally(q,function(){a.removeFromParent(b)})}):function(){var a=open(f);e.callFinally(q,function(){a.close()})}();return q}},function(h,d){d.removeChildren=function(d){for(;;){var g=d.firstElementChild;if(!g)break;d.removeChild(g)}};d.removeFromParent=function(d){var g=d.parentElement;return g?(g.removeChild(d),!0):!1}},function(h,d){function f(a){var b=typeof a;if("number"===b||"string"===b)if(b=parseFloat(""+a),!Number.isNaN(b))return b;
throw Error("Expected floating-point number, but received: "+JSON.stringify(a)+".");}function g(a){if("object"===typeof a){if(null===a)return"null";if(Array.isArray(a)){var b="[",e=a.length,c=0;if(c<e)for(b+=g(a[c]);++c<e;)b+=",",b+=g(a[c]);return b+"]"}var b="{",e=Object.keys(a).sort(),c=0,l=e.length;if(c<l)for(var d=e[c],b=b+JSON.stringify(d),b=b+":"+g(a[d]);++c<l;)b+=",",d=e[c],b+=JSON.stringify(d),b+=":",b+=g(a[d]);return b+="}"}return JSON.stringify(a)}function c(a){return a.replace(/['"]/g,
function(a){return'"'===a?"'":'"'})}function a(a){return c(JSON.stringify(c(a)))}function b(e){if("object"===typeof e){if(null===e)return"null";var c=e.toJSON;if("function"===typeof c)return b(c.call(e));if(Array.isArray(e)){var c="[",l=e.length,d=0;if(d<l)for(c+=b(e[d]);++d<l;)c+="_",c+=b(e[d]);return c+"]"}for(var c="{",d=Object.keys(e),l=!0,d=$jscomp.makeIterator(d),k=d.next();!k.done;k=d.next()){var k=k.value,r=e[k];void 0!==r&&(r=b(r))&&(l?l=!1:c+="_",c+=a(k),c+=":",c+=r)}return c+"}"}return"string"===
typeof e?a(e):JSON.stringify(e)}function e(a,b,e,c){if(2<=a.length&&a.charAt(0)===b&&a.charAt(a.length-1)===b){a=a.substr(1,a.length-2);for(b=e;0<a.length;){var l=a.match(c);if(null===l){b+=a;break}b+=l[1];b+="\\";b+=e;a=a.substr(l.index+l[0].length)}return b+e}return a}function l(a){return e(a,"'",'"',C)}function r(a,b,c){var l=/[&_,]/g,d=void 0,k=void 0,r=void 0;'"'===c?(d="'",k=C,r=w):(d='"',k=u,r=z);for(var n="";0<a.length;){var p=a.match(r),m=void 0,f=void 0;null===p?(m=a,f=a=""):(m=a.substr(0,
p.index),a=a.substr(p.index+p[0].length),f=p[1],f=void 0!==f?e(f,d,c,k):p[2]);n+=m.replace(l,b);n+=f}return n}function n(a){return r(a,",",'"')}function k(a){return JSON.parse(n(a))}function p(a){for(var b="";0<a.length;){var e=a.match(w),c=void 0,d=void 0;null===e?(c=a,d=a=""):(c=a.substr(0,e.index),a=a.substr(e.index+e[0].length),d=e[1],d=void 0!==d?l(d):e[2]);b+=c.replace(/\(/g,"[").replace(/\)/g,"]").replace("True","true").replace("False","false").replace(/,\s*([\}\]])/g,"$1");b+=d}return b}function m(a){if("object"!==
typeof a||null==a||Array.isArray(a))throw Error("Expected JSON object, but received: "+JSON.stringify(a)+".");return a}function t(a){var b=parseInt(a,10);if(!Number.isInteger(b))throw Error("Expected integer, but received: "+JSON.stringify(a)+".");return b}function q(a){if("string"!==typeof a)throw Error("Expected string, but received: "+JSON.stringify(a)+".");return a}d.verifyFloat=f;d.verifyFinitePositiveFloat=function(a){a=f(a);if(Number.isFinite(a)&&0<a)return a;throw Error("Expected positive finite floating-point number, but received: "+
a+".");};d.parseXYZ=function(a,b){var e=2>=arguments.length||void 0===arguments[2]?f:arguments[2];m(b);var c=Object.keys(b);c.sort();if(3!==c.length||"x"!==c[0]||"y"!==c[1]||"z"!==c[2])throw Error("Expected object to have keys ['x', 'y', 'z'], but received: "+JSON.stringify(b)+".");a[0]=e(b.x);a[1]=e(b.y);a[2]=e(b.z);return a};d.parseFiniteVec=function(a,b){var e=a.length;if(!Array.isArray(b)||b.length!==e)throw Error("Incompatible sizes");for(var c=0;c<e;++c)if(!Number.isFinite(parseFloat(b[c])))throw Error("Non-finite value.");
for(c=0;c<e;++c)a[c]=parseFloat(b[c]);return a};d.parseIntVec=function(a,b){var e=a.length;if(!Array.isArray(b)||b.length!==e)throw Error("Incompatible sizes.");for(var c=0;c<e;++c){var l=parseInt(b[c],void 0);if(!Number.isInteger(l))throw Error("Non-integer value.");}for(c=0;c<e;++c)a[c]=parseInt(b[c],void 0);return a};d.stableStringify=g;d.urlSafeStringifyString=a;d.urlSafeStringify=b;var v=/('(?:[^'\\]|(?:\\.))*')/,x=/("(?:[^'\\]|(?:\\.))*")/,w=new RegExp(v.source+"|"+x.source),z=new RegExp(x.source+
"|"+v.source),C=/^((?:[^"'\\]|(?:\\.))*)"/,u=/^((?:[^"'\\]|(?:\\.))*)'/;d.normalizeStringLiteral=l;d.urlSafeToJSON=n;d.jsonToUrlSafe=function(a){return r(a,"_","'")};d.urlSafeParse=k;d.pythonLiteralToJSON=p;d.pythonLiteralParse=function(a){return JSON.parse(p(a))};d.parseArray=function(a,b){if(!Array.isArray(a))throw Error("Expected array, but received: "+JSON.stringify(a)+".");return a.map(b)};d.parseFixedLengthArray=function(a,b,e){var c=a.length;if(!Array.isArray(b)||b.length!==c)throw Error("Expected length "+
c+" array, but received: "+JSON.stringify(b)+".");for(var l=0;l<c;++l)a[l]=e(b[l],l);return a};d.verifyObject=m;d.verifyInt=t;d.verifyPositiveInt=function(a){a=t(a);if(0>=a)throw Error("Expected positive integer, but received: "+a+".");return a};d.verifyMapKey=function(a,b){var e=b.get(a);if(void 0===e)throw Error("Expected one of "+JSON.stringify(Array.from(b.keys()))+", but received: "+JSON.stringify(a)+".");return e};d.verifyString=q;d.verifyOptionalString=function(a){return void 0===a?void 0:
q(a)};d.verifyObjectProperty=function(a,b,e){a=a.hasOwnProperty(b)?a[b]:void 0;try{return e(a)}catch(c){throw Error("Error parsing "+JSON.stringify(b)+" property: "+c.message);}};d.verifyObjectAsMap=function(a,b){m(a);for(var e=new Map,c=$jscomp.makeIterator(Object.keys(a)),l=c.next();!l.done;l=c.next()){l=l.value;try{e.set(l,b(a[l]))}catch(d){throw Error("Error parsing value associated with key "+JSON.stringify(l)+": "+d.message);}}return e};d.verifyFloat01=function(a){if("number"!==typeof a||!Number.isFinite(a)||
0>a||1<a)throw Error("Expected floating point number in [0,1], but received: "+JSON.stringify(a)+".");return a};d.parseQueryStringParameters=function(a){if(""===a)return{};if(a.startsWith("{"))return k(a);var b={};a=a.split(/[&;]/);a=$jscomp.makeIterator(a);for(var e=a.next();!e.done;e=a.next()){var e=e.value,c=e.match(/^([^=&;]+)=([^&;]*)$/);if(null===c)throw Error("Invalid query string part: "+JSON.stringify(e)+".");b[c[1]]=c[2]}return b};d.verifyEnumString=function(a,b){if("string"===typeof a&&
null!==a.match(/^[a-zA-Z]/)&&(a=a.toUpperCase(),b.hasOwnProperty(a)))return b[a];throw Error("Invalid enum value: "+JSON.stringify(a)+".");}},function(h,d){function f(a){var e=!1,c=void 0,r=void 0,n=new Promise(function(k,n){function m(a){e||(e=!0,k(a))}function f(a){e||(e=!0,n(a))}function q(a){if(e)try{a()}catch(b){}}try{a(m,f,q)}catch(v){f(v)}r=function(){if(!e){e=!0;if(void 0!==c){try{c()}catch(a){}c=void 0}n(d.CANCELLED)}}});n.cancel=r;return n}function g(a){if(null!=a){var e=a.cancel;void 0!==
e&&e.call(a)}}var c=function(){function a(b,c){for(var d=0;d<c.length;d++){var n=c[d];n.enumerable=n.enumerable||!1;n.configurable=!0;"value"in n&&(n.writable=!0);Object.defineProperty(b,n.key,n)}}return function(e,c,d){c&&a(e.prototype,c);d&&a(e,d);return e}}(),a=function(){function a(){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");}c(a,[{key:"toString",value:function(){return"CancellationError"}}]);return a}();d.CancellationError=a;d.CANCELLED=new a;d.makeCancellablePromise=
f;d.cancelPromise=g;d.callFinally=function(a,e){return f(function(c,d,n){n(function(){g(a)});a.then(function(a){n(void 0);Promise.resolve(e(n)).then(function(){c(a)})},function(a){n(void 0);try{Promise.resolve(e(n)).then(function(){d(a)},d)}catch(b){d(b)}})})};d.cancellableThen=function(a,e){return f(function(c,r,n){var k=!1;n(function(){k=!0;g(a)});a.then(function(a){k?r(d.CANCELLED):(n(void 0),c(e(a,n)))})})}},function(h,d){d.getRandomHexString=function(){var d=Math.ceil((0>=arguments.length||void 0===
arguments[0]?128:arguments[0])/32),g=new Uint32Array(d);crypto.getRandomValues(g);for(var c="",a=0;a<d;++a)c+=("00000000"+g[a].toString(16)).slice(-8);return c};d.getRandomValues=function(d){d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength);for(var g=0,c=d.length;g<c;g+=65536)crypto.getRandomValues(d.subarray(g,Math.min(c,g+65536)))}},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==
typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function b(a,b){r.set(a,b)}var e=function p(a,b,e){null===a&&(a=Function.prototype);
var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c)return a=Object.getPrototypeOf(a),null===a?void 0:p(a,b,e);if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(e)},l=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}();h=f(12);var r=new Map;d.registerRPC=b;f=function(){function b(e){var c=
this;a(this,b);this.target=e;this.objects=new Map;this.nextId=0;e.onmessage=function(a){a=a.data;r.get(a.functionName).call(c,a)}}l(b,[{key:"set",value:function(a,b){this.objects.set(a,b)}},{key:"delete",value:function(a){this.objects.delete(a)}},{key:"get",value:function(a){return this.objects.get(a)}},{key:"getRef",value:function(a){var b=this.get(a.id);b.referencedGeneration=a.gen;b.addRef();return b}},{key:"invoke",value:function(a,b,e){b.functionName=a;this.target.postMessage(b,e)}},{key:"newId",
value:function(){return this.nextId++}},{key:"numObjects",get:function(){return this.objects.size}}]);return b}();d.RPC=f;h=function(b){function d(){a(this,d);for(var b=arguments.length,e=Array(b),c=0;c<b;c++)e[c]=arguments[c];var l,b=g(this,(l=Object.getPrototypeOf(d)).call.apply(l,[].concat([this],$jscomp.arrayFromIterable(e))));b.rpc=null;b.rpcId=null;return b}c(d,b);l(d,[{key:"initializeSharedObject",value:function(a){var b=1>=arguments.length||void 0===arguments[1]?a.newId():arguments[1];this.rpc=
a;this.rpcId=b;this.isOwner=!1;a.set(b,this)}},{key:"initializeCounterpart",value:function(a){var b=1>=arguments.length||void 0===arguments[1]?{}:arguments[1];this.initializeSharedObject(a);this.referencedGeneration=this.unreferencedGeneration=0;this.isOwner=!0;b.id=this.rpcId;a.invoke("SharedObject.new",b)}},{key:"dispose",value:function(){e(Object.getPrototypeOf(d.prototype),"dispose",this).call(this)}},{key:"addCounterpartRef",value:function(){return{id:this.rpcId,gen:++this.referencedGeneration}}},
{key:"refCountReachedZero",value:function(){!0===this.isOwner?this.referencedGeneration===this.unreferencedGeneration&&this.ownerDispose():!1===this.isOwner?this.rpc.invoke("SharedObject.refCountReachedZero",{id:this.rpcId,gen:this.referencedGeneration}):e(Object.getPrototypeOf(d.prototype),"refCountReachedZero",this).call(this)}},{key:"ownerDispose",value:function(){var a=this.rpc,b=this.rpcId;e(Object.getPrototypeOf(d.prototype),"refCountReachedZero",this).call(this);a.delete(b);a.invoke("SharedObject.dispose",
{id:b})}},{key:"counterpartRefCountReachedZero",value:function(a){this.unreferencedGeneration=a;0===this.refCount&&a===this.referencedGeneration&&this.ownerDispose()}}]);return d}(h.RefCounted);d.SharedObject=h;h=function(b){function e(b){var c=1>=arguments.length||void 0===arguments[1]?{}:arguments[1];a(this,e);var l=g(this,Object.getPrototypeOf(e).call(this));null!=b&&l.initializeSharedObject(b,c.id);return l}c(e,b);return e}(h);d.SharedObjectCounterpart=h;b("SharedObject.dispose",function(a){a=
this.get(a.id);if(0!==a.refCount)throw Error("Attempted to dispose object with non-zero reference count.");a.disposed();this.delete(a.rpcId);a.rpcId=null;a.rpc=null});b("SharedObject.refCountReachedZero",function(a){this.get(a.id).counterpartRefCountReachedZero(a.gen)});var n=new Map;d.registerSharedObject=function(a,b){n.set(a,b)};b("SharedObject.new",function(a){--(new (n.get(a.type))(this,a)).refCount})},function(h,d){var f=function(){function c(a,b){for(var e=0;e<b.length;e++){var c=b[e];c.enumerable=
c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(a,b,e){b&&c(a.prototype,b);e&&c(a,e);return a}}(),g=function(){function c(){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");this.refCount=1}f(c,[{key:"addRef",value:function(){++this.refCount;return this}},{key:"dispose",value:function(){0===--this.refCount&&this.refCountReachedZero()}},{key:"refCountReachedZero",value:function(){this.disposed();var a=
this.disposers;if(null!=a){for(var b=a.length;0<b;--b){var e=a[b-1];"object"===typeof e?e.dispose():e.call(this)}this.disposers=void 0}}},{key:"disposed",value:function(){}},{key:"registerDisposer",value:function(a){var b=this.disposers;null==b?this.disposers=[a]:b.push(a);return a}},{key:"unregisterDisposer",value:function(a){var b=this.disposers;if(null!=b){var e=b.indexOf(a);-1!==e&&b.splice(e,1)}return a}},{key:"registerSignalBinding",value:function(a){this.registerDisposer(function(){return a.detach()})}},
{key:"registerEventListener",value:function(a,b,e,c){a.addEventListener(b,e,c);this.registerDisposer(function(){return a.removeEventListener(b,e,c)})}}]);return c}();d.RefCounted=g},function(h,d,f){function g(a,b,c,n){d.INSTANCE_IDENTIFIERS[a]=c;d.INSTANCE_NAMES[a]=n;c=["https://"+b];for(n=0;9>=n;++n)c.push("https://s"+n+"-"+b);d.INSTANCE_BASE_URLS[a]=c}var c=f(3),a=f(14),b=f(9);d.numPendingRequests=0;d.PRODUCTION_INSTANCE=0;d.INSTANCE_NAMES=[];d.INSTANCE_BASE_URLS=[];d.INSTANCE_IDENTIFIERS=[];d.brainmapsInstanceKey=
function(a){return d.INSTANCE_IDENTIFIERS[a]};d.setupBrainmapsInstance=g;g(d.PRODUCTION_INSTANCE,"brainmaps.googleapis.com","prod","Brain Maps");d.makeRequest=function(e,l,r,n){var k=void 0;return b.makeCancellablePromise(function(b,f,t){function q(t){null===k?--d.numPendingRequests:(k=a.openShardedHttpRequest(d.INSTANCE_BASE_URLS[e],r,l),k.responseType=n,k.setRequestHeader("Authorization",t.tokenType+" "+t.accessToken),k.onloadend=function(){if(null===k)--d.numPendingRequests;else{var e=this.status;
200<=e&&300>e?(--d.numPendingRequests,b(this.response)):403===e||401===e?c.getToken(t).then(q):(--d.numPendingRequests,f(a.HttpError.fromXhr(this)))}},k.send())}t(function(){var a=k;k=null;null!=a&&a.abort()});c.getToken().then(q)})}},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&
(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function c(a,e){if(Array.isArray(a)){var c=a.length,c=1===c?0:Math.abs(b.simpleStringHash(e))%c;return a[c]+e}return a+e}var a=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}(),b=f(15),e=f(9);$jscomp.initSymbol();d.URL_SYMBOL=Symbol("url");$jscomp.initSymbol();
d.METHOD_SYMBOL=Symbol("method");var l=function(b){function e(a,b,c,l){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var d=a+" "+JSON.stringify(b)+" resulted in HTTP error "+c;l&&(d+=": "+l);var d=d+".",r;r=Object.getPrototypeOf(e).call(this,d);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");r=!r||"object"!==typeof r&&"function"!==typeof r?this:r;r.name="HttpError";r.message=d;r.method=a;r.url=b;r.code=c;r.statusMessage=
l;return r}g(e,b);a(e,null,[{key:"fromXhr",value:function(a){return new e(a[d.METHOD_SYMBOL],a[d.URL_SYMBOL],a.status,a.statusText)}}]);return e}(Error);d.HttpError=l;d.openHttpRequest=function(a){var b=1>=arguments.length||void 0===arguments[1]?"GET":arguments[1],e=new XMLHttpRequest;e[d.METHOD_SYMBOL]=b;e[d.URL_SYMBOL]=a;e.open(b,a);return e};d.pickShard=c;d.openShardedHttpRequest=function(a,b){var e=2>=arguments.length||void 0===arguments[2]?"GET":arguments[2],l=new XMLHttpRequest,f=c(a,b);l[d.METHOD_SYMBOL]=
e;l[d.URL_SYMBOL]=f;l.open(e,f);return l};d.sendHttpRequest=function(a,b){a.responseType=b;return e.makeCancellablePromise(function(b,e,c){a.onloadend=function(){var c=this.status;200<=c&&300>c?b(this.response):e(l.fromXhr(a))};c(function(){a.abort()});a.send()})};d.parseSpecialUrl=function(a){var b=a.match(/^([^:\/]+):\/\/([^\/]+)(\/.*)?$/);if(null===b)throw Error("Invalid URL: "+JSON.stringify(a));return"gs"===b[1]?(a=b[2],[["https://"+a+".storage.googleapis.com","https://storage.googleapis.com/"+
a],b[3]]):[[a],""]}},function(h,d){d.simpleStringHash=function(d){for(var g=0,c=d.length,a=0;a<c;++a)g=31*g+d.charCodeAt(a)|0;return g}},function(h,d,f){var g=f(13);(function(a){a[a.RAW=0]="RAW";a[a.JPEG=1]="JPEG";a[a.COMPRESSED_SEGMENTATION=2]="COMPRESSED_SEGMENTATION"})(d.VolumeChunkEncoding||(d.VolumeChunkEncoding={}));var c=d.VolumeChunkEncoding;d.volumeSourceToString=function(a){return"brainmaps-"+g.brainmapsInstanceKey(a.instance)+":volume/"+a.volume_id+"/"+a.scaleIndex+"/"+c[a.encoding]};d.meshSourceToString=
function(a){return"brainmaps:"+g.brainmapsInstanceKey(a.instance)+":mesh/"+a.volume_id+"/"+a.mesh_name}},function(h,d,f){function g(a,b){void 0===b&&(b=-1===a.indexOf("/")?":":"/");var e=a.lastIndexOf(b);return-1===e?0:e+1}function c(a,b){var e=g(a,b);return a.substring(e)}function a(a){a=a.match(n);if(null===a||void 0===a[1])throw Error('Data source URL must have the form "<protocol>://<path>".');var b=a[1],e=r.get(b);if(void 0===e)throw Error("Unsupported data source: "+JSON.stringify(b)+".");return[e,
a[2],b]}var b=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var e=[],c=!0,l=!1,d=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var r=a[Symbol.iterator](),n;!(c=(n=r.next()).done)&&(e.push(n.value),!b||e.length!==b);c=!0);}catch(f){l=!0,d=f}finally{try{if(!c&&r["return"])r["return"]()}finally{if(l)throw d;}}return e}throw new TypeError("Invalid attempt to destructure non-iterable instance");
}}(),e=f(18),l=f(9);d.findSourceGroupBasedOnSeparator=g;d.suggestLayerNameBasedOnSeparator=c;var r=new Map;d.registerDataSourceFactory=function(a,b){r.set(a,b)};var n=/^(?:([a-zA-Z-+_]+):\/\/)?(.*)$/;d.getVolume=function(e){e=a(e);e=b(e,2);return e[0].getVolume(e[1])};d.getMeshSource=function(e,c){var l=2>=arguments.length||void 0===arguments[2]?0:arguments[2],d=a(c),d=b(d,2);return d[0].getMeshSource(e,d[1],l)};d.getSkeletonSource=function(e,c){var l=a(c),l=b(l,2);return l[0].getSkeletonSource(e,
l[1])};d.volumeCompleter=function(a){var c=a.match(n),d=c[1];if(void 0===d){for(var c=[],f=$jscomp.makeIterator(r),q=f.next();!q.done;q=f.next()){var v=b(q.value,2),q=v[0],v=v[1],q=q+"://";q.startsWith(a)&&c.push({value:q,description:v.description})}return Promise.resolve({offset:0,completions:c})}a=r.get(d);return void 0!==a&&(a=a.volumeCompleter,void 0!==a)?l.cancellableThen(a(c[2]),function(a){return e.applyCompletionOffset(d.length+3,a)}):Promise.reject(null)};d.suggestLayerName=function(e){e=
a(e);var l=b(e,2);e=l[1];l=l[0].suggestLayerName;return void 0!==l?l(e):c(e)};d.findSourceGroup=function(e){e=a(e);e=b(e,3);var c=e[2];return(e[0].findSourceGroup||g)(e[1])+c.length+3}},function(h,d){d.applyCompletionOffset=function(d,g){g.offset+=d;return g};d.getPrefixMatches=function(d,g){for(var c=[],a=$jscomp.makeIterator(g),b=a.next();!b.done;b=a.next())b=b.value,b.startsWith(d)&&c.push({value:b});return c};d.getPrefixMatchesWithDescriptions=function(d,g,c,a){var b=[];g=$jscomp.makeIterator(g);
for(var e=g.next();!e.done;e=g.next()){var e=e.value,l=c(e);l.startsWith(d)&&b.push({value:l,description:a(e)})}return b}},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,
enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}var b=function z(a,b,e){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c)return a=Object.getPrototypeOf(a),null===a?void 0:z(a,b,e);if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(e)},e=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=
e[c];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}(),l=f(20);h=f(21);var r=f(24),n=f(39),k=f(26),p=f(29),m=f(70),t=f(11),q=function(){function b(){a(this,b);this.tempLightVec=n.vec4.create();this.tempPickID=new Float32Array(4)}e(b,[{key:"defineShader",value:function(a){a.addAttribute("highp vec3","aVertexPosition");a.addAttribute("highp vec3","aVertexNormal");a.addVarying("highp vec3",
"vColor");a.addUniform("highp vec4","uLightDirection");a.addUniform("highp vec3","uColor");a.addUniform("highp mat4","uModelMatrix");a.addUniform("highp mat4","uProjection");a.addUniform("highp vec4","uPickID");a.require(r.perspectivePanelEmit);a.setVertexMain("\ngl_Position = uProjection * (uModelMatrix * vec4(aVertexPosition, 1.0));\nvec3 normal = (uModelMatrix * vec4(aVertexNormal, 0.0)).xyz;\nfloat lightingFactor = abs(dot(normal, uLightDirection.xyz)) + uLightDirection.w;\nvColor = lightingFactor * uColor;\n");
a.setFragmentMain("emit(vec4(vColor, 1.0), uPickID);")}},{key:"beginLayer",value:function(a,b,e){var c=e.dataToDevice,l=e.lightDirection,d=e.ambientLighting;e=e.directionalLighting;a.uniformMatrix4fv(b.uniform("uProjection"),!1,c);c=this.tempLightVec;n.vec3.scale(c,l,e);c[3]=d;a.uniform4fv(b.uniform("uLightDirection"),c)}},{key:"beginObject",value:function(a,b,e,c,l){a.uniformMatrix4fv(b.uniform("uModelMatrix"),!1,e);a.uniform4fv(b.uniform("uPickID"),m.setVec4FromUint32(this.tempPickID,l));a.uniform3fv(b.uniform("uColor"),
c)}},{key:"getShader",value:function(a){var b=this;return a.memoize.get("mesh/MeshShaderManager",function(){var e=new p.ShaderBuilder(a);b.defineShader(e);return e.build()})}},{key:"drawFragment",value:function(a,b,e){e.vertexBuffer.bindToVertexAttrib(b.attribute("aVertexPosition"),3);e.normalBuffer.bindToVertexAttrib(b.attribute("aVertexNormal"),3);e.indexBuffer.bind();a.drawElements(a.TRIANGLES,e.numIndices,a.UNSIGNED_INT,0)}},{key:"endLayer",value:function(a,b){a.disableVertexAttribArray(b.attribute("aVertexPosition"));
a.disableVertexAttribArray(b.attribute("aVertexNormal"))}}]);return b}();d.MeshShaderManager=q;f=function(b){function d(b,e,c){a(this,d);var l=g(this,Object.getPrototypeOf(d).call(this));l.chunkManager=b;l.source=e;l.displayState=c;l.meshShaderManager=new q;l.shader=l.registerDisposer(l.meshShaderManager.getShader(l.gl));var r=function(){l.redrawNeeded.dispatch()};l.registerSignalBinding(c.segmentColorHash.changed.add(r));l.registerSignalBinding(c.visibleSegments.changed.add(r));l.registerSignalBinding(c.segmentSelectionState.changed.add(r));
l.registerDisposer(new t.SharedObject).initializeCounterpart(b.rpc,{type:"mesh/MeshLayer",chunkManager:b.rpcId,source:e.addCounterpartRef(),visibleSegmentSet:c.visibleSegments.rpcId});l.setReady(!0);return l}c(d,b);e(d,[{key:"draw",value:function(a){var b=this.gl,e=this.shader;e.bind();var c=this.meshShaderManager;c.beginLayer(b,e,a);var d=this.source.fragmentSource.objectChunks;a=a.pickIDs;var r=n.mat4.create();n.mat4.identity(r);for(var k=n.vec3.create(),f=this.displayState,p=f.segmentColorHash,
m=f.segmentSelectionState,f=$jscomp.makeIterator(f.visibleSegments),q=f.next();!q.done;q=f.next()){var q=q.value,t=d.get(q.low+":"+q.high);if(void 0!==t){p.compute(k,q);if(m.isSelected(q))for(var v=0;3>v;++v)k[v]=.5*k[v]+.5;c.beginObject(b,e,r,k,a.register(this,q));q=$jscomp.makeIterator(t);for(t=q.next();!t.done;t=q.next())t=t.value,t.state===l.ChunkState.GPU_MEMORY&&c.drawFragment(b,e,t)}}c.endLayer(b,e)}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}}]);return d}(r.PerspectiveViewRenderLayer);
d.MeshLayer=f;var v=function(l){function d(b,e){a(this,d);var c=g(this,Object.getPrototypeOf(d).call(this,b));c.objectKey=e.objectKey;c.vertexPositions=e.vertexPositions;var l=c.indices=e.indices;c.numIndices=l.length;c.vertexNormals=e.vertexNormals;return c}c(d,l);e(d,[{key:"copyToGPU",value:function(a){b(Object.getPrototypeOf(d.prototype),"copyToGPU",this).call(this,a);this.vertexBuffer=k.Buffer.fromData(a,this.vertexPositions,a.ARRAY_BUFFER,a.STATIC_DRAW);this.indexBuffer=k.Buffer.fromData(a,this.indices,
a.ELEMENT_ARRAY_BUFFER,a.STATIC_DRAW);this.normalBuffer=k.Buffer.fromData(a,this.vertexNormals,a.ARRAY_BUFFER,a.STATIC_DRAW)}},{key:"freeGPUMemory",value:function(a){b(Object.getPrototypeOf(d.prototype),"freeGPUMemory",this).call(this,a);this.vertexBuffer.dispose();this.indexBuffer.dispose();this.normalBuffer.dispose()}}]);return d}(h.Chunk);d.FragmentChunk=v;var x=function(l){function d(b,e){a(this,d);var c=g(this,Object.getPrototypeOf(d).call(this,b));c.meshSource=e;c.objectChunks=new Map;c.initializeCounterpart(b.rpc,
{type:"mesh/FragmentSource"});return c}c(d,l);e(d,[{key:"addChunk",value:function(a,e){b(Object.getPrototypeOf(d.prototype),"addChunk",this).call(this,a,e);var c=this.objectChunks,l=e.objectKey,r=c.get(l);void 0===r&&(r=new Set,c.set(l,r));r.add(e)}},{key:"deleteChunk",value:function(a){var e=this.chunks.get(a);b(Object.getPrototypeOf(d.prototype),"deleteChunk",this).call(this,a);a=this.objectChunks;var c=e.objectKey,l=a.get(c);l.delete(e);0===l.size&&a.delete(c)}},{key:"getChunk",value:function(a){return new v(this,
a)}}]);return d}(h.ChunkSource);d.FragmentSource=x;f=function(l){function d(){a(this,d);for(var b=arguments.length,e=Array(b),c=0;c<b;c++)e[c]=arguments[c];var l,b=g(this,(l=Object.getPrototypeOf(d)).call.apply(l,[].concat([this],$jscomp.arrayFromIterable(e))));b.fragmentSource=new x(b.chunkManager,b);return b}c(d,l);e(d,[{key:"initializeCounterpart",value:function(a,e){e.fragmentSource=this.fragmentSource.addCounterpartRef();b(Object.getPrototypeOf(d.prototype),"initializeCounterpart",this).call(this,
a,e)}}]);return d}(h.ChunkSource);d.MeshSource=f},function(h,d){var f=function(){function c(a,b){for(var e=0;e<b.length;e++){var c=b[e];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(a,b,e){b&&c(a.prototype,b);e&&c(a,e);return a}}();(function(c){c[c.GPU_MEMORY=0]="GPU_MEMORY";c[c.SYSTEM_MEMORY=1]="SYSTEM_MEMORY";c[c.SYSTEM_MEMORY_WORKER=2]="SYSTEM_MEMORY_WORKER";c[c.DOWNLOADING=3]="DOWNLOADING";c[c.QUEUED=4]="QUEUED";
c[c.NEW=5]="NEW";c[c.FAILED=6]="FAILED";c[c.EXPIRED=7]="EXPIRED"})(d.ChunkState||(d.ChunkState={}));(function(c){c[c.FIRST_TIER=0]="FIRST_TIER";c[c.FIRST_ORDERED_TIER=0]="FIRST_ORDERED_TIER";c[c.VISIBLE=0]="VISIBLE";c[c.PREFETCH=1]="PREFETCH";c[c.LAST_ORDERED_TIER=1]="LAST_ORDERED_TIER";c[c.RECENT=2]="RECENT";c[c.LAST_TIER=2]="LAST_TIER"})(d.ChunkPriorityTier||(d.ChunkPriorityTier={}));var g=function(){function c(a,b){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");
this.itemCapacity=this.availableItems=a;this.sizeCapacity=this.availableSize=b}f(c,[{key:"adjust",value:function(a,b){this.availableItems+=a;this.availableSize+=b}},{key:"toString",value:function(){return this.availableItems+"/"+this.itemCapacity+" items, "+this.availableSize+"/"+this.sizeCapacity+" size"}},{key:"toObject",value:function(){return{itemCapacity:this.itemCapacity,sizeCapacity:this.sizeCapacity}}}],[{key:"fromObject",value:function(a){return new c(a.itemCapacity,a.sizeCapacity)}}]);return c}();
g.INFINITE=new g(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);d.AvailableCapacity=g},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,
configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}var b=function p(a,b,e){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c)return a=Object.getPrototypeOf(a),null===a?void 0:p(a,b,e);if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(e)},e=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=
l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}(),l=f(20),r=f(22);h=f(11);var n=f(23);f=function(){function b(e){a(this,b);this.source=e;this.state=l.ChunkState.SYSTEM_MEMORY}e(b,[{key:"copyToGPU",value:function(a){this.state=l.ChunkState.GPU_MEMORY}},{key:"freeGPUMemory",value:function(a){this.state=l.ChunkState.SYSTEM_MEMORY}},{key:"gl",get:function(){return this.source.gl}}]);return b}();
d.Chunk=f;f=function(b){function d(b,e,c){a(this,d);var l=g(this,Object.getPrototypeOf(d).call(this));l.gl=e;l.visibleChunksChanged=new n.Signal;l.pendingChunkUpdates=null;l.pendingChunkUpdatesTail=null;l.chunkUpdateDeadline=null;l.chunkUpdateDelay=30;l.initializeCounterpart(b,{type:"ChunkQueueManager",gpuMemoryCapacity:c.gpuMemory.toObject(),systemMemoryCapacity:c.systemMemory.toObject(),downloadCapacity:c.download.toObject()});return l}c(d,b);e(d,[{key:"scheduleChunkUpdate",value:function(){var a=
this.chunkUpdateDeadline,b=void 0,b=null===a||Date.now()<a?0:this.chunkUpdateDelay;setTimeout(this.processPendingChunkUpdates.bind(this),b)}},{key:"processPendingChunkUpdates",value:function(){var a=this.chunkUpdateDeadline;if(null!==a&&Date.now()>a)setTimeout(this.processPendingChunkUpdates.bind(this),this.chunkUpdateDelay);else{var a=this.pendingChunkUpdates,b=this.rpc.get(a.source),e=a.state;if(e===l.ChunkState.EXPIRED)b.deleteChunk(a.id);else{var c=void 0,d=a.id;a["new"]?(c=b.getChunk(a),b.addChunk(d,
c)):c=b.chunks.get(d);if(e!==c.state)switch(e){case l.ChunkState.GPU_MEMORY:c.copyToGPU(this.gl);this.visibleChunksChanged.dispatch();break;case l.ChunkState.SYSTEM_MEMORY:c.freeGPUMemory(this.gl);break;default:throw Error("INTERNAL ERROR: Invalid chunk state: "+l.ChunkState[e]);}}null!=(this.pendingChunkUpdates=a.nextUpdate)?this.scheduleChunkUpdate():this.pendingChunkUpdatesTail=null}}}]);return d}(h.SharedObject);d.ChunkQueueManager=f;h.registerRPC("Chunk.update",function(a){var b=this.get(a.source).chunkManager.chunkQueueManager,
e=b.pendingChunkUpdatesTail;null==e?(b.pendingChunkUpdates=a,b.pendingChunkUpdatesTail=a,b.scheduleChunkUpdate()):(e.nextUpdate=a,b.pendingChunkUpdatesTail=a)});f=function(b){function l(b){a(this,l);var e=g(this,Object.getPrototypeOf(l).call(this));e.chunkQueueManager=b;e.chunkSourceCache=new Map;e.registerDisposer(b.addRef());e.initializeCounterpart(b.rpc,{type:"ChunkManager",chunkQueueManager:b.rpcId});return e}c(l,b);e(l,[{key:"getChunkSource",value:function(a,b,e){var c=this.chunkSourceCache,
l=c.get(a);void 0===l&&(l=new r.Memoize,c.set(a,l));return l.get(b,e)}}]);return l}(h.SharedObject);d.ChunkManager=f;h=function(l){function d(b){a(this,d);var e=g(this,Object.getPrototypeOf(d).call(this));e.chunkManager=b;e.chunks=new Map;e.registerDisposer(b.addRef());return e}c(d,l);e(d,[{key:"initializeCounterpart",value:function(a,e){e.chunkManager=this.chunkManager.rpcId;b(Object.getPrototypeOf(d.prototype),"initializeCounterpart",this).call(this,a,e)}},{key:"deleteChunk",value:function(a){this.chunks.delete(a)}},
{key:"addChunk",value:function(a,b){this.chunks.set(a,b)}},{key:"getChunk",value:function(a){throw Error("Not implemented.");}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}}]);return d}(h.SharedObject);d.ChunkSource=h},function(h,d){var f=function(){function c(a,b){for(var e=0;e<b.length;e++){var c=b[e];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(a,b,e){b&&c(a.prototype,b);e&&c(a,e);return a}}(),
g=function(){function c(){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");this.map=new Map}f(c,[{key:"get",value:function(a,b){var e=this.map,c=e.get(a);void 0===c?(c=b(),c.registerDisposer(function(){e.delete(a)}),e.set(a,c)):c.addRef();return c}}]);return c}();d.Memoize=g},function(h,d,f){var g;(function(c){function a(a,b,e,c,d){this._listener=b;this._isOnce=e;this.context=c;this._signal=a;this._priority=d||0}function b(a,b){if("function"!==typeof a)throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",
b));}function e(){this._bindings=[];this._prevParams=null;var a=this;this.dispatch=function(){e.prototype.dispatch.apply(a,arguments)}}a.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},
getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};e.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(b,e,c,d){var f=this._indexOfListener(b,c);if(-1!==f){if(b=this._bindings[f],b.isOnce()!==e)throw Error("You cannot add"+
(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.");}else b=new a(this,b,e,c,d),this._addBinding(b);this.memorize&&this._prevParams&&b.execute(this._prevParams);return b},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var e=this._bindings.length,c;e--;)if(c=this._bindings[e],c._listener===a&&c.context===
b)return e;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,e,c){b(a,"add");return this._registerListener(a,!1,e,c)},addOnce:function(a,e,c){b(a,"addOnce");return this._registerListener(a,!0,e,c)},remove:function(a,e){b(a,"remove");var c=this._indexOfListener(a,e);-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},
halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),e=this._bindings.length,c;this.memorize&&(this._prevParams=b);if(e){c=this._bindings.slice();this._shouldPropagate=!0;do e--;while(c[e]&&this._shouldPropagate&&!1!==c[e].execute(b))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+
this.getNumListeners()+"]"}};e.Signal=e;!(g=function(){return e}.call(d,f,d,h),void 0!==g&&(h.exports=g))})(this)},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a){a.addFragmentExtension("GL_EXT_draw_buffers");a.addFragmentCode(d.glsl_perspectivePanelEmit)}var e=function D(a,b,e){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c)return a=Object.getPrototypeOf(a),null===a?void 0:D(a,b,e);if("value"in c)return c.value;b=c.get;
return void 0===b?void 0:b.call(e)},l=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}(),r=f(25);h=f(30);var n=f(30),k=f(52),p=f(53),m=f(58),t=f(68),q=f(39),v=f(69),x=f(66),w=f(70),z=f(23);f(71);f(72);var C=function(b){function e(){g(this,e);for(var a=arguments.length,b=Array(a),l=0;l<a;l++)b[l]=arguments[l];
var d,a=c(this,(d=Object.getPrototypeOf(e)).call.apply(d,[].concat([this],$jscomp.arrayFromIterable(b))));a.redrawNeeded=new z.Signal;return a}a(e,b);l(e,[{key:"draw",value:function(a){}},{key:"drawPicking",value:function(a){}}]);return e}(h.RenderLayer);d.PerspectiveViewRenderLayer=C;(function(a){a[a.COLOR=0]="COLOR";a[a.Z=1]="Z";a[a.PICK=2]="PICK";a[a.NUM_TEXTURES=3]="NUM_TEXTURES"})(d.OffscreenTextures||(d.OffscreenTextures={}));var u=d.OffscreenTextures;d.glsl_perspectivePanelEmit=[w.glsl_packFloat01ToFixedPoint,
"\nvoid emit(vec4 color, vec4 pickId) {\n  gl_FragData["+u.COLOR+"] = color;\n  gl_FragData["+u.Z+"] = packFloat01ToFixedPoint(1.0 - gl_FragCoord.z);\n  gl_FragData["+u.PICK+"] = pickId;\n}\n"];d.perspectivePanelEmit=b;var y=q.vec3.create(),B=q.mat4.create();f=function(d){function f(a,e,l){g(this,f);var d=c(this,Object.getPrototypeOf(f).call(this,a,e,l));d.visibleLayerTracker=d.registerDisposer(new n.VisibleRenderLayerTracker(d.viewer.layerManager,C,function(a){a.redrawNeeded.add(d.scheduleRedraw,
d);d.scheduleRedraw()},function(a){a.redrawNeeded.remove(d.scheduleRedraw,d);d.scheduleRedraw()}));d.sliceViews=new Set;d.projectionMat=q.mat4.create();d.inverseProjectionMat=q.mat4.create();d.modelViewMat=q.mat4.create();d.width=0;d.height=0;d.pickIDs=new k.PickIDManager;d.axesLineHelper=d.registerDisposer(r.AxesLineHelper.get(d.gl));d.sliceViewRenderHelper=d.registerDisposer(m.SliceViewRenderHelper.get(d.gl,"SliceViewRenderHelper:PerspectivePanel",b));d.offscreenFramebuffer=new x.OffscreenFramebuffer(d.gl,
{numDataBuffers:u.NUM_TEXTURES,depthBuffer:!0,stencilBuffer:!0});d.offscreenCopyHelper=x.OffscreenCopyHelper.get(d.gl);d.registerSignalBinding(d.navigationState.changed.add(function(){d.viewportChanged()}));a=d.registerDisposer(new t.TrackableBooleanCheckbox(l.showSliceViews));a.element.className="perspective-panel-show-slice-views noselect";e=document.createElement("label");e.className="perspective-panel-show-slice-views noselect";e.appendChild(document.createTextNode("Slices"));e.appendChild(a.element);
d.element.appendChild(e);d.registerSignalBinding(l.showSliceViews.changed.add(function(){d.scheduleRedraw()}));d.registerSignalBinding(l.showAxisLines.changed.add(function(){d.scheduleRedraw()}));return d}a(f,d);l(f,[{key:"updateProjectionMatrix",value:function(){var a=this.projectionMat;q.mat4.perspective(a,Math.PI/4,this.width/this.height,10,5E3);var b=this.modelViewMat;this.navigationState.toMat4(b);q.vec3.set(y,1,-1,-1);q.mat4.scale(b,b,y);var e=q.vec3.set(y,0,0,100);q.mat4.translate(b,b,e);q.mat4.invert(B,
b);q.mat4.multiply(a,a,B);q.mat4.invert(this.inverseProjectionMat,a)}},{key:"viewportChanged",value:function(){this.context.scheduleRedraw()}},{key:"onResize",value:function(){this.width=this.element.clientWidth;this.height=this.element.clientHeight;this.viewportChanged()}},{key:"disposed",value:function(){for(var a=$jscomp.makeIterator(this.sliceViews),b=a.next();!b.done;b=a.next())b.value.dispose();this.sliceViews.clear()}},{key:"updateMouseState",value:function(a){a.pickedRenderLayer=null;if(!this.navigationState.valid)return!1;
var b=a.position,e=this.offscreenFramebuffer,c=this.width,l=this.height;if(!e.hasSize(c,l))return!1;var d=this.mouseX,r=l-this.mouseY,n=e.readPixel(u.Z,d,r),n=1-w.unpackFloat01FromFixedPoint(n);if(1===n)return!1;b[0]=2*d/c-1;b[1]=2*r/l-1;b[2]=2*n-1;q.vec3.transformMat4(b,b,this.inverseProjectionMat);this.pickIDs.setMouseState(a,e.readPixelAsUint32(u.PICK,d,r));return!0}},{key:"onMousedown",value:function(a){if(event.target===this.element&&(e(Object.getPrototypeOf(f.prototype),"onMousedown",this).call(this,
a),this.navigationState.valid&&0===a.button)){var b=this;v.startRelativeMouseDrag(a,function(a,e,c){b.navigationState.pose.rotateRelative(q.kAxes[1],-e/4*Math.PI/180);b.navigationState.pose.rotateRelative(q.kAxes[0],c/4*Math.PI/180);b.viewer.navigationState.changed.dispatch()})}}},{key:"draw",value:function(){var a=this.width,b=this.height;if(this.navigationState.valid&&0!==a&&0!==b){for(var e=$jscomp.makeIterator(this.sliceViews),c=e.next();!c.done;c=e.next())c.value.updateRendering();e=this.gl;
this.offscreenFramebuffer.bind(a,b);e.disable(e.SCISSOR_TEST);this.gl.clearColor(0,0,0,0);e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);e.enable(e.DEPTH_TEST);b=this.projectionMat;this.updateProjectionMatrix();c=q.vec4.create();q.vec4.transformMat4(c,q.kAxes[2],this.modelViewMat);q.vec4.normalize(c,c);a=this.pickIDs;a.clear();for(var a={dataToDevice:b,lightDirection:c.subarray(0,3),ambientLighting:.2,directionalLighting:.8,pickIDs:a},l=this.visibleLayerTracker.getVisibleLayers(),d=$jscomp.makeIterator(l),
r=d.next();!r.done;r=d.next())r.value.draw(a);if(this.viewer.showSliceViews.value)for(var d=this.sliceViewRenderHelper,r=$jscomp.makeIterator(this.sliceViews),n=r.next();!n.done;n=r.next()){var n=n.value,k=.2+.8*Math.abs(q.vec3.dot(c,n.viewportAxes[2])),f=B;q.mat4.identity(f);f[0]=n.width/2;f[5]=-n.height/2;q.mat4.multiply(f,n.viewportToData,f);q.mat4.multiply(f,b,f);d.draw(n.offscreenFramebuffer.dataTextures[0],f,q.vec4.fromValues(k,k,k,1),q.vec4.fromValues(.5,.5,.5,1),0,0,1,1)}this.viewer.showAxisLines.value&&
(q.mat4.identity(B),B[0]=1600,B[5]=1600,B[10]=1600,c=this.navigationState.position.spatialCoordinates,B[12]=c[0],B[13]=c[1],B[14]=c[2],B[15]=1,q.mat4.multiply(B,b,B),e.WEBGL_draw_buffers.drawBuffersWEBGL([e.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL]),this.axesLineHelper.draw(B,!1));e.WEBGL_draw_buffers.drawBuffersWEBGL([e.NONE,e.WEBGL_draw_buffers.COLOR_ATTACHMENT1_WEBGL,e.WEBGL_draw_buffers.COLOR_ATTACHMENT2_WEBGL]);b=$jscomp.makeIterator(l);for(c=b.next();!c.done;c=b.next())c.value.drawPicking(a);
e.disable(e.DEPTH_TEST);this.offscreenFramebuffer.unbind();this.setGLViewport();this.offscreenCopyHelper.draw(this.offscreenFramebuffer.dataTextures[u.COLOR])}}},{key:"zoomByMouse",value:function(a){this.navigationState.zoomBy(a)}},{key:"navigationState",get:function(){return this.viewer.navigationState}}]);return f}(p.RenderedDataPanel);d.PerspectivePanel=f},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var c=function(){function a(b,e){for(var c=0;c<e.length;c++){var d=e[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(b,d.key,d)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var a=f(26),b=f(28);f=function(e){function l(e){if(!(this instanceof
l))throw new TypeError("Cannot call a class as a function");var c;c=Object.getPrototypeOf(l).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");c=!c||"object"!==typeof c&&"function"!==typeof c?this:c;c.gl=e;c.vertexBuffer=c.registerDisposer(a.Buffer.fromData(e,new Float32Array([0,0,0,1,1,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,1]),e.ARRAY_BUFFER,e.STATIC_DRAW));c.colorBuffer=c.registerDisposer(a.Buffer.fromData(e,new Float32Array([1,0,0,.5,1,0,0,
.5,0,1,0,.5,0,1,0,.5,0,0,1,.5,0,0,1,.5]),e.ARRAY_BUFFER,e.STATIC_DRAW));c.trivialColorShader=c.registerDisposer(b.trivialColorShader(e));return c}g(l,e);c(l,[{key:"draw",value:function(a){var b=1>=arguments.length||void 0===arguments[1]?!0:arguments[1],e=this.trivialColorShader,c=this.gl;e.bind();c.uniformMatrix4fv(e.uniform("uProjectionMatrix"),!1,a);var l=e.attribute("aVertexPosition");this.vertexBuffer.bindToVertexAttrib(l,4);e=e.attribute("aColor");this.colorBuffer.bindToVertexAttrib(e,4);b&&
(c.colorMask(!1,!1,!1,!0),c.clearColor(0,0,0,0),c.clear(c.COLOR_BUFFER_BIT),c.colorMask(!0,!0,!0,!0),c.enable(c.BLEND),c.blendFunc(c.ONE_MINUS_DST_ALPHA,c.DST_ALPHA));c.lineWidth(1);c.drawArrays(c.LINES,0,6);b&&c.disable(c.BLEND);c.disableVertexAttribArray(l);c.disableVertexAttribArray(e)}}],[{key:"get",value:function(a){return a.memoize.get("SliceViewPanel:AxesLineHelper",function(){return new l(a)})}}]);return l}(h.RefCounted);d.AxesLineHelper=f},function(h,d,f){var g=function(){function a(a,e){for(var c=
0;c<e.length;c++){var d=e[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}(),c=f(27);h=function(){function a(b){var e=1>=arguments.length||void 0===arguments[1]?c.GL_ARRAY_BUFFER:arguments[1];if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.gl=b;this.bufferType=e;this.gl=b;this.buffer=b.createBuffer()}g(a,[{key:"bind",value:function(){this.gl.bindBuffer(this.bufferType,
this.buffer)}},{key:"bindToVertexAttrib",value:function(a,e){var l=2>=arguments.length||void 0===arguments[2]?c.GL_FLOAT:arguments[2],d=3>=arguments.length||void 0===arguments[3]?!1:arguments[3],n=4>=arguments.length||void 0===arguments[4]?0:arguments[4],k=5>=arguments.length||void 0===arguments[5]?0:arguments[5];this.bind();this.gl.enableVertexAttribArray(a);this.gl.vertexAttribPointer(a,e,l,d,n,k)}},{key:"setData",value:function(a){var e=1>=arguments.length||void 0===arguments[1]?c.GL_STATIC_DRAW:
arguments[1],l=this.gl;this.bind();l.bufferData(this.bufferType,a,e)}},{key:"dispose",value:function(){this.gl.deleteBuffer(this.buffer);this.gl=this.buffer=void 0}}],[{key:"fromData",value:function(b,e,c,d){b=new a(b,c);b.setData(e,d);return b}}]);return a}();d.Buffer=h},function(h,d){d.GL_DEPTH_BUFFER_BIT=256;d.GL_STENCIL_BUFFER_BIT=1024;d.GL_COLOR_BUFFER_BIT=16384;d.GL_POINTS=0;d.GL_LINES=1;d.GL_LINE_LOOP=2;d.GL_LINE_STRIP=3;d.GL_TRIANGLES=4;d.GL_TRIANGLE_STRIP=5;d.GL_TRIANGLE_FAN=6;d.GL_ZERO=
0;d.GL_ONE=1;d.GL_SRC_COLOR=768;d.GL_ONE_MINUS_SRC_COLOR=769;d.GL_SRC_ALPHA=770;d.GL_ONE_MINUS_SRC_ALPHA=771;d.GL_DST_ALPHA=772;d.GL_ONE_MINUS_DST_ALPHA=773;d.GL_DST_COLOR=774;d.GL_ONE_MINUS_DST_COLOR=775;d.GL_SRC_ALPHA_SATURATE=776;d.GL_FUNC_ADD=32774;d.GL_BLEND_EQUATION=32777;d.GL_BLEND_EQUATION_RGB=32777;d.GL_BLEND_EQUATION_ALPHA=34877;d.GL_FUNC_SUBTRACT=32778;d.GL_FUNC_REVERSE_SUBTRACT=32779;d.GL_BLEND_DST_RGB=32968;d.GL_BLEND_SRC_RGB=32969;d.GL_BLEND_DST_ALPHA=32970;d.GL_BLEND_SRC_ALPHA=32971;
d.GL_CONSTANT_COLOR=32769;d.GL_ONE_MINUS_CONSTANT_COLOR=32770;d.GL_CONSTANT_ALPHA=32771;d.GL_ONE_MINUS_CONSTANT_ALPHA=32772;d.GL_BLEND_COLOR=32773;d.GL_ARRAY_BUFFER=34962;d.GL_ELEMENT_ARRAY_BUFFER=34963;d.GL_ARRAY_BUFFER_BINDING=34964;d.GL_ELEMENT_ARRAY_BUFFER_BINDING=34965;d.GL_STREAM_DRAW=35040;d.GL_STATIC_DRAW=35044;d.GL_DYNAMIC_DRAW=35048;d.GL_BUFFER_SIZE=34660;d.GL_BUFFER_USAGE=34661;d.GL_CURRENT_VERTEX_ATTRIB=34342;d.GL_FRONT=1028;d.GL_BACK=1029;d.GL_FRONT_AND_BACK=1032;d.GL_CULL_FACE=2884;
d.GL_BLEND=3042;d.GL_DITHER=3024;d.GL_STENCIL_TEST=2960;d.GL_DEPTH_TEST=2929;d.GL_SCISSOR_TEST=3089;d.GL_POLYGON_OFFSET_FILL=32823;d.GL_SAMPLE_ALPHA_TO_COVERAGE=32926;d.GL_SAMPLE_COVERAGE=32928;d.GL_NO_ERROR=0;d.GL_INVALID_ENUM=1280;d.GL_INVALID_VALUE=1281;d.GL_INVALID_OPERATION=1282;d.GL_OUT_OF_MEMORY=1285;d.GL_CW=2304;d.GL_CCW=2305;d.GL_LINE_WIDTH=2849;d.GL_ALIASED_POINT_SIZE_RANGE=33901;d.GL_ALIASED_LINE_WIDTH_RANGE=33902;d.GL_CULL_FACE_MODE=2885;d.GL_FRONT_FACE=2886;d.GL_DEPTH_RANGE=2928;d.GL_DEPTH_WRITEMASK=
2930;d.GL_DEPTH_CLEAR_VALUE=2931;d.GL_DEPTH_FUNC=2932;d.GL_STENCIL_CLEAR_VALUE=2961;d.GL_STENCIL_FUNC=2962;d.GL_STENCIL_FAIL=2964;d.GL_STENCIL_PASS_DEPTH_FAIL=2965;d.GL_STENCIL_PASS_DEPTH_PASS=2966;d.GL_STENCIL_REF=2967;d.GL_STENCIL_VALUE_MASK=2963;d.GL_STENCIL_WRITEMASK=2968;d.GL_STENCIL_BACK_FUNC=34816;d.GL_STENCIL_BACK_FAIL=34817;d.GL_STENCIL_BACK_PASS_DEPTH_FAIL=34818;d.GL_STENCIL_BACK_PASS_DEPTH_PASS=34819;d.GL_STENCIL_BACK_REF=36003;d.GL_STENCIL_BACK_VALUE_MASK=36004;d.GL_STENCIL_BACK_WRITEMASK=
36005;d.GL_VIEWPORT=2978;d.GL_SCISSOR_BOX=3088;d.GL_COLOR_CLEAR_VALUE=3106;d.GL_COLOR_WRITEMASK=3107;d.GL_UNPACK_ALIGNMENT=3317;d.GL_PACK_ALIGNMENT=3333;d.GL_MAX_TEXTURE_SIZE=3379;d.GL_MAX_VIEWPORT_DIMS=3386;d.GL_SUBPIXEL_BITS=3408;d.GL_RED_BITS=3410;d.GL_GREEN_BITS=3411;d.GL_BLUE_BITS=3412;d.GL_ALPHA_BITS=3413;d.GL_DEPTH_BITS=3414;d.GL_STENCIL_BITS=3415;d.GL_POLYGON_OFFSET_UNITS=10752;d.GL_POLYGON_OFFSET_FACTOR=32824;d.GL_TEXTURE_BINDING_2D=32873;d.GL_SAMPLE_BUFFERS=32936;d.GL_SAMPLES=32937;d.GL_SAMPLE_COVERAGE_VALUE=
32938;d.GL_SAMPLE_COVERAGE_INVERT=32939;d.GL_COMPRESSED_TEXTURE_FORMATS=34467;d.GL_DONT_CARE=4352;d.GL_FASTEST=4353;d.GL_NICEST=4354;d.GL_GENERATE_MIPMAP_HINT=33170;d.GL_BYTE=5120;d.GL_UNSIGNED_BYTE=5121;d.GL_SHORT=5122;d.GL_UNSIGNED_SHORT=5123;d.GL_INT=5124;d.GL_UNSIGNED_INT=5125;d.GL_FLOAT=5126;d.GL_DEPTH_COMPONENT=6402;d.GL_ALPHA=6406;d.GL_RGB=6407;d.GL_RGBA=6408;d.GL_LUMINANCE=6409;d.GL_LUMINANCE_ALPHA=6410;d.GL_UNSIGNED_SHORT_4_4_4_4=32819;d.GL_UNSIGNED_SHORT_5_5_5_1=32820;d.GL_UNSIGNED_SHORT_5_6_5=
33635;d.GL_FRAGMENT_SHADER=35632;d.GL_VERTEX_SHADER=35633;d.GL_MAX_VERTEX_ATTRIBS=34921;d.GL_MAX_VERTEX_UNIFORM_VECTORS=36347;d.GL_MAX_VARYING_VECTORS=36348;d.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661;d.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660;d.GL_MAX_TEXTURE_IMAGE_UNITS=34930;d.GL_MAX_FRAGMENT_UNIFORM_VECTORS=36349;d.GL_SHADER_TYPE=35663;d.GL_DELETE_STATUS=35712;d.GL_LINK_STATUS=35714;d.GL_VALIDATE_STATUS=35715;d.GL_ATTACHED_SHADERS=35717;d.GL_ACTIVE_UNIFORMS=35718;d.GL_ACTIVE_ATTRIBUTES=35721;d.GL_SHADING_LANGUAGE_VERSION=
35724;d.GL_CURRENT_PROGRAM=35725;d.GL_NEVER=512;d.GL_LESS=513;d.GL_EQUAL=514;d.GL_LEQUAL=515;d.GL_GREATER=516;d.GL_NOTEQUAL=517;d.GL_GEQUAL=518;d.GL_ALWAYS=519;d.GL_KEEP=7680;d.GL_REPLACE=7681;d.GL_INCR=7682;d.GL_DECR=7683;d.GL_INVERT=5386;d.GL_INCR_WRAP=34055;d.GL_DECR_WRAP=34056;d.GL_VENDOR=7936;d.GL_RENDERER=7937;d.GL_VERSION=7938;d.GL_NEAREST=9728;d.GL_LINEAR=9729;d.GL_NEAREST_MIPMAP_NEAREST=9984;d.GL_LINEAR_MIPMAP_NEAREST=9985;d.GL_NEAREST_MIPMAP_LINEAR=9986;d.GL_LINEAR_MIPMAP_LINEAR=9987;d.GL_TEXTURE_MAG_FILTER=
10240;d.GL_TEXTURE_MIN_FILTER=10241;d.GL_TEXTURE_WRAP_S=10242;d.GL_TEXTURE_WRAP_T=10243;d.GL_TEXTURE_2D=3553;d.GL_TEXTURE=5890;d.GL_TEXTURE_CUBE_MAP=34067;d.GL_TEXTURE_BINDING_CUBE_MAP=34068;d.GL_TEXTURE_CUBE_MAP_POSITIVE_X=34069;d.GL_TEXTURE_CUBE_MAP_NEGATIVE_X=34070;d.GL_TEXTURE_CUBE_MAP_POSITIVE_Y=34071;d.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y=34072;d.GL_TEXTURE_CUBE_MAP_POSITIVE_Z=34073;d.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z=34074;d.GL_MAX_CUBE_MAP_TEXTURE_SIZE=34076;d.GL_TEXTURE0=33984;d.GL_TEXTURE1=33985;
d.GL_TEXTURE2=33986;d.GL_TEXTURE3=33987;d.GL_TEXTURE4=33988;d.GL_TEXTURE5=33989;d.GL_TEXTURE6=33990;d.GL_TEXTURE7=33991;d.GL_TEXTURE8=33992;d.GL_TEXTURE9=33993;d.GL_TEXTURE10=33994;d.GL_TEXTURE11=33995;d.GL_TEXTURE12=33996;d.GL_TEXTURE13=33997;d.GL_TEXTURE14=33998;d.GL_TEXTURE15=33999;d.GL_TEXTURE16=34E3;d.GL_TEXTURE17=34001;d.GL_TEXTURE18=34002;d.GL_TEXTURE19=34003;d.GL_TEXTURE20=34004;d.GL_TEXTURE21=34005;d.GL_TEXTURE22=34006;d.GL_TEXTURE23=34007;d.GL_TEXTURE24=34008;d.GL_TEXTURE25=34009;d.GL_TEXTURE26=
34010;d.GL_TEXTURE27=34011;d.GL_TEXTURE28=34012;d.GL_TEXTURE29=34013;d.GL_TEXTURE30=34014;d.GL_TEXTURE31=34015;d.GL_ACTIVE_TEXTURE=34016;d.GL_REPEAT=10497;d.GL_CLAMP_TO_EDGE=33071;d.GL_MIRRORED_REPEAT=33648;d.GL_FLOAT_VEC2=35664;d.GL_FLOAT_VEC3=35665;d.GL_FLOAT_VEC4=35666;d.GL_INT_VEC2=35667;d.GL_INT_VEC3=35668;d.GL_INT_VEC4=35669;d.GL_BOOL=35670;d.GL_BOOL_VEC2=35671;d.GL_BOOL_VEC3=35672;d.GL_BOOL_VEC4=35673;d.GL_FLOAT_MAT2=35674;d.GL_FLOAT_MAT3=35675;d.GL_FLOAT_MAT4=35676;d.GL_SAMPLER_2D=35678;d.GL_SAMPLER_CUBE=
35680;d.GL_VERTEX_ATTRIB_ARRAY_ENABLED=34338;d.GL_VERTEX_ATTRIB_ARRAY_SIZE=34339;d.GL_VERTEX_ATTRIB_ARRAY_STRIDE=34340;d.GL_VERTEX_ATTRIB_ARRAY_TYPE=34341;d.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED=34922;d.GL_VERTEX_ATTRIB_ARRAY_POINTER=34373;d.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975;d.GL_IMPLEMENTATION_COLOR_READ_TYPE=35738;d.GL_IMPLEMENTATION_COLOR_READ_FORMAT=35739;d.GL_COMPILE_STATUS=35713;d.GL_LOW_FLOAT=36336;d.GL_MEDIUM_FLOAT=36337;d.GL_HIGH_FLOAT=36338;d.GL_LOW_INT=36339;d.GL_MEDIUM_INT=36340;
d.GL_HIGH_INT=36341;d.GL_FRAMEBUFFER=36160;d.GL_RENDERBUFFER=36161;d.GL_RGBA4=32854;d.GL_RGB5_A1=32855;d.GL_RGB565=36194;d.GL_DEPTH_COMPONENT16=33189;d.GL_STENCIL_INDEX=6401;d.GL_STENCIL_INDEX8=36168;d.GL_DEPTH_STENCIL=34041;d.GL_RENDERBUFFER_WIDTH=36162;d.GL_RENDERBUFFER_HEIGHT=36163;d.GL_RENDERBUFFER_INTERNAL_FORMAT=36164;d.GL_RENDERBUFFER_RED_SIZE=36176;d.GL_RENDERBUFFER_GREEN_SIZE=36177;d.GL_RENDERBUFFER_BLUE_SIZE=36178;d.GL_RENDERBUFFER_ALPHA_SIZE=36179;d.GL_RENDERBUFFER_DEPTH_SIZE=36180;d.GL_RENDERBUFFER_STENCIL_SIZE=
36181;d.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048;d.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049;d.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050;d.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051;d.GL_COLOR_ATTACHMENT0=36064;d.GL_DEPTH_ATTACHMENT=36096;d.GL_STENCIL_ATTACHMENT=36128;d.GL_DEPTH_STENCIL_ATTACHMENT=33306;d.GL_NONE=0;d.GL_FRAMEBUFFER_COMPLETE=36053;d.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054;d.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055;d.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS=
36057;d.GL_FRAMEBUFFER_UNSUPPORTED=36061;d.GL_FRAMEBUFFER_BINDING=36006;d.GL_RENDERBUFFER_BINDING=36007;d.GL_MAX_RENDERBUFFER_SIZE=34024;d.GL_INVALID_FRAMEBUFFER_OPERATION=1286;d.GL_UNPACK_FLIP_Y_WEBGL=37440;d.GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441;d.GL_CONTEXT_LOST_WEBGL=37442;d.GL_UNPACK_COLORSPACE_CONVERSION_WEBGL=37443;d.GL_BROWSER_DEFAULT_WEBGL=37444},function(h,d,f){var g=f(29);d.trivialTextureShader=function(c){return c.memoize.get("trivialTextureShader",function(){var a=new g.ShaderBuilder(c);
a.addVarying("vec2","vTexCoord");a.addUniform("sampler2D","uSampler");a.addUniform("mat4","uProjectionMatrix");a.setFragmentMain("gl_FragColor = texture2D(uSampler, vTexCoord);");a.addAttribute("vec4","aVertexPosition");a.addAttribute("vec2","aTexCoord");a.setVertexMain("vTexCoord = aTexCoord; gl_Position = uProjectionMatrix * aVertexPosition;");return a.build()})};d.trivialColorShader=function(c){return c.memoize.get("trivialColorShader",function(){var a=new g.ShaderBuilder(c);a.addVarying("vec4",
"vColor");a.setFragmentMain("gl_FragColor = vColor;");a.addAttribute("vec4","aVertexPosition");a.addAttribute("vec4","aColor");a.addUniform("mat4","uProjectionMatrix");a.setVertexMain("vColor = aColor; gl_Position = uProjectionMatrix * aVertexPosition;");return a.build()})};d.trivialUniformColorShader=function(c){return c.memoize.get("trivialUniformColorShader",function(){var a=new g.ShaderBuilder(c);a.addUniform("mat4","uProjectionMatrix");a.addAttribute("vec4","aVertexPosition");a.addUniform("vec4",
"uColor");a.setFragmentMain("gl_FragColor = uColor;");a.setVertexMain("gl_Position = uProjectionMatrix * aVertexPosition;");return a.build()})}},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a){a=a.replace("\x00","");var b=[];a=$jscomp.makeIterator(a.split("\n"));for(var e=a.next();!e.done;e=a.next()){var e=e.value,c=e.match(/^ERROR:\s*(\d+):(\d+)\s*(.+)$/);null!==c?b.push({message:c[3].trim(),file:parseInt(c[1],10),line:parseInt(c[2],10)}):(c=e.match(/^ERROR:\s*(.+)$/),null!==c?b.push({message:c[1]}):
(e=e.trim())&&b.push({message:e}))}return b}function e(a,e,c){var l=a.createShader(c);a.shaderSource(l,e);a.compileShader(l);if(!a.getShaderParameter(l,a.COMPILE_STATUS))throw a=a.getShaderInfoLog(l)||"",new k(c,e,a,b(a));return l}var l=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}();h=f(12);var r=f(27);(function(a){a[a.VERTEX=
r.GL_VERTEX_SHADER]="VERTEX";a[a.FRAGMENT=r.GL_FRAGMENT_SHADER]="FRAGMENT"})(d.ShaderType||(d.ShaderType={}));var n=d.ShaderType;d.parseShaderErrors=b;var k=function(b){function e(a,b,l,d){g(this,e);var r="Error compiling "+n[a].toLowerCase()+" shader: "+l,k=c(this,Object.getPrototypeOf(e).call(this,r));k.name="ShaderCompilationError";k.log=l;k.message=r;k.shaderType=a;k.source=b;k.errorMessages=d;return k}a(e,b);return e}(Error);d.ShaderCompilationError=k;var p=function(b){function e(a,b,l){g(this,
e);var d="Error linking shader: "+l,r=c(this,Object.getPrototypeOf(e).call(this,d));r.name="ShaderLinkError";r.log=l;r.message=d;r.vertexSource=a;r.fragmentSource=b;return r}a(e,b);return e}(Error);d.ShaderLinkError=p;d.getShader=e;var m=function(b){function d(a,b,l,r,n){g(this,d);var k=c(this,Object.getPrototypeOf(d).call(this));k.gl=a;k.vertexSource=b;k.fragmentSource=l;k.attributes=new Map;k.uniforms=new Map;var f=k.vertexShader=e(a,b,a.VERTEX_SHADER),m=k.fragmentShader=e(a,l,a.FRAGMENT_SHADER),
q=a.createProgram();a.attachShader(q,f);a.attachShader(q,m);a.linkProgram(q);if(!a.getProgramParameter(q,a.LINK_STATUS))throw a=a.getProgramInfoLog(q)||"",new p(b,l,a);k.program=q;l=k.uniforms;b=k.attributes;if(r)for(r=$jscomp.makeIterator(r),f=r.next();!f.done;f=r.next())f=f.value,l.set(f,a.getUniformLocation(q,f));if(n)for(n=$jscomp.makeIterator(n),r=n.next();!r.done;r=n.next())r=r.value,b.set(r,a.getAttribLocation(q,r));return k}a(d,b);l(d,[{key:"uniform",value:function(a){return this.uniforms.get(a)}},
{key:"attribute",value:function(a){return this.attributes.get(a)}},{key:"textureUnit",value:function(a){return this.textureUnits.get(a)}},{key:"bind",value:function(){this.gl.useProgram(this.program)}},{key:"disposed",value:function(){var a=this.gl;a.deleteShader(this.vertexShader);this.vertexShader=void 0;a.deleteShader(this.fragmentShader);this.fragmentShader=void 0;a.deleteProgram(this.program);this.uniforms=this.attributes=this.gl=this.program=void 0}}]);return d}(h.RefCounted);d.ShaderProgram=
m;var t=function(){function a(){g(this,a);this.code="";this.parts=new Set}l(a,[{key:"add",value:function(a){if(!this.parts.has(a))switch(this.parts.add(a),typeof a){case "string":this.code+=a;break;case "function":this.add(a());break;default:if(Array.isArray(a)){a=$jscomp.makeIterator(a);for(var b=a.next();!b.done;b=a.next())this.add(b.value)}else throw Error("Invalid code type");}}},{key:"toString",value:function(){return this.code}}]);return a}();d.ShaderCode=t;f=function(){function a(b){g(this,
a);this.gl=b;this.nextTextureUnit=this.nextSymbolID=0;this.varyingsCode=this.attributesCode=this.uniformsCode="";this.fragmentExtensionsSet=new Set;this.fragmentExtensions="";this.vertexCode=new t;this.vertexMain="";this.fragmentCode=new t;this.fragmentMain="";this.required=new Set;this.uniforms=[];this.attributes=[];this.initializers=[];this.textureUnits=new Map}l(a,[{key:"allocateTextureUnit",value:function(a){var b=1>=arguments.length||void 0===arguments[1]?1:arguments[1];if(this.textureUnits.has(a))throw Error("Duplicate texture unit symbol: "+
a);var e=this.nextTextureUnit;this.nextTextureUnit+=b;this.textureUnits.set(a,e);return e}},{key:"addTextureSampler2D",value:function(a,b,e){var c=this.allocateTextureUnit(b,e);this.addUniform("highp sampler2D",a,e);this.addInitializer(function(b){if(e){for(var l=new Int32Array(e),d=0;d<e;++d)l[d]=d+c;b.gl.uniform1iv(b.uniform(a),l)}else b.gl.uniform1i(b.uniform(a),c)});return c}},{key:"symbol",value:function(a){return a+this.nextSymbolID++}},{key:"addAttribute",value:function(a,b){this.attributes.push(b);
this.attributesCode+="attribute "+a+" "+b+";\n";return b}},{key:"addVarying",value:function(a,b){this.varyingsCode+="varying "+a+" "+b+";\n"}},{key:"addUniform",value:function(a,b,e){this.uniforms.push(b);this.uniformsCode=null!=e?this.uniformsCode+("uniform "+a+" "+b+"["+e+"];\n"):this.uniformsCode+("uniform "+a+" "+b+";\n");return b}},{key:"addFragmentExtension",value:function(a){this.fragmentExtensionsSet.has(a)||(this.fragmentExtensionsSet.add(a),this.fragmentExtensions+="#extension "+a+" : require\n")}},
{key:"addVertexCode",value:function(a){this.vertexCode.add(a)}},{key:"addFragmentCode",value:function(a){this.fragmentCode.add(a)}},{key:"setVertexMain",value:function(a){this.vertexMain=a}},{key:"setFragmentMain",value:function(a){this.fragmentMain="void main() {\n"+a+"\n}\n"}},{key:"setFragmentMainFunction",value:function(a){this.fragmentMain=a}},{key:"addInitializer",value:function(a){this.initializers.push(a)}},{key:"require",value:function(a){this.required.has(a)||(this.required.add(a),a(this))}},
{key:"build",value:function(){var a=new m(this.gl,"\nprecision highp float;\n"+this.uniformsCode+"\n"+this.attributesCode+"\n"+this.varyingsCode+"\n"+this.vertexCode+"\nvoid main() {\n"+this.vertexMain+"\n}\n","\n"+this.fragmentExtensions+"\nprecision highp float;\n"+this.uniformsCode+"\n"+this.varyingsCode+"\n"+this.fragmentCode+"\n"+this.fragmentMain+"\n",this.uniforms,this.attributes);a.textureUnits=this.textureUnits;var b=this.initializers;if(0<b.length){a.bind();for(var b=$jscomp.makeIterator(b),
e=b.next();!e.done;e=b.next())e=e.value,e(a)}return a}}]);return a}();d.ShaderBuilder=f},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);
a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var e=[],c=!0,l=!1,d=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var r=a[Symbol.iterator](),n;!(c=(n=r.next()).done)&&(e.push(n.value),!b||e.length!==b);c=
!0);}catch(k){l=!0,d=k}finally{try{if(!c&&r["return"])r["return"]()}finally{if(l)throw d;}}return e}throw new TypeError("Invalid attempt to destructure non-iterable instance");}}(),e=function(){function a(b,e){for(var c=0;c<e.length;c++){var l=e[c];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in l&&(l.writable=!0);Object.defineProperty(b,l.key,l)}}return function(b,e,c){e&&a(b.prototype,e);c&&a(b,c);return b}}(),l=f(31);h=f(12);var r=f(39),n=f(50),k=f(51),p=f(23);f=function(b){function l(){g(this,
l);for(var a=arguments.length,b=Array(a),e=0;e<a;e++)b[e]=arguments[e];var d,a=c(this,(d=Object.getPrototypeOf(l)).call.apply(d,[].concat([this],$jscomp.arrayFromIterable(b))));a.ready=!1;a.layerChanged=new p.Signal;a.readyStateChanged=new p.Signal;a.voxelSize=null;a.boundingBox=null;return a}a(l,b);e(l,[{key:"setReady",value:function(a){this.ready=a;this.readyStateChanged.dispatch();this.layerChanged.dispatch()}},{key:"handleAction",value:function(a){}},{key:"getValueAt",value:function(a){}}]);return l}(h.RefCounted);
d.RenderLayer=f;f=function(b){function l(){g(this,l);return c(this,Object.getPrototypeOf(l).apply(this,arguments))}a(l,b);e(l,[{key:"onShow",value:function(){}},{key:"onHide",value:function(){}}]);return l}(h.RefCounted);d.UserLayerDropdown=f;f=function(b){function l(){var a=0>=arguments.length||void 0===arguments[0]?[]:arguments[0];g(this,l);var b=c(this,Object.getPrototypeOf(l).call(this));b.layersChanged=new p.Signal;b.readyStateChanged=new p.Signal;b.specificationChanged=new p.Signal;b.renderLayers=
[];a.forEach(b.addRenderLayer.bind(b));return b}a(l,b);e(l,[{key:"addRenderLayer",value:function(a){this.renderLayers.push(a);var b=this.layersChanged,e=this.readyStateChanged;this.registerDisposer(a);this.registerSignalBinding(a.layerChanged.add(b.dispatch,b));this.registerSignalBinding(a.readyStateChanged.add(e.dispatch,e));b.dispatch()}},{key:"getValueAt",value:function(a,b,e){var c=void 0,l=this.renderLayers;if(null!==b&&-1!==l.indexOf(b))return e;b=$jscomp.makeIterator(l);for(e=b.next();!e.done&&
(e=e.value,!e.ready||(c=e.getValueAt(a),void 0===c));e=b.next());return c}},{key:"toJSON",value:function(){return null}},{key:"makeDropdown",value:function(a){}},{key:"handleAction",value:function(a){}}]);return l}(h.RefCounted);d.UserLayer=f;var m=function(b){function l(a){var b=1>=arguments.length||void 0===arguments[1]?null:arguments[1],e=2>=arguments.length||void 0===arguments[2]?!0:arguments[2];g(this,l);var d=c(this,Object.getPrototypeOf(l).call(this));d.name=a;d.visible=e;d.readyStateChanged=
new p.Signal;d.layerChanged=new p.Signal;d.specificationChanged=new p.Signal;d.wasDisposed=!1;d.layer_=null;d.layer=b;return d}a(l,b);e(l,[{key:"updateSignalBindings",value:function(a,b){b(a.layersChanged,this.handleLayerChanged,this);b(a.readyStateChanged,this.readyStateChanged.dispatch,this.readyStateChanged);b(a.specificationChanged,this.specificationChanged.dispatch,this.specificationChanged)}},{key:"handleLayerChanged",value:function(){this.visible&&this.layerChanged.dispatch()}},{key:"setVisible",
value:function(a){a!==this.visible&&(this.visible=a,this.layerChanged.dispatch())}},{key:"disposed",value:function(){this.wasDisposed=!0}},{key:"layer",get:function(){return this.layer_},set:function(a){var b=this.layer_;null!=b&&this.updateSignalBindings(b,n.removeSignalBinding);this.layer_=a;null!=a&&(this.updateSignalBindings(a,n.addSignalBinding),this.readyStateChanged.dispatch(),this.handleLayerChanged())}}]);return l}(h.RefCounted);d.ManagedUserLayer=m;f=function(l){function d(){g(this,d);for(var a=
arguments.length,b=Array(a),e=0;e<a;e++)b[e]=arguments[e];var l,a=c(this,(l=Object.getPrototypeOf(d)).call.apply(l,[].concat([this],$jscomp.arrayFromIterable(b))));a.managedLayers=[];a.layersChanged=new p.Signal;a.readyStateChanged=new p.Signal;a.specificationChanged=new p.Signal;a.boundPositions=new WeakSet;return a}a(d,l);e(d,[{key:"updateSignalBindings",value:function(a,b){b(a.layerChanged,this.layersChanged.dispatch,this.layersChanged);b(a.readyStateChanged,this.readyStateChanged.dispatch,this.readyStateChanged);
b(a.specificationChanged,this.specificationChanged.dispatch,this.specificationChanged)}},{key:"addManagedLayer",value:function(a){this.updateSignalBindings(a,n.addSignalBinding);this.managedLayers.push(a);this.layersChanged.dispatch();return a}},{key:"addUserLayer",value:function(a,b,e){a=new m(a,b,e);return this.addManagedLayer(a)}},{key:"readyRenderLayers",value:function(){function a(f,p){for(;;)switch(b){case 0:n=$jscomp.makeIterator(k.managedLayers),r=n.next();case 1:if(r.done){b=3;break}d=r.value;
if(d.visible&&d.layer){b=4;break}b=2;break;case 4:l=$jscomp.makeIterator(d.layer.renderLayers),c=l.next();case 5:if(c.done){b=7;break}e=c.value;if(e.ready){b=8;break}b=6;break;case 8:return b=9,{value:e,done:!1};case 9:if(void 0===p){b=10;break}b=-1;throw p;case 10:case 6:c=l.next();b=5;break;case 7:case 2:r=n.next();b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,e,c,l,d,r,n,k=this,f={next:function(b){return a(b,void 0)},throw:function(b){return a(void 0,b)},return:function(a){throw Error("Not yet implemented");
}};$jscomp.initSymbolIterator();f[Symbol.iterator]=function(){return this};return f}},{key:"unbindManagedLayer",value:function(a){this.updateSignalBindings(a,n.removeSignalBinding);a.dispose()}},{key:"clear",value:function(){for(var a=$jscomp.makeIterator(this.managedLayers),b=a.next();!b.done;b=a.next())this.unbindManagedLayer(b.value);this.managedLayers.length=0;this.layersChanged.dispatch()}},{key:"removeManagedLayer",value:function(a){var b=this.managedLayers.indexOf(a);if(-1===b)throw Error("Internal error: invalid managed layer.");
this.unbindManagedLayer(a);this.managedLayers.splice(b,1);this.layersChanged.dispatch()}},{key:"reorderManagedLayer",value:function(a,e){var c=this.managedLayers.length;a===e||0>a||a>=c||0>e||e>=c||(c=this.managedLayers.splice(a,1),c=b(c,1)[0],this.managedLayers.splice(e,0,c),this.layersChanged.dispatch())}},{key:"disposed",value:function(){this.clear()}},{key:"getLayerByName",value:function(a){return this.managedLayers.find(function(b){return b.name===a})}},{key:"initializePosition",value:function(a){var b=
this;if(!a.valid&&!this.updatePositionFromLayers(a)){var e=this.boundPositions;if(!e.has(a)){e.add(a);var c=function(){b.updatePositionFromLayers(a);a.valid&&(b.readyStateChanged.remove(c),b.boundPositions.delete(a))};this.readyStateChanged.add(c)}}}},{key:"updatePositionFromLayers",value:function(a){if(!a.valid)for(var b=$jscomp.makeIterator(this.managedLayers),e=b.next();!e.done;e=b.next())if(e=e.value.layer,null!=e)for(var e=$jscomp.makeIterator(e.renderLayers),c=e.next();!c.done;c=e.next())if(c=
c.value,c.ready&&(a.voxelSize.valid||null==c.voxelSize||(r.vec3.copy(a.voxelSize.size,c.voxelSize),a.voxelSize.setValid()),!a.spatialCoordinatesValid&&!a.voxelCoordinatesValid&&null!=c.boundingBox)){var c=c.boundingBox,l=r.vec3.create();r.vec3.add(l,c.lower,c.upper);r.vec3.scale(l,l,.5);a.setVoxelCoordinates(l)}}},{key:"invokeAction",value:function(a){for(var b=$jscomp.makeIterator(this.managedLayers),e=b.next();!e.done;e=b.next())if(e=e.value,null!==e.layer&&e.visible){e=e.layer;e.handleAction(a);
for(var e=$jscomp.makeIterator(e.renderLayers),c=e.next();!c.done;c=e.next())c=c.value,c.ready&&c.handleAction(a)}}},{key:"renderLayers",get:function(){var a=this;$jscomp.initSymbol();$jscomp.initSymbolIterator();var b={};return b[Symbol.iterator]=function(){function b(f,p){for(;;)switch(e){case 0:k=$jscomp.makeIterator(a.managedLayers),n=k.next();case 1:if(n.done){e=3;break}r=n.value;if(null!==r.layer){e=4;break}e=2;break;case 4:d=$jscomp.makeIterator(r.layer.renderLayers),l=d.next();case 5:if(l.done){e=
7;break}c=l.value;e=8;return{value:c,done:!1};case 8:if(void 0===p){e=9;break}e=-1;throw p;case 9:case 6:l=d.next();e=5;break;case 7:case 2:n=k.next();e=1;break;case 3:e=-1;default:return{value:void 0,done:!0}}}var e=0,c,l,d,r,n,k,f={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();f[Symbol.iterator]=function(){return this};return f},b}},{key:"visibleRenderLayers",get:function(){var a=this;
$jscomp.initSymbol();$jscomp.initSymbolIterator();var b={};return b[Symbol.iterator]=function(){function b(f,p){for(;;)switch(e){case 0:k=$jscomp.makeIterator(a.managedLayers),n=k.next();case 1:if(n.done){e=3;break}r=n.value;if(null!==r.layer&&r.visible){e=4;break}e=2;break;case 4:d=$jscomp.makeIterator(r.layer.renderLayers),l=d.next();case 5:if(l.done){e=7;break}c=l.value;e=8;return{value:c,done:!1};case 8:if(void 0===p){e=9;break}e=-1;throw p;case 9:case 6:l=d.next();e=5;break;case 7:case 2:n=k.next();
e=1;break;case 3:e=-1;default:return{value:void 0,done:!0}}}var e=0,c,l,d,r,n,k,f={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();f[Symbol.iterator]=function(){return this};return f},b}}]);return d}(h.RefCounted);d.LayerManager=f;f=function(){function a(){var b=this;g(this,a);this.changed=new p.Signal;this.position=r.vec3.create();this.active=!1;this.pickedRenderLayer=null;this.pickedValue=
new k.Uint64(0,0);this.updater=void 0;this.stale=!1;this.triggerUpdate=l(function(){b.update()},50,{leading:!0,trailing:!0})}e(a,[{key:"updateUnconditionally",value:function(){this.triggerUpdate.cancel();this.update();return this.active}},{key:"updateIfStale",value:function(){this.stale&&this.update()}},{key:"update",value:function(){var a=this.updater;this.stale=!1;a?this.setActive(a(this)):this.setActive(!1)}},{key:"setActive",value:function(a){this.stale=!1;if(this.active!==a||!0===a)this.active=
a,this.changed.dispatch()}}]);return a}();d.MouseSelectionState=f;f=function(b){function l(a,b){g(this,l);var e=c(this,Object.getPrototypeOf(l).call(this));e.layerManager=a;e.mouseState=b;e.values=new Map;e.changed=new p.Signal;e.needsUpdate=!0;e.registerSignalBinding(b.changed.add(e.handleChange,e));e.registerSignalBinding(a.layersChanged.add(function(){e.handleLayerChange()}));return e}a(l,b);e(l,[{key:"handleLayerChange",value:function(){this.mouseState.active&&this.handleChange()}},{key:"handleChange",
value:function(){this.needsUpdate=!0;this.changed.dispatch()}},{key:"update",value:function(){if(this.needsUpdate){this.needsUpdate=!1;var a=this.values,b=this.mouseState;a.clear();if(b.active)for(var e=b.position,c=$jscomp.makeIterator(this.layerManager.managedLayers),l=c.next();!l.done;l=c.next()){var l=l.value,d=l.layer;l.visible&&d&&a.set(d,d.getValueAt(e,b.pickedRenderLayer,b.pickedValue))}}}},{key:"get",value:function(a){this.update();return this.values.get(a)}}]);return l}(h.RefCounted);d.LayerSelectedValues=
f;h=function(b){function l(a,b,e,d){g(this,l);var r=c(this,Object.getPrototypeOf(l).call(this));r.layerManager=a;r.renderLayerType=b;r.layerAdded=e;r.layerRemoved=d;r.visibleLayers=new Set;r.newVisibleLayers=new Set;r.updatePending=null;r.registerSignalBinding(a.layersChanged.add(r.handleLayersChanged,r));r.updateVisibleLayers();return r}a(l,b);e(l,[{key:"handleLayersChanged",value:function(){if(null===this.updatePending){var a=this;this.updatePending=setTimeout(function(){a.updatePending=null;a.updateVisibleLayers()},
0)}}},{key:"disposed",value:function(){this.cancelUpdate();this.visibleLayers.forEach(this.layerRemoved);this.visibleLayers.clear()}},{key:"cancelUpdate",value:function(){var a=this.updatePending;null!==a&&clearTimeout(a)}},{key:"updateVisibleLayers",value:function(){for(var a=this.visibleLayers,b=this.newVisibleLayers,e=this.renderLayerType,c=this.layerAdded,l=this.layerRemoved,d=$jscomp.makeIterator(this.layerManager.readyRenderLayers()),r=d.next();!r.done;r=d.next())r=r.value,r instanceof e&&(b.add(r),
a.has(r)||(a.add(r),c(r)));e=$jscomp.makeIterator(a);for(c=e.next();!c.done;c=e.next())c=c.value,b.has(c)||(a.delete(c),l(c));b.clear()}},{key:"getVisibleLayers",value:function(){null!==this.updatePending&&(this.cancelUpdate(),this.updateVisibleLayers());return this.visibleLayers}}]);return l}(h.RefCounted);d.VisibleRenderLayerTracker=h},function(h,d,f){var g=f(32),c=f(33);h.exports=function(a,b,e){var l=!0,d=!0;if("function"!=typeof a)throw new TypeError("Expected a function");c(e)&&(l="leading"in
e?!!e.leading:l,d="trailing"in e?!!e.trailing:d);return g(a,b,{leading:l,maxWait:b,trailing:d})}},function(h,d,f){var g=f(33),c=f(34),a=f(35),b=Math.max,e=Math.min;h.exports=function(l,d,n){function k(a){var b=h,e=x;h=x=void 0;y=a;return z=l.apply(e,b)}function f(a){var b=a-u;a-=y;return void 0===u||b>=d||0>b||A&&a>=w}function m(){var a=c();if(f(a))return t(a);var b=setTimeout,l;l=a-y;a=d-(a-u);l=A?e(a,w-l):a;C=b(m,l)}function t(a){C=void 0;if(D&&h)return k(a);h=x=void 0;return z}function q(){var a=
c(),b=f(a);h=arguments;x=this;u=a;if(b){if(void 0===C)return y=a=u,C=setTimeout(m,d),B?k(a):z;if(A)return C=setTimeout(m,d),k(u)}void 0===C&&(C=setTimeout(m,d));return z}var h,x,w,z,C,u,y=0,B=!1,A=!1,D=!0;if("function"!=typeof l)throw new TypeError("Expected a function");d=a(d)||0;g(n)&&(B=!!n.leading,w=(A="maxWait"in n)?b(a(n.maxWait)||0,d):w,D="trailing"in n?!!n.trailing:D);q.cancel=function(){y=0;h=u=x=C=void 0};q.flush=function(){return void 0===C?z:t(c())};return q}},function(h,d){h.exports=
function(d){var g=typeof d;return!!d&&("object"==g||"function"==g)}},function(h,d){h.exports=function(){return Date.now()}},function(h,d,f){var g=f(36),c=f(33),a=f(37),b=0/0,e=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,n=/^0o[0-7]+$/i,k=parseInt;h.exports=function(d){if("number"==typeof d)return d;if(a(d))return b;c(d)&&(d=g(d.valueOf)?d.valueOf():d,d=c(d)?d+"":d);if("string"!=typeof d)return 0===d?d:+d;d=d.replace(e,"");var f=r.test(d);return f||n.test(d)?k(d.slice(2),f?2:8):l.test(d)?b:
+d}},function(h,d,f){var g=f(33),c=Object.prototype.toString;h.exports=function(a){a=g(a)?c.call(a):"";return"[object Function]"==a||"[object GeneratorFunction]"==a}},function(h,d,f){var g=f(38),c=Object.prototype.toString;h.exports=function(a){return"symbol"==typeof a||g(a)&&"[object Symbol]"==c.call(a)}},function(h,d){h.exports=function(d){return!!d&&"object"==typeof d}},function(h,d,f){function g(c,a){var b=Math.abs(c[a]),e=Math.abs(c[a+1]),l=Math.abs(c[a+2]),d=Math.max(b,e,l);1E-4>b/d&&(c[a]=
0);1E-4>e/d&&(c[a+1]=0);1E-4>l/d&&(c[a+2]=0)}h=f(40);f=f(40);d.mat2=f.mat2;d.mat3=f.mat3;d.mat4=f.mat4;d.quat=f.quat;d.vec2=f.vec2;d.vec3=f.vec3;d.vec4=f.vec4;d.identityMat4=h.mat4.create();d.AXES_NAMES=["x","y","z"];d.BoundingBox=function a(b,e){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.lower=b;this.upper=e};d.kAxes=[h.vec4.fromValues(1,0,0,0),h.vec4.fromValues(0,1,0,0),h.vec4.fromValues(0,0,1,0)];d.kZeroVec=h.vec3.fromValues(0,0,0);d.prod3=function(a){return a[0]*
a[1]*a[2]};d.prod4=function(a){return a[0]*a[1]*a[2]*a[3]};d.vec3Key=function(a){return a[0]+","+a[1]+","+a[2]};d.rectifyVec3IfAxisAligned=g;d.rectifyTransformMatrixIfAxisAligned=function(a){g(a,0);g(a,4);g(a,8)}},function(h,d,f){d.glMatrix=f(41);d.mat2=f(42);d.mat2d=f(43);d.mat3=f(44);d.mat4=f(45);d.quat=f(46);d.vec2=f(49);d.vec3=f(47);d.vec4=f(48)},function(h,d){var f={EPSILON:1E-6};f.ARRAY_TYPE="undefined"!==typeof Float32Array?Float32Array:Array;f.RANDOM=Math.random;f.ENABLE_SIMD=!1;f.SIMD_AVAILABLE=
f.ARRAY_TYPE===Float32Array&&"SIMD"in this;f.USE_SIMD=f.ENABLE_SIMD&&f.SIMD_AVAILABLE;f.setMatrixArrayType=function(c){f.ARRAY_TYPE=c};var g=Math.PI/180;f.toRadian=function(c){return c*g};f.equals=function(c,a){return Math.abs(c-a)<=f.EPSILON*Math.max(1,Math.abs(c),Math.abs(a))};h.exports=f},function(h,d,f){var g=f(41);d={create:function(){var c=new g.ARRAY_TYPE(4);c[0]=1;c[1]=0;c[2]=0;c[3]=1;return c},clone:function(c){var a=new g.ARRAY_TYPE(4);a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];return a},copy:function(c,
a){c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];return c},identity:function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=1;return c},fromValues:function(c,a,b,e){var l=new g.ARRAY_TYPE(4);l[0]=c;l[1]=a;l[2]=b;l[3]=e;return l},set:function(c,a,b,e,l){c[0]=a;c[1]=b;c[2]=e;c[3]=l;return c},transpose:function(c,a){if(c===a){var b=a[1];c[1]=a[2];c[2]=b}else c[0]=a[0],c[1]=a[2],c[2]=a[1],c[3]=a[3];return c},invert:function(c,a){var b=a[0],e=a[1],l=a[2],d=a[3],n=b*d-l*e;if(!n)return null;n=1/n;c[0]=d*n;c[1]=-e*n;c[2]=-l*n;c[3]=
b*n;return c},adjoint:function(c,a){var b=a[0];c[0]=a[3];c[1]=-a[1];c[2]=-a[2];c[3]=b;return c},determinant:function(c){return c[0]*c[3]-c[2]*c[1]},multiply:function(c,a,b){var e=a[0],l=a[1],d=a[2];a=a[3];var n=b[0],k=b[1],f=b[2];b=b[3];c[0]=e*n+d*k;c[1]=l*n+a*k;c[2]=e*f+d*b;c[3]=l*f+a*b;return c}};d.mul=d.multiply;d.rotate=function(c,a,b){var e=a[0],l=a[1],d=a[2];a=a[3];var n=Math.sin(b);b=Math.cos(b);c[0]=e*b+d*n;c[1]=l*b+a*n;c[2]=e*-n+d*b;c[3]=l*-n+a*b;return c};d.scale=function(c,a,b){var e=a[1],
l=a[2],d=a[3],n=b[0];b=b[1];c[0]=a[0]*n;c[1]=e*n;c[2]=l*b;c[3]=d*b;return c};d.fromRotation=function(c,a){var b=Math.sin(a),e=Math.cos(a);c[0]=e;c[1]=b;c[2]=-b;c[3]=e;return c};d.fromScaling=function(c,a){c[0]=a[0];c[1]=0;c[2]=0;c[3]=a[1];return c};d.str=function(c){return"mat2("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+")"};d.frob=function(c){return Math.sqrt(Math.pow(c[0],2)+Math.pow(c[1],2)+Math.pow(c[2],2)+Math.pow(c[3],2))};d.LDU=function(c,a,b,e){c[2]=e[2]/e[0];b[0]=e[0];b[1]=e[1];b[3]=e[3]-c[2]*
b[1];return[c,a,b]};d.add=function(c,a,b){c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];return c};d.subtract=function(c,a,b){c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];c[3]=a[3]-b[3];return c};d.sub=d.subtract;d.exactEquals=function(c,a){return c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]&&c[3]===a[3]};d.equals=function(c,a){var b=c[0],e=c[1],l=c[2],d=c[3],n=a[0],k=a[1],f=a[2],m=a[3];return Math.abs(b-n)<=g.EPSILON*Math.max(1,Math.abs(b),Math.abs(n))&&Math.abs(e-k)<=g.EPSILON*Math.max(1,
Math.abs(e),Math.abs(k))&&Math.abs(l-f)<=g.EPSILON*Math.max(1,Math.abs(l),Math.abs(f))&&Math.abs(d-m)<=g.EPSILON*Math.max(1,Math.abs(d),Math.abs(m))};d.multiplyScalar=function(c,a,b){c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;return c};d.multiplyScalarAndAdd=function(c,a,b,e){c[0]=a[0]+b[0]*e;c[1]=a[1]+b[1]*e;c[2]=a[2]+b[2]*e;c[3]=a[3]+b[3]*e;return c};h.exports=d},function(h,d,f){var g=f(41);d={create:function(){var c=new g.ARRAY_TYPE(6);c[0]=1;c[1]=0;c[2]=0;c[3]=1;c[4]=0;c[5]=0;return c},clone:function(c){var a=
new g.ARRAY_TYPE(6);a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];a[4]=c[4];a[5]=c[5];return a},copy:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];c[4]=a[4];c[5]=a[5];return c},identity:function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=1;c[4]=0;c[5]=0;return c},fromValues:function(c,a,b,e,l,d){var n=new g.ARRAY_TYPE(6);n[0]=c;n[1]=a;n[2]=b;n[3]=e;n[4]=l;n[5]=d;return n},set:function(c,a,b,e,l,d,n){c[0]=a;c[1]=b;c[2]=e;c[3]=l;c[4]=d;c[5]=n;return c},invert:function(c,a){var b=a[0],e=a[1],l=a[2],d=a[3],n=a[4],
k=a[5],f=b*d-e*l;if(!f)return null;f=1/f;c[0]=d*f;c[1]=-e*f;c[2]=-l*f;c[3]=b*f;c[4]=(l*k-d*n)*f;c[5]=(e*n-b*k)*f;return c},determinant:function(c){return c[0]*c[3]-c[1]*c[2]},multiply:function(c,a,b){var e=a[0],l=a[1],d=a[2],n=a[3],k=a[4];a=a[5];var f=b[0],m=b[1],t=b[2],q=b[3],g=b[4];b=b[5];c[0]=e*f+d*m;c[1]=l*f+n*m;c[2]=e*t+d*q;c[3]=l*t+n*q;c[4]=e*g+d*b+k;c[5]=l*g+n*b+a;return c}};d.mul=d.multiply;d.rotate=function(c,a,b){var e=a[0],l=a[1],d=a[2],n=a[3],k=a[4];a=a[5];var f=Math.sin(b);b=Math.cos(b);
c[0]=e*b+d*f;c[1]=l*b+n*f;c[2]=e*-f+d*b;c[3]=l*-f+n*b;c[4]=k;c[5]=a;return c};d.scale=function(c,a,b){var e=a[1],l=a[2],d=a[3],n=a[4],k=a[5],f=b[0];b=b[1];c[0]=a[0]*f;c[1]=e*f;c[2]=l*b;c[3]=d*b;c[4]=n;c[5]=k;return c};d.translate=function(c,a,b){var e=a[0],l=a[1],d=a[2],n=a[3],k=a[4];a=a[5];var f=b[0];b=b[1];c[0]=e;c[1]=l;c[2]=d;c[3]=n;c[4]=e*f+d*b+k;c[5]=l*f+n*b+a;return c};d.fromRotation=function(c,a){var b=Math.sin(a),e=Math.cos(a);c[0]=e;c[1]=b;c[2]=-b;c[3]=e;c[4]=0;c[5]=0;return c};d.fromScaling=
function(c,a){c[0]=a[0];c[1]=0;c[2]=0;c[3]=a[1];c[4]=0;c[5]=0;return c};d.fromTranslation=function(c,a){c[0]=1;c[1]=0;c[2]=0;c[3]=1;c[4]=a[0];c[5]=a[1];return c};d.str=function(c){return"mat2d("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+", "+c[4]+", "+c[5]+")"};d.frob=function(c){return Math.sqrt(Math.pow(c[0],2)+Math.pow(c[1],2)+Math.pow(c[2],2)+Math.pow(c[3],2)+Math.pow(c[4],2)+Math.pow(c[5],2)+1)};d.add=function(c,a,b){c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];c[4]=a[4]+b[4];c[5]=a[5]+
b[5];return c};d.subtract=function(c,a,b){c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];c[3]=a[3]-b[3];c[4]=a[4]-b[4];c[5]=a[5]-b[5];return c};d.sub=d.subtract;d.multiplyScalar=function(c,a,b){c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;c[4]=a[4]*b;c[5]=a[5]*b;return c};d.multiplyScalarAndAdd=function(c,a,b,e){c[0]=a[0]+b[0]*e;c[1]=a[1]+b[1]*e;c[2]=a[2]+b[2]*e;c[3]=a[3]+b[3]*e;c[4]=a[4]+b[4]*e;c[5]=a[5]+b[5]*e;return c};d.exactEquals=function(c,a){return c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]&&
c[3]===a[3]&&c[4]===a[4]&&c[5]===a[5]};d.equals=function(c,a){var b=c[0],e=c[1],l=c[2],d=c[3],n=c[4],k=c[5],f=a[0],m=a[1],t=a[2],q=a[3],h=a[4],x=a[5];return Math.abs(b-f)<=g.EPSILON*Math.max(1,Math.abs(b),Math.abs(f))&&Math.abs(e-m)<=g.EPSILON*Math.max(1,Math.abs(e),Math.abs(m))&&Math.abs(l-t)<=g.EPSILON*Math.max(1,Math.abs(l),Math.abs(t))&&Math.abs(d-q)<=g.EPSILON*Math.max(1,Math.abs(d),Math.abs(q))&&Math.abs(n-h)<=g.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(k-x)<=g.EPSILON*Math.max(1,
Math.abs(k),Math.abs(x))};h.exports=d},function(h,d,f){var g=f(41);d={create:function(){var c=new g.ARRAY_TYPE(9);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c},fromMat4:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[4];c[4]=a[5];c[5]=a[6];c[6]=a[8];c[7]=a[9];c[8]=a[10];return c},clone:function(c){var a=new g.ARRAY_TYPE(9);a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];a[4]=c[4];a[5]=c[5];a[6]=c[6];a[7]=c[7];a[8]=c[8];return a},copy:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];
c[3]=a[3];c[4]=a[4];c[5]=a[5];c[6]=a[6];c[7]=a[7];c[8]=a[8];return c},fromValues:function(c,a,b,e,d,r,n,k,f){var m=new g.ARRAY_TYPE(9);m[0]=c;m[1]=a;m[2]=b;m[3]=e;m[4]=d;m[5]=r;m[6]=n;m[7]=k;m[8]=f;return m},set:function(c,a,b,e,d,r,n,k,f,m){c[0]=a;c[1]=b;c[2]=e;c[3]=d;c[4]=r;c[5]=n;c[6]=k;c[7]=f;c[8]=m;return c},identity:function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c},transpose:function(c,a){if(c===a){var b=a[1],e=a[2],d=a[5];c[1]=a[3];c[2]=a[6];c[3]=b;c[5]=a[7];
c[6]=e;c[7]=d}else c[0]=a[0],c[1]=a[3],c[2]=a[6],c[3]=a[1],c[4]=a[4],c[5]=a[7],c[6]=a[2],c[7]=a[5],c[8]=a[8];return c},invert:function(c,a){var b=a[0],e=a[1],d=a[2],r=a[3],n=a[4],k=a[5],f=a[6],m=a[7],t=a[8],q=t*n-k*m,g=-t*r+k*f,h=m*r-n*f,w=b*q+e*g+d*h;if(!w)return null;w=1/w;c[0]=q*w;c[1]=(-t*e+d*m)*w;c[2]=(k*e-d*n)*w;c[3]=g*w;c[4]=(t*b-d*f)*w;c[5]=(-k*b+d*r)*w;c[6]=h*w;c[7]=(-m*b+e*f)*w;c[8]=(n*b-e*r)*w;return c},adjoint:function(c,a){var b=a[0],e=a[1],d=a[2],r=a[3],n=a[4],k=a[5],f=a[6],m=a[7],t=
a[8];c[0]=n*t-k*m;c[1]=d*m-e*t;c[2]=e*k-d*n;c[3]=k*f-r*t;c[4]=b*t-d*f;c[5]=d*r-b*k;c[6]=r*m-n*f;c[7]=e*f-b*m;c[8]=b*n-e*r;return c},determinant:function(c){var a=c[3],b=c[4],e=c[5],d=c[6],r=c[7],n=c[8];return c[0]*(n*b-e*r)+c[1]*(-n*a+e*d)+c[2]*(r*a-b*d)},multiply:function(c,a,b){var e=a[0],d=a[1],r=a[2],n=a[3],f=a[4],p=a[5],m=a[6],t=a[7];a=a[8];var q=b[0],g=b[1],h=b[2],w=b[3],z=b[4],C=b[5],u=b[6],y=b[7];b=b[8];c[0]=q*e+g*n+h*m;c[1]=q*d+g*f+h*t;c[2]=q*r+g*p+h*a;c[3]=w*e+z*n+C*m;c[4]=w*d+z*f+C*t;c[5]=
w*r+z*p+C*a;c[6]=u*e+y*n+b*m;c[7]=u*d+y*f+b*t;c[8]=u*r+y*p+b*a;return c}};d.mul=d.multiply;d.translate=function(c,a,b){var e=a[0],d=a[1],r=a[2],n=a[3],f=a[4],p=a[5],m=a[6],t=a[7];a=a[8];var q=b[0];b=b[1];c[0]=e;c[1]=d;c[2]=r;c[3]=n;c[4]=f;c[5]=p;c[6]=q*e+b*n+m;c[7]=q*d+b*f+t;c[8]=q*r+b*p+a;return c};d.rotate=function(c,a,b){var e=a[0],d=a[1],r=a[2],n=a[3],f=a[4],p=a[5],m=a[6],t=a[7];a=a[8];var q=Math.sin(b);b=Math.cos(b);c[0]=b*e+q*n;c[1]=b*d+q*f;c[2]=b*r+q*p;c[3]=b*n-q*e;c[4]=b*f-q*d;c[5]=b*p-q*
r;c[6]=m;c[7]=t;c[8]=a;return c};d.scale=function(c,a,b){var e=b[0];b=b[1];c[0]=e*a[0];c[1]=e*a[1];c[2]=e*a[2];c[3]=b*a[3];c[4]=b*a[4];c[5]=b*a[5];c[6]=a[6];c[7]=a[7];c[8]=a[8];return c};d.fromTranslation=function(c,a){c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=a[0];c[7]=a[1];c[8]=1;return c};d.fromRotation=function(c,a){var b=Math.sin(a),e=Math.cos(a);c[0]=e;c[1]=b;c[2]=0;c[3]=-b;c[4]=e;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c};d.fromScaling=function(c,a){c[0]=a[0];c[1]=0;c[2]=0;c[3]=0;c[4]=a[1];
c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c};d.fromMat2d=function(c,a){c[0]=a[0];c[1]=a[1];c[2]=0;c[3]=a[2];c[4]=a[3];c[5]=0;c[6]=a[4];c[7]=a[5];c[8]=1;return c};d.fromQuat=function(c,a){var b=a[0],e=a[1],d=a[2],r=a[3],n=b+b,f=e+e,p=d+d,b=b*n,m=e*n,e=e*f,t=d*n,q=d*f,d=d*p,n=r*n,f=r*f,r=r*p;c[0]=1-e-d;c[3]=m-r;c[6]=t+f;c[1]=m+r;c[4]=1-b-d;c[7]=q-n;c[2]=t-f;c[5]=q+n;c[8]=1-b-e;return c};d.normalFromMat4=function(c,a){var b=a[0],e=a[1],d=a[2],f=a[3],n=a[4],k=a[5],p=a[6],m=a[7],t=a[8],q=a[9],g=a[10],h=a[11],
w=a[12],z=a[13],C=a[14],u=a[15],y=b*k-e*n,B=b*p-d*n,A=b*m-f*n,D=e*p-d*k,E=e*m-f*k,H=d*m-f*p,G=t*z-q*w,P=t*C-g*w,t=t*u-h*w,R=q*C-g*z,q=q*u-h*z,g=g*u-h*C,h=y*g-B*q+A*R+D*t-E*P+H*G;if(!h)return null;h=1/h;c[0]=(k*g-p*q+m*R)*h;c[1]=(p*t-n*g-m*P)*h;c[2]=(n*q-k*t+m*G)*h;c[3]=(d*q-e*g-f*R)*h;c[4]=(b*g-d*t+f*P)*h;c[5]=(e*t-b*q-f*G)*h;c[6]=(z*H-C*E+u*D)*h;c[7]=(C*A-w*H-u*B)*h;c[8]=(w*E-z*A+u*y)*h;return c};d.str=function(c){return"mat3("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+", "+c[4]+", "+c[5]+", "+c[6]+", "+
c[7]+", "+c[8]+")"};d.frob=function(c){return Math.sqrt(Math.pow(c[0],2)+Math.pow(c[1],2)+Math.pow(c[2],2)+Math.pow(c[3],2)+Math.pow(c[4],2)+Math.pow(c[5],2)+Math.pow(c[6],2)+Math.pow(c[7],2)+Math.pow(c[8],2))};d.add=function(c,a,b){c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];c[4]=a[4]+b[4];c[5]=a[5]+b[5];c[6]=a[6]+b[6];c[7]=a[7]+b[7];c[8]=a[8]+b[8];return c};d.subtract=function(c,a,b){c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];c[3]=a[3]-b[3];c[4]=a[4]-b[4];c[5]=a[5]-b[5];c[6]=a[6]-
b[6];c[7]=a[7]-b[7];c[8]=a[8]-b[8];return c};d.sub=d.subtract;d.multiplyScalar=function(c,a,b){c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;c[4]=a[4]*b;c[5]=a[5]*b;c[6]=a[6]*b;c[7]=a[7]*b;c[8]=a[8]*b;return c};d.multiplyScalarAndAdd=function(c,a,b,e){c[0]=a[0]+b[0]*e;c[1]=a[1]+b[1]*e;c[2]=a[2]+b[2]*e;c[3]=a[3]+b[3]*e;c[4]=a[4]+b[4]*e;c[5]=a[5]+b[5]*e;c[6]=a[6]+b[6]*e;c[7]=a[7]+b[7]*e;c[8]=a[8]+b[8]*e;return c};d.exactEquals=function(c,a){return c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]&&c[3]===a[3]&&
c[4]===a[4]&&c[5]===a[5]&&c[6]===a[6]&&c[7]===a[7]&&c[8]===a[8]};d.equals=function(c,a){var b=c[0],e=c[1],d=c[2],f=c[3],n=c[4],k=c[5],p=c[6],m=c[7],t=c[8],q=a[0],h=a[1],x=a[2],w=a[3],z=a[4],C=a[5],u=c[6],y=a[7],B=a[8];return Math.abs(b-q)<=g.EPSILON*Math.max(1,Math.abs(b),Math.abs(q))&&Math.abs(e-h)<=g.EPSILON*Math.max(1,Math.abs(e),Math.abs(h))&&Math.abs(d-x)<=g.EPSILON*Math.max(1,Math.abs(d),Math.abs(x))&&Math.abs(f-w)<=g.EPSILON*Math.max(1,Math.abs(f),Math.abs(w))&&Math.abs(n-z)<=g.EPSILON*Math.max(1,
Math.abs(n),Math.abs(z))&&Math.abs(k-C)<=g.EPSILON*Math.max(1,Math.abs(k),Math.abs(C))&&Math.abs(p-u)<=g.EPSILON*Math.max(1,Math.abs(p),Math.abs(u))&&Math.abs(m-y)<=g.EPSILON*Math.max(1,Math.abs(m),Math.abs(y))&&Math.abs(t-B)<=g.EPSILON*Math.max(1,Math.abs(t),Math.abs(B))};h.exports=d},function(h,d,f){var g=f(41),c={scalar:{},SIMD:{},create:function(){var a=new g.ARRAY_TYPE(16);a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a},
clone:function(a){var b=new g.ARRAY_TYPE(16);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a},fromValues:function(a,b,e,c,d,f,k,p,m,t,q,h,x,w,z,C){var u=new g.ARRAY_TYPE(16);
u[0]=a;u[1]=b;u[2]=e;u[3]=c;u[4]=d;u[5]=f;u[6]=k;u[7]=p;u[8]=m;u[9]=t;u[10]=q;u[11]=h;u[12]=x;u[13]=w;u[14]=z;u[15]=C;return u},set:function(a,b,e,c,d,f,k,p,m,g,q,h,x,w,z,C,u){a[0]=b;a[1]=e;a[2]=c;a[3]=d;a[4]=f;a[5]=k;a[6]=p;a[7]=m;a[8]=g;a[9]=q;a[10]=h;a[11]=x;a[12]=w;a[13]=z;a[14]=C;a[15]=u;return a},identity:function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a}};c.scalar.transpose=function(a,b){if(a===b){var e=
b[1],c=b[2],d=b[3],f=b[6],k=b[7],p=b[11];a[1]=b[4];a[2]=b[8];a[3]=b[12];a[4]=e;a[6]=b[9];a[7]=b[13];a[8]=c;a[9]=f;a[11]=b[14];a[12]=d;a[13]=k;a[14]=p}else a[0]=b[0],a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=b[1],a[5]=b[5],a[6]=b[9],a[7]=b[13],a[8]=b[2],a[9]=b[6],a[10]=b[10],a[11]=b[14],a[12]=b[3],a[13]=b[7],a[14]=b[11],a[15]=b[15];return a};c.SIMD.transpose=function(a,b){var e,c,d,f,k,p,m;e=SIMD.Float32x4.load(b,0);c=SIMD.Float32x4.load(b,4);d=SIMD.Float32x4.load(b,8);f=SIMD.Float32x4.load(b,12);k=SIMD.Float32x4.shuffle(e,
c,0,1,4,5);p=SIMD.Float32x4.shuffle(d,f,0,1,4,5);m=SIMD.Float32x4.shuffle(k,p,0,2,4,6);k=SIMD.Float32x4.shuffle(k,p,1,3,5,7);SIMD.Float32x4.store(a,0,m);SIMD.Float32x4.store(a,4,k);k=SIMD.Float32x4.shuffle(e,c,2,3,6,7);p=SIMD.Float32x4.shuffle(d,f,2,3,6,7);e=SIMD.Float32x4.shuffle(k,p,0,2,4,6);c=SIMD.Float32x4.shuffle(k,p,1,3,5,7);SIMD.Float32x4.store(a,8,e);SIMD.Float32x4.store(a,12,c);return a};c.transpose=g.USE_SIMD?c.SIMD.transpose:c.scalar.transpose;c.scalar.invert=function(a,b){var e=b[0],c=
b[1],d=b[2],f=b[3],k=b[4],p=b[5],m=b[6],g=b[7],q=b[8],h=b[9],x=b[10],w=b[11],z=b[12],C=b[13],u=b[14],y=b[15],B=e*p-c*k,A=e*m-d*k,D=e*g-f*k,E=c*m-d*p,H=c*g-f*p,G=d*g-f*m,P=q*C-h*z,R=q*u-x*z,W=q*y-w*z,Q=h*u-x*C,T=h*y-w*C,X=x*y-w*u,N=B*X-A*T+D*Q+E*W-H*R+G*P;if(!N)return null;N=1/N;a[0]=(p*X-m*T+g*Q)*N;a[1]=(d*T-c*X-f*Q)*N;a[2]=(C*G-u*H+y*E)*N;a[3]=(x*H-h*G-w*E)*N;a[4]=(m*W-k*X-g*R)*N;a[5]=(e*X-d*W+f*R)*N;a[6]=(u*D-z*G-y*A)*N;a[7]=(q*G-x*D+w*A)*N;a[8]=(k*T-p*W+g*P)*N;a[9]=(c*W-e*T-f*P)*N;a[10]=(z*H-C*
D+y*B)*N;a[11]=(h*D-q*H-w*B)*N;a[12]=(p*R-k*Q-m*P)*N;a[13]=(e*Q-c*R+d*P)*N;a[14]=(C*A-z*E-u*B)*N;a[15]=(q*E-h*A+x*B)*N;return a};c.SIMD.invert=function(a,b){var e,c,d,f,k,p,m,g,q;p=SIMD.Float32x4.load(b,0);m=SIMD.Float32x4.load(b,4);g=SIMD.Float32x4.load(b,8);q=SIMD.Float32x4.load(b,12);k=SIMD.Float32x4.shuffle(p,m,0,1,4,5);c=SIMD.Float32x4.shuffle(g,q,0,1,4,5);e=SIMD.Float32x4.shuffle(k,c,0,2,4,6);c=SIMD.Float32x4.shuffle(c,k,1,3,5,7);k=SIMD.Float32x4.shuffle(p,m,2,3,6,7);f=SIMD.Float32x4.shuffle(g,
q,2,3,6,7);d=SIMD.Float32x4.shuffle(k,f,0,2,4,6);f=SIMD.Float32x4.shuffle(f,k,1,3,5,7);k=SIMD.Float32x4.mul(d,f);k=SIMD.Float32x4.swizzle(k,1,0,3,2);p=SIMD.Float32x4.mul(c,k);m=SIMD.Float32x4.mul(e,k);k=SIMD.Float32x4.swizzle(k,2,3,0,1);p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,k),p);m=SIMD.Float32x4.sub(SIMD.Float32x4.mul(e,k),m);m=SIMD.Float32x4.swizzle(m,2,3,0,1);k=SIMD.Float32x4.mul(c,d);k=SIMD.Float32x4.swizzle(k,1,0,3,2);p=SIMD.Float32x4.add(SIMD.Float32x4.mul(f,k),p);q=SIMD.Float32x4.mul(e,
k);k=SIMD.Float32x4.swizzle(k,2,3,0,1);p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(f,k));q=SIMD.Float32x4.sub(SIMD.Float32x4.mul(e,k),q);q=SIMD.Float32x4.swizzle(q,2,3,0,1);k=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(c,2,3,0,1),f);k=SIMD.Float32x4.swizzle(k,1,0,3,2);d=SIMD.Float32x4.swizzle(d,2,3,0,1);p=SIMD.Float32x4.add(SIMD.Float32x4.mul(d,k),p);g=SIMD.Float32x4.mul(e,k);k=SIMD.Float32x4.swizzle(k,2,3,0,1);p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(d,k));g=SIMD.Float32x4.sub(SIMD.Float32x4.mul(e,
k),g);g=SIMD.Float32x4.swizzle(g,2,3,0,1);k=SIMD.Float32x4.mul(e,c);k=SIMD.Float32x4.swizzle(k,1,0,3,2);g=SIMD.Float32x4.add(SIMD.Float32x4.mul(f,k),g);q=SIMD.Float32x4.sub(SIMD.Float32x4.mul(d,k),q);k=SIMD.Float32x4.swizzle(k,2,3,0,1);g=SIMD.Float32x4.sub(SIMD.Float32x4.mul(f,k),g);q=SIMD.Float32x4.sub(q,SIMD.Float32x4.mul(d,k));k=SIMD.Float32x4.mul(e,f);k=SIMD.Float32x4.swizzle(k,1,0,3,2);m=SIMD.Float32x4.sub(m,SIMD.Float32x4.mul(d,k));g=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,k),g);k=SIMD.Float32x4.swizzle(k,
2,3,0,1);m=SIMD.Float32x4.add(SIMD.Float32x4.mul(d,k),m);g=SIMD.Float32x4.sub(g,SIMD.Float32x4.mul(c,k));k=SIMD.Float32x4.mul(e,d);k=SIMD.Float32x4.swizzle(k,1,0,3,2);m=SIMD.Float32x4.add(SIMD.Float32x4.mul(f,k),m);q=SIMD.Float32x4.sub(q,SIMD.Float32x4.mul(c,k));k=SIMD.Float32x4.swizzle(k,2,3,0,1);m=SIMD.Float32x4.sub(m,SIMD.Float32x4.mul(f,k));q=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,k),q);e=SIMD.Float32x4.mul(e,p);e=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(e,2,3,0,1),e);e=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(e,
1,0,3,2),e);k=SIMD.Float32x4.reciprocalApproximation(e);e=SIMD.Float32x4.sub(SIMD.Float32x4.add(k,k),SIMD.Float32x4.mul(e,SIMD.Float32x4.mul(k,k)));e=SIMD.Float32x4.swizzle(e,0,0,0,0);if(!e)return null;SIMD.Float32x4.store(a,0,SIMD.Float32x4.mul(e,p));SIMD.Float32x4.store(a,4,SIMD.Float32x4.mul(e,m));SIMD.Float32x4.store(a,8,SIMD.Float32x4.mul(e,g));SIMD.Float32x4.store(a,12,SIMD.Float32x4.mul(e,q));return a};c.invert=g.USE_SIMD?c.SIMD.invert:c.scalar.invert;c.scalar.adjoint=function(a,b){var e=b[0],
c=b[1],d=b[2],f=b[3],k=b[4],p=b[5],m=b[6],g=b[7],q=b[8],h=b[9],x=b[10],w=b[11],z=b[12],C=b[13],u=b[14],y=b[15];a[0]=p*(x*y-w*u)-h*(m*y-g*u)+C*(m*w-g*x);a[1]=-(c*(x*y-w*u)-h*(d*y-f*u)+C*(d*w-f*x));a[2]=c*(m*y-g*u)-p*(d*y-f*u)+C*(d*g-f*m);a[3]=-(c*(m*w-g*x)-p*(d*w-f*x)+h*(d*g-f*m));a[4]=-(k*(x*y-w*u)-q*(m*y-g*u)+z*(m*w-g*x));a[5]=e*(x*y-w*u)-q*(d*y-f*u)+z*(d*w-f*x);a[6]=-(e*(m*y-g*u)-k*(d*y-f*u)+z*(d*g-f*m));a[7]=e*(m*w-g*x)-k*(d*w-f*x)+q*(d*g-f*m);a[8]=k*(h*y-w*C)-q*(p*y-g*C)+z*(p*w-g*h);a[9]=-(e*
(h*y-w*C)-q*(c*y-f*C)+z*(c*w-f*h));a[10]=e*(p*y-g*C)-k*(c*y-f*C)+z*(c*g-f*p);a[11]=-(e*(p*w-g*h)-k*(c*w-f*h)+q*(c*g-f*p));a[12]=-(k*(h*u-x*C)-q*(p*u-m*C)+z*(p*x-m*h));a[13]=e*(h*u-x*C)-q*(c*u-d*C)+z*(c*x-d*h);a[14]=-(e*(p*u-m*C)-k*(c*u-d*C)+z*(c*m-d*p));a[15]=e*(p*x-m*h)-k*(c*x-d*h)+q*(c*m-d*p);return a};c.SIMD.adjoint=function(a,b){var e,c,d,f,k,p,m,g,q;e=SIMD.Float32x4.load(b,0);c=SIMD.Float32x4.load(b,4);d=SIMD.Float32x4.load(b,8);f=SIMD.Float32x4.load(b,12);m=SIMD.Float32x4.shuffle(e,c,0,1,4,
5);p=SIMD.Float32x4.shuffle(d,f,0,1,4,5);k=SIMD.Float32x4.shuffle(m,p,0,2,4,6);p=SIMD.Float32x4.shuffle(p,m,1,3,5,7);m=SIMD.Float32x4.shuffle(e,c,2,3,6,7);c=SIMD.Float32x4.shuffle(d,f,2,3,6,7);e=SIMD.Float32x4.shuffle(m,c,0,2,4,6);c=SIMD.Float32x4.shuffle(c,m,1,3,5,7);m=SIMD.Float32x4.mul(e,c);m=SIMD.Float32x4.swizzle(m,1,0,3,2);d=SIMD.Float32x4.mul(p,m);f=SIMD.Float32x4.mul(k,m);m=SIMD.Float32x4.swizzle(m,2,3,0,1);d=SIMD.Float32x4.sub(SIMD.Float32x4.mul(p,m),d);f=SIMD.Float32x4.sub(SIMD.Float32x4.mul(k,
m),f);f=SIMD.Float32x4.swizzle(f,2,3,0,1);m=SIMD.Float32x4.mul(p,e);m=SIMD.Float32x4.swizzle(m,1,0,3,2);d=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,m),d);q=SIMD.Float32x4.mul(k,m);m=SIMD.Float32x4.swizzle(m,2,3,0,1);d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(c,m));q=SIMD.Float32x4.sub(SIMD.Float32x4.mul(k,m),q);q=SIMD.Float32x4.swizzle(q,2,3,0,1);m=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(p,2,3,0,1),c);m=SIMD.Float32x4.swizzle(m,1,0,3,2);e=SIMD.Float32x4.swizzle(e,2,3,0,1);d=SIMD.Float32x4.add(SIMD.Float32x4.mul(e,
m),d);g=SIMD.Float32x4.mul(k,m);m=SIMD.Float32x4.swizzle(m,2,3,0,1);d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(e,m));g=SIMD.Float32x4.sub(SIMD.Float32x4.mul(k,m),g);g=SIMD.Float32x4.swizzle(g,2,3,0,1);m=SIMD.Float32x4.mul(k,p);m=SIMD.Float32x4.swizzle(m,1,0,3,2);g=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,m),g);q=SIMD.Float32x4.sub(SIMD.Float32x4.mul(e,m),q);m=SIMD.Float32x4.swizzle(m,2,3,0,1);g=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,m),g);q=SIMD.Float32x4.sub(q,SIMD.Float32x4.mul(e,m));m=SIMD.Float32x4.mul(k,
c);m=SIMD.Float32x4.swizzle(m,1,0,3,2);f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(e,m));g=SIMD.Float32x4.add(SIMD.Float32x4.mul(p,m),g);m=SIMD.Float32x4.swizzle(m,2,3,0,1);f=SIMD.Float32x4.add(SIMD.Float32x4.mul(e,m),f);g=SIMD.Float32x4.sub(g,SIMD.Float32x4.mul(p,m));m=SIMD.Float32x4.mul(k,e);m=SIMD.Float32x4.swizzle(m,1,0,3,2);f=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,m),f);q=SIMD.Float32x4.sub(q,SIMD.Float32x4.mul(p,m));m=SIMD.Float32x4.swizzle(m,2,3,0,1);f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(c,
m));q=SIMD.Float32x4.add(SIMD.Float32x4.mul(p,m),q);SIMD.Float32x4.store(a,0,d);SIMD.Float32x4.store(a,4,f);SIMD.Float32x4.store(a,8,g);SIMD.Float32x4.store(a,12,q);return a};c.adjoint=g.USE_SIMD?c.SIMD.adjoint:c.scalar.adjoint;c.determinant=function(a){var b=a[0],e=a[1],c=a[2],d=a[3],f=a[4],k=a[5],p=a[6],m=a[7],g=a[8],q=a[9],h=a[10],x=a[11],w=a[12],z=a[13],C=a[14];a=a[15];return(b*k-e*f)*(h*a-x*C)-(b*p-c*f)*(q*a-x*z)+(b*m-d*f)*(q*C-h*z)+(e*p-c*k)*(g*a-x*w)-(e*m-d*k)*(g*C-h*w)+(c*m-d*p)*(g*z-q*w)};
c.SIMD.multiply=function(a,b,e){var c=SIMD.Float32x4.load(b,0),d=SIMD.Float32x4.load(b,4),f=SIMD.Float32x4.load(b,8);b=SIMD.Float32x4.load(b,12);var k=SIMD.Float32x4.load(e,0),k=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,0,0,0,0),c),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,1,1,1,1),d),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,2,2,2,2),f),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,3,3,3,3),b))));SIMD.Float32x4.store(a,0,k);k=SIMD.Float32x4.load(e,
4);k=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,0,0,0,0),c),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,1,1,1,1),d),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,2,2,2,2),f),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,3,3,3,3),b))));SIMD.Float32x4.store(a,4,k);k=SIMD.Float32x4.load(e,8);k=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,0,0,0,0),c),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,1,1,1,1),d),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,
2,2,2,2),f),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(k,3,3,3,3),b))));SIMD.Float32x4.store(a,8,k);e=SIMD.Float32x4.load(e,12);c=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(e,0,0,0,0),c),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(e,1,1,1,1),d),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(e,2,2,2,2),f),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(e,3,3,3,3),b))));SIMD.Float32x4.store(a,12,c);return a};c.scalar.multiply=function(a,b,e){var c=b[0],d=b[1],
f=b[2],k=b[3],p=b[4],m=b[5],g=b[6],q=b[7],h=b[8],x=b[9],w=b[10],z=b[11],C=b[12],u=b[13],y=b[14];b=b[15];var B=e[0],A=e[1],D=e[2],E=e[3];a[0]=B*c+A*p+D*h+E*C;a[1]=B*d+A*m+D*x+E*u;a[2]=B*f+A*g+D*w+E*y;a[3]=B*k+A*q+D*z+E*b;B=e[4];A=e[5];D=e[6];E=e[7];a[4]=B*c+A*p+D*h+E*C;a[5]=B*d+A*m+D*x+E*u;a[6]=B*f+A*g+D*w+E*y;a[7]=B*k+A*q+D*z+E*b;B=e[8];A=e[9];D=e[10];E=e[11];a[8]=B*c+A*p+D*h+E*C;a[9]=B*d+A*m+D*x+E*u;a[10]=B*f+A*g+D*w+E*y;a[11]=B*k+A*q+D*z+E*b;B=e[12];A=e[13];D=e[14];E=e[15];a[12]=B*c+A*p+D*h+E*C;
a[13]=B*d+A*m+D*x+E*u;a[14]=B*f+A*g+D*w+E*y;a[15]=B*k+A*q+D*z+E*b;return a};c.multiply=g.USE_SIMD?c.SIMD.multiply:c.scalar.multiply;c.mul=c.multiply;c.scalar.translate=function(a,b,e){var c=e[0],d=e[1];e=e[2];var f,k,p,m,g,q,h,x,w,z,C,u;b===a?(a[12]=b[0]*c+b[4]*d+b[8]*e+b[12],a[13]=b[1]*c+b[5]*d+b[9]*e+b[13],a[14]=b[2]*c+b[6]*d+b[10]*e+b[14],a[15]=b[3]*c+b[7]*d+b[11]*e+b[15]):(f=b[0],k=b[1],p=b[2],m=b[3],g=b[4],q=b[5],h=b[6],x=b[7],w=b[8],z=b[9],C=b[10],u=b[11],a[0]=f,a[1]=k,a[2]=p,a[3]=m,a[4]=g,
a[5]=q,a[6]=h,a[7]=x,a[8]=w,a[9]=z,a[10]=C,a[11]=u,a[12]=f*c+g*d+w*e+b[12],a[13]=k*c+q*d+z*e+b[13],a[14]=p*c+h*d+C*e+b[14],a[15]=m*c+x*d+u*e+b[15]);return a};c.SIMD.translate=function(a,b,e){var c=SIMD.Float32x4.load(b,0),d=SIMD.Float32x4.load(b,4),f=SIMD.Float32x4.load(b,8),k=SIMD.Float32x4.load(b,12);e=SIMD.Float32x4(e[0],e[1],e[2],0);b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11]);c=SIMD.Float32x4.mul(c,SIMD.Float32x4.swizzle(e,
0,0,0,0));d=SIMD.Float32x4.mul(d,SIMD.Float32x4.swizzle(e,1,1,1,1));f=SIMD.Float32x4.mul(f,SIMD.Float32x4.swizzle(e,2,2,2,2));b=SIMD.Float32x4.add(c,SIMD.Float32x4.add(d,SIMD.Float32x4.add(f,k)));SIMD.Float32x4.store(a,12,b);return a};c.translate=g.USE_SIMD?c.SIMD.translate:c.scalar.translate;c.scalar.scale=function(a,b,e){var c=e[0],d=e[1];e=e[2];a[0]=b[0]*c;a[1]=b[1]*c;a[2]=b[2]*c;a[3]=b[3]*c;a[4]=b[4]*d;a[5]=b[5]*d;a[6]=b[6]*d;a[7]=b[7]*d;a[8]=b[8]*e;a[9]=b[9]*e;a[10]=b[10]*e;a[11]=b[11]*e;a[12]=
b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a};c.SIMD.scale=function(a,b,e){var c;e=SIMD.Float32x4(e[0],e[1],e[2],0);c=SIMD.Float32x4.load(b,0);SIMD.Float32x4.store(a,0,SIMD.Float32x4.mul(c,SIMD.Float32x4.swizzle(e,0,0,0,0)));c=SIMD.Float32x4.load(b,4);SIMD.Float32x4.store(a,4,SIMD.Float32x4.mul(c,SIMD.Float32x4.swizzle(e,1,1,1,1)));c=SIMD.Float32x4.load(b,8);SIMD.Float32x4.store(a,8,SIMD.Float32x4.mul(c,SIMD.Float32x4.swizzle(e,2,2,2,2)));a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a};
c.scale=g.USE_SIMD?c.SIMD.scale:c.scalar.scale;c.rotate=function(a,b,e,c){var d=c[0],f=c[1];c=c[2];var k=Math.sqrt(d*d+f*f+c*c),p,m,h,q,v,x,w,z,C,u,y,B,A,D,E,H,G,P,R,W;if(Math.abs(k)<g.EPSILON)return null;k=1/k;d*=k;f*=k;c*=k;p=Math.sin(e);m=Math.cos(e);h=1-m;e=b[0];k=b[1];q=b[2];v=b[3];x=b[4];w=b[5];z=b[6];C=b[7];u=b[8];y=b[9];B=b[10];A=b[11];D=d*d*h+m;E=f*d*h+c*p;H=c*d*h-f*p;G=d*f*h-c*p;P=f*f*h+m;R=c*f*h+d*p;W=d*c*h+f*p;d=f*c*h-d*p;f=c*c*h+m;a[0]=e*D+x*E+u*H;a[1]=k*D+w*E+y*H;a[2]=q*D+z*E+B*H;a[3]=
v*D+C*E+A*H;a[4]=e*G+x*P+u*R;a[5]=k*G+w*P+y*R;a[6]=q*G+z*P+B*R;a[7]=v*G+C*P+A*R;a[8]=e*W+x*d+u*f;a[9]=k*W+w*d+y*f;a[10]=q*W+z*d+B*f;a[11]=v*W+C*d+A*f;b!==a&&(a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);return a};c.scalar.rotateX=function(a,b,e){var c=Math.sin(e);e=Math.cos(e);var d=b[4],f=b[5],k=b[6],p=b[7],m=b[8],g=b[9],q=b[10],h=b[11];b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[4]=d*e+m*c;a[5]=f*e+g*c;a[6]=k*e+q*c;a[7]=p*e+h*c;a[8]=m*e-
d*c;a[9]=g*e-f*c;a[10]=q*e-k*c;a[11]=h*e-p*c;return a};c.SIMD.rotateX=function(a,b,e){var c=SIMD.Float32x4.splat(Math.sin(e));e=SIMD.Float32x4.splat(Math.cos(e));b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);var d=SIMD.Float32x4.load(b,4);b=SIMD.Float32x4.load(b,8);SIMD.Float32x4.store(a,4,SIMD.Float32x4.add(SIMD.Float32x4.mul(d,e),SIMD.Float32x4.mul(b,c)));SIMD.Float32x4.store(a,8,SIMD.Float32x4.sub(SIMD.Float32x4.mul(b,e),SIMD.Float32x4.mul(d,c)));
return a};c.rotateX=g.USE_SIMD?c.SIMD.rotateX:c.scalar.rotateX;c.scalar.rotateY=function(a,b,e){var c=Math.sin(e);e=Math.cos(e);var d=b[0],f=b[1],k=b[2],p=b[3],m=b[8],g=b[9],q=b[10],h=b[11];b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[0]=d*e-m*c;a[1]=f*e-g*c;a[2]=k*e-q*c;a[3]=p*e-h*c;a[8]=d*c+m*e;a[9]=f*c+g*e;a[10]=k*c+q*e;a[11]=p*c+h*e;return a};c.SIMD.rotateY=function(a,b,e){var c=SIMD.Float32x4.splat(Math.sin(e));e=SIMD.Float32x4.splat(Math.cos(e));
b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);var d=SIMD.Float32x4.load(b,0);b=SIMD.Float32x4.load(b,8);SIMD.Float32x4.store(a,0,SIMD.Float32x4.sub(SIMD.Float32x4.mul(d,e),SIMD.Float32x4.mul(b,c)));SIMD.Float32x4.store(a,8,SIMD.Float32x4.add(SIMD.Float32x4.mul(d,c),SIMD.Float32x4.mul(b,e)));return a};c.rotateY=g.USE_SIMD?c.SIMD.rotateY:c.scalar.rotateY;c.scalar.rotateZ=function(a,b,e){var c=Math.sin(e);e=Math.cos(e);var d=b[0],f=b[1],k=b[2],p=b[3],
m=b[4],g=b[5],q=b[6],h=b[7];b!==a&&(a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[0]=d*e+m*c;a[1]=f*e+g*c;a[2]=k*e+q*c;a[3]=p*e+h*c;a[4]=m*e-d*c;a[5]=g*e-f*c;a[6]=q*e-k*c;a[7]=h*e-p*c;return a};c.SIMD.rotateZ=function(a,b,e){var c=SIMD.Float32x4.splat(Math.sin(e));e=SIMD.Float32x4.splat(Math.cos(e));b!==a&&(a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);var d=SIMD.Float32x4.load(b,0);b=SIMD.Float32x4.load(b,
4);SIMD.Float32x4.store(a,0,SIMD.Float32x4.add(SIMD.Float32x4.mul(d,e),SIMD.Float32x4.mul(b,c)));SIMD.Float32x4.store(a,4,SIMD.Float32x4.sub(SIMD.Float32x4.mul(b,e),SIMD.Float32x4.mul(d,c)));return a};c.rotateZ=g.USE_SIMD?c.SIMD.rotateZ:c.scalar.rotateZ;c.fromTranslation=function(a,b){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=b[0];a[13]=b[1];a[14]=b[2];a[15]=1;return a};c.fromScaling=function(a,b){a[0]=b[0];a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=b[1];a[6]=
0;a[7]=0;a[8]=0;a[9]=0;a[10]=b[2];a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};c.fromRotation=function(a,b,e){var c=e[0],d=e[1];e=e[2];var f=Math.sqrt(c*c+d*d+e*e),k;if(Math.abs(f)<g.EPSILON)return null;f=1/f;c*=f;d*=f;e*=f;f=Math.sin(b);b=Math.cos(b);k=1-b;a[0]=c*c*k+b;a[1]=d*c*k+e*f;a[2]=e*c*k-d*f;a[3]=0;a[4]=c*d*k-e*f;a[5]=d*d*k+b;a[6]=e*d*k+c*f;a[7]=0;a[8]=c*e*k+d*f;a[9]=d*e*k-c*f;a[10]=e*e*k+b;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};c.fromXRotation=function(a,b){var e=Math.sin(b),
c=Math.cos(b);a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=c;a[6]=e;a[7]=0;a[8]=0;a[9]=-e;a[10]=c;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};c.fromYRotation=function(a,b){var e=Math.sin(b),c=Math.cos(b);a[0]=c;a[1]=0;a[2]=-e;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=e;a[9]=0;a[10]=c;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};c.fromZRotation=function(a,b){var e=Math.sin(b),c=Math.cos(b);a[0]=c;a[1]=e;a[2]=0;a[3]=0;a[4]=-e;a[5]=c;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=
0;a[15]=1;return a};c.fromRotationTranslation=function(a,b,e){var c=b[0],d=b[1],f=b[2],k=b[3],p=c+c,m=d+d,g=f+f;b=c*p;var h=c*m,c=c*g,v=d*m,d=d*g,f=f*g,p=k*p,m=k*m,k=k*g;a[0]=1-(v+f);a[1]=h+k;a[2]=c-m;a[3]=0;a[4]=h-k;a[5]=1-(b+f);a[6]=d+p;a[7]=0;a[8]=c+m;a[9]=d-p;a[10]=1-(b+v);a[11]=0;a[12]=e[0];a[13]=e[1];a[14]=e[2];a[15]=1;return a};c.getTranslation=function(a,b){a[0]=b[12];a[1]=b[13];a[2]=b[14];return a};c.getRotation=function(a,b){var e=b[0]+b[5]+b[10],c=0;0<e?(c=2*Math.sqrt(e+1),a[3]=.25*c,a[0]=
(b[6]-b[9])/c,a[1]=(b[8]-b[2])/c,a[2]=(b[1]-b[4])/c):b[0]>b[5]&b[0]>b[10]?(c=2*Math.sqrt(1+b[0]-b[5]-b[10]),a[3]=(b[6]-b[9])/c,a[0]=.25*c,a[1]=(b[1]+b[4])/c,a[2]=(b[8]+b[2])/c):b[5]>b[10]?(c=2*Math.sqrt(1+b[5]-b[0]-b[10]),a[3]=(b[8]-b[2])/c,a[0]=(b[1]+b[4])/c,a[1]=.25*c,a[2]=(b[6]+b[9])/c):(c=2*Math.sqrt(1+b[10]-b[0]-b[5]),a[3]=(b[1]-b[4])/c,a[0]=(b[8]+b[2])/c,a[1]=(b[6]+b[9])/c,a[2]=.25*c);return a};c.fromRotationTranslationScale=function(a,b,c,d){var f=b[0],n=b[1],k=b[2],g=b[3],m=f+f,h=n+n,q=k+
k;b=f*m;var v=f*h,f=f*q,x=n*h,n=n*q,k=k*q,m=g*m,h=g*h,g=g*q,q=d[0],w=d[1];d=d[2];a[0]=(1-(x+k))*q;a[1]=(v+g)*q;a[2]=(f-h)*q;a[3]=0;a[4]=(v-g)*w;a[5]=(1-(b+k))*w;a[6]=(n+m)*w;a[7]=0;a[8]=(f+h)*d;a[9]=(n-m)*d;a[10]=(1-(b+x))*d;a[11]=0;a[12]=c[0];a[13]=c[1];a[14]=c[2];a[15]=1;return a};c.fromRotationTranslationScaleOrigin=function(a,b,c,d,f){var n=b[0],k=b[1],g=b[2],m=b[3],h=n+n,q=k+k,v=g+g;b=n*h;var x=n*q,n=n*v,w=k*q,k=k*v,g=g*v,h=m*h,q=m*q,m=m*v,v=d[0],z=d[1];d=d[2];var C=f[0],u=f[1];f=f[2];a[0]=(1-
(w+g))*v;a[1]=(x+m)*v;a[2]=(n-q)*v;a[3]=0;a[4]=(x-m)*z;a[5]=(1-(b+g))*z;a[6]=(k+h)*z;a[7]=0;a[8]=(n+q)*d;a[9]=(k-h)*d;a[10]=(1-(b+w))*d;a[11]=0;a[12]=c[0]+C-(a[0]*C+a[4]*u+a[8]*f);a[13]=c[1]+u-(a[1]*C+a[5]*u+a[9]*f);a[14]=c[2]+f-(a[2]*C+a[6]*u+a[10]*f);a[15]=1;return a};c.fromQuat=function(a,b){var c=b[0],d=b[1],f=b[2],n=b[3],k=c+c,g=d+d,m=f+f,c=c*k,h=d*k,d=d*g,q=f*k,v=f*g,f=f*m,k=n*k,g=n*g,n=n*m;a[0]=1-d-f;a[1]=h+n;a[2]=q-g;a[3]=0;a[4]=h-n;a[5]=1-c-f;a[6]=v+k;a[7]=0;a[8]=q+g;a[9]=v-k;a[10]=1-c-d;
a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};c.frustum=function(a,b,c,d,f,n,k){var g=1/(c-b),m=1/(f-d),h=1/(n-k);a[0]=2*n*g;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=2*n*m;a[6]=0;a[7]=0;a[8]=(c+b)*g;a[9]=(f+d)*m;a[10]=(k+n)*h;a[11]=-1;a[12]=0;a[13]=0;a[14]=k*n*2*h;a[15]=0;return a};c.perspective=function(a,b,c,d,f){b=1/Math.tan(b/2);var n=1/(d-f);a[0]=b/c;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=b;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=(f+d)*n;a[11]=-1;a[12]=0;a[13]=0;a[14]=2*f*d*n;a[15]=0;return a};c.perspectiveFromFieldOfView=
function(a,b,c,d){var f=Math.tan(b.upDegrees*Math.PI/180),n=Math.tan(b.downDegrees*Math.PI/180),k=Math.tan(b.leftDegrees*Math.PI/180);b=Math.tan(b.rightDegrees*Math.PI/180);var g=2/(k+b),m=2/(f+n);a[0]=g;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=m;a[6]=0;a[7]=0;a[8]=-((k-b)*g*.5);a[9]=(f-n)*m*.5;a[10]=d/(c-d);a[11]=-1;a[12]=0;a[13]=0;a[14]=d*c/(c-d);a[15]=0;return a};c.ortho=function(a,b,c,d,f,n,k){var g=1/(b-c),m=1/(d-f),h=1/(n-k);a[0]=-2*g;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=-2*m;a[6]=0;a[7]=0;a[8]=0;a[9]=
0;a[10]=2*h;a[11]=0;a[12]=(b+c)*g;a[13]=(f+d)*m;a[14]=(k+n)*h;a[15]=1;return a};c.lookAt=function(a,b,e,d){var f,n,k,p,m,h,q,v,x=b[0],w=b[1];b=b[2];k=d[0];p=d[1];n=d[2];q=e[0];d=e[1];f=e[2];if(Math.abs(x-q)<g.EPSILON&&Math.abs(w-d)<g.EPSILON&&Math.abs(b-f)<g.EPSILON)return c.identity(a);e=x-q;d=w-d;q=b-f;v=1/Math.sqrt(e*e+d*d+q*q);e*=v;d*=v;q*=v;f=p*q-n*d;n=n*e-k*q;k=k*d-p*e;(v=Math.sqrt(f*f+n*n+k*k))?(v=1/v,f*=v,n*=v,k*=v):k=n=f=0;p=d*k-q*n;m=q*f-e*k;h=e*n-d*f;(v=Math.sqrt(p*p+m*m+h*h))?(v=1/v,p*=
v,m*=v,h*=v):h=m=p=0;a[0]=f;a[1]=p;a[2]=e;a[3]=0;a[4]=n;a[5]=m;a[6]=d;a[7]=0;a[8]=k;a[9]=h;a[10]=q;a[11]=0;a[12]=-(f*x+n*w+k*b);a[13]=-(p*x+m*w+h*b);a[14]=-(e*x+d*w+q*b);a[15]=1;return a};c.str=function(a){return"mat4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+")"};c.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],
2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2)+Math.pow(a[9],2)+Math.pow(a[10],2)+Math.pow(a[11],2)+Math.pow(a[12],2)+Math.pow(a[13],2)+Math.pow(a[14],2)+Math.pow(a[15],2))};c.add=function(a,b,c){a[0]=b[0]+c[0];a[1]=b[1]+c[1];a[2]=b[2]+c[2];a[3]=b[3]+c[3];a[4]=b[4]+c[4];a[5]=b[5]+c[5];a[6]=b[6]+c[6];a[7]=b[7]+c[7];a[8]=b[8]+c[8];a[9]=b[9]+c[9];a[10]=b[10]+c[10];a[11]=b[11]+c[11];a[12]=b[12]+c[12];a[13]=b[13]+c[13];a[14]=b[14]+c[14];a[15]=b[15]+c[15];return a};c.subtract=function(a,
b,c){a[0]=b[0]-c[0];a[1]=b[1]-c[1];a[2]=b[2]-c[2];a[3]=b[3]-c[3];a[4]=b[4]-c[4];a[5]=b[5]-c[5];a[6]=b[6]-c[6];a[7]=b[7]-c[7];a[8]=b[8]-c[8];a[9]=b[9]-c[9];a[10]=b[10]-c[10];a[11]=b[11]-c[11];a[12]=b[12]-c[12];a[13]=b[13]-c[13];a[14]=b[14]-c[14];a[15]=b[15]-c[15];return a};c.sub=c.subtract;c.multiplyScalar=function(a,b,c){a[0]=b[0]*c;a[1]=b[1]*c;a[2]=b[2]*c;a[3]=b[3]*c;a[4]=b[4]*c;a[5]=b[5]*c;a[6]=b[6]*c;a[7]=b[7]*c;a[8]=b[8]*c;a[9]=b[9]*c;a[10]=b[10]*c;a[11]=b[11]*c;a[12]=b[12]*c;a[13]=b[13]*c;a[14]=
b[14]*c;a[15]=b[15]*c;return a};c.multiplyScalarAndAdd=function(a,b,c,d){a[0]=b[0]+c[0]*d;a[1]=b[1]+c[1]*d;a[2]=b[2]+c[2]*d;a[3]=b[3]+c[3]*d;a[4]=b[4]+c[4]*d;a[5]=b[5]+c[5]*d;a[6]=b[6]+c[6]*d;a[7]=b[7]+c[7]*d;a[8]=b[8]+c[8]*d;a[9]=b[9]+c[9]*d;a[10]=b[10]+c[10]*d;a[11]=b[11]+c[11]*d;a[12]=b[12]+c[12]*d;a[13]=b[13]+c[13]*d;a[14]=b[14]+c[14]*d;a[15]=b[15]+c[15]*d;return a};c.exactEquals=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===
b[7]&&a[8]===b[8]&&a[9]===b[9]&&a[10]===b[10]&&a[11]===b[11]&&a[12]===b[12]&&a[13]===b[13]&&a[14]===b[14]&&a[15]===b[15]};c.equals=function(a,b){var c=a[0],d=a[1],f=a[2],n=a[3],k=a[4],p=a[5],m=a[6],h=a[7],q=a[8],v=a[9],x=a[10],w=a[11],z=a[12],C=a[13],u=a[14],y=a[15],B=b[0],A=b[1],D=b[2],E=b[3],H=b[4],G=b[5],P=b[6],R=b[7],W=b[8],Q=b[9],T=b[10],X=b[11],N=b[12],ja=b[13],ca=b[14],ya=b[15];return Math.abs(c-B)<=g.EPSILON*Math.max(1,Math.abs(c),Math.abs(B))&&Math.abs(d-A)<=g.EPSILON*Math.max(1,Math.abs(d),
Math.abs(A))&&Math.abs(f-D)<=g.EPSILON*Math.max(1,Math.abs(f),Math.abs(D))&&Math.abs(n-E)<=g.EPSILON*Math.max(1,Math.abs(n),Math.abs(E))&&Math.abs(k-H)<=g.EPSILON*Math.max(1,Math.abs(k),Math.abs(H))&&Math.abs(p-G)<=g.EPSILON*Math.max(1,Math.abs(p),Math.abs(G))&&Math.abs(m-P)<=g.EPSILON*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(h-R)<=g.EPSILON*Math.max(1,Math.abs(h),Math.abs(R))&&Math.abs(q-W)<=g.EPSILON*Math.max(1,Math.abs(q),Math.abs(W))&&Math.abs(v-Q)<=g.EPSILON*Math.max(1,Math.abs(v),Math.abs(Q))&&
Math.abs(x-T)<=g.EPSILON*Math.max(1,Math.abs(x),Math.abs(T))&&Math.abs(w-X)<=g.EPSILON*Math.max(1,Math.abs(w),Math.abs(X))&&Math.abs(z-N)<=g.EPSILON*Math.max(1,Math.abs(z),Math.abs(N))&&Math.abs(C-ja)<=g.EPSILON*Math.max(1,Math.abs(C),Math.abs(ja))&&Math.abs(u-ca)<=g.EPSILON*Math.max(1,Math.abs(u),Math.abs(ca))&&Math.abs(y-ya)<=g.EPSILON*Math.max(1,Math.abs(y),Math.abs(ya))};h.exports=c},function(h,d,f){var g=f(41),c=f(44),a=f(47);d=f(48);var b={create:function(){var a=new g.ARRAY_TYPE(4);a[0]=0;
a[1]=0;a[2]=0;a[3]=1;return a}};b.rotationTo=function(){var c=a.create(),d=a.fromValues(1,0,0),f=a.fromValues(0,1,0);return function(n,k,g){var m=a.dot(k,g);if(-.999999>m)return a.cross(c,d,k),1E-6>a.length(c)&&a.cross(c,f,k),a.normalize(c,c),b.setAxisAngle(n,c,Math.PI),n;if(.999999<m)return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n;a.cross(c,k,g);n[0]=c[0];n[1]=c[1];n[2]=c[2];n[3]=1+m;return b.normalize(n,n)}}();b.setAxes=function(){var a=c.create();return function(c,d,f,k){a[0]=f[0];a[3]=f[1];a[6]=f[2];a[1]=
k[0];a[4]=k[1];a[7]=k[2];a[2]=-d[0];a[5]=-d[1];a[8]=-d[2];return b.normalize(c,b.fromMat3(c,a))}}();b.clone=d.clone;b.fromValues=d.fromValues;b.copy=d.copy;b.set=d.set;b.identity=function(a){a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a};b.setAxisAngle=function(a,b,c){c*=.5;var d=Math.sin(c);a[0]=d*b[0];a[1]=d*b[1];a[2]=d*b[2];a[3]=Math.cos(c);return a};b.getAxisAngle=function(a,b){var c=2*Math.acos(b[3]),d=Math.sin(c/2);0!=d?(a[0]=b[0]/d,a[1]=b[1]/d,a[2]=b[2]/d):(a[0]=1,a[1]=0,a[2]=0);return c};b.add=d.add;
b.multiply=function(a,b,c){var d=b[0],f=b[1],g=b[2];b=b[3];var m=c[0],h=c[1],q=c[2];c=c[3];a[0]=d*c+b*m+f*q-g*h;a[1]=f*c+b*h+g*m-d*q;a[2]=g*c+b*q+d*h-f*m;a[3]=b*c-d*m-f*h-g*q;return a};b.mul=b.multiply;b.scale=d.scale;b.rotateX=function(a,b,c){c*=.5;var d=b[0],f=b[1],g=b[2];b=b[3];var m=Math.sin(c);c=Math.cos(c);a[0]=d*c+b*m;a[1]=f*c+g*m;a[2]=g*c-f*m;a[3]=b*c-d*m;return a};b.rotateY=function(a,b,c){c*=.5;var d=b[0],f=b[1],g=b[2];b=b[3];var m=Math.sin(c);c=Math.cos(c);a[0]=d*c-g*m;a[1]=f*c+b*m;a[2]=
g*c+d*m;a[3]=b*c-f*m;return a};b.rotateZ=function(a,b,c){c*=.5;var d=b[0],f=b[1],g=b[2];b=b[3];var m=Math.sin(c);c=Math.cos(c);a[0]=d*c+f*m;a[1]=f*c-d*m;a[2]=g*c+b*m;a[3]=b*c-g*m;return a};b.calculateW=function(a,b){var c=b[0],d=b[1],f=b[2];a[0]=c;a[1]=d;a[2]=f;a[3]=Math.sqrt(Math.abs(1-c*c-d*d-f*f));return a};b.dot=d.dot;b.lerp=d.lerp;b.slerp=function(a,b,c,d){var f=b[0],g=b[1],m=b[2];b=b[3];var h=c[0],q=c[1],v=c[2];c=c[3];var x,w,z;w=f*h+g*q+m*v+b*c;0>w&&(w=-w,h=-h,q=-q,v=-v,c=-c);1E-6<1-w?(x=Math.acos(w),
z=Math.sin(x),w=Math.sin((1-d)*x)/z,d=Math.sin(d*x)/z):w=1-d;a[0]=w*f+d*h;a[1]=w*g+d*q;a[2]=w*m+d*v;a[3]=w*b+d*c;return a};b.sqlerp=function(){var a=b.create(),c=b.create();return function(d,f,k,g,m,h){b.slerp(a,f,m,h);b.slerp(c,k,g,h);b.slerp(d,a,c,2*h*(1-h));return d}}();b.invert=function(a,b){var c=b[0],d=b[1],f=b[2],g=b[3],m=c*c+d*d+f*f+g*g,m=m?1/m:0;a[0]=-c*m;a[1]=-d*m;a[2]=-f*m;a[3]=g*m;return a};b.conjugate=function(a,b){a[0]=-b[0];a[1]=-b[1];a[2]=-b[2];a[3]=b[3];return a};b.length=d.length;
b.len=b.length;b.squaredLength=d.squaredLength;b.sqrLen=b.squaredLength;b.normalize=d.normalize;b.fromMat3=function(a,b){var c=b[0]+b[4]+b[8];if(0<c)c=Math.sqrt(c+1),a[3]=.5*c,c=.5/c,a[0]=(b[5]-b[7])*c,a[1]=(b[6]-b[2])*c,a[2]=(b[1]-b[3])*c;else{var d=0;b[4]>b[0]&&(d=1);b[8]>b[3*d+d]&&(d=2);var f=(d+1)%3,g=(d+2)%3,c=Math.sqrt(b[3*d+d]-b[3*f+f]-b[3*g+g]+1);a[d]=.5*c;c=.5/c;a[3]=(b[3*f+g]-b[3*g+f])*c;a[f]=(b[3*f+d]+b[3*d+f])*c;a[g]=(b[3*g+d]+b[3*d+g])*c}return a};b.str=function(a){return"quat("+a[0]+
", "+a[1]+", "+a[2]+", "+a[3]+")"};b.exactEquals=d.exactEquals;b.equals=d.equals;h.exports=b},function(h,d,f){var g=f(41),c={create:function(){var a=new g.ARRAY_TYPE(3);a[0]=0;a[1]=0;a[2]=0;return a},clone:function(a){var b=new g.ARRAY_TYPE(3);b[0]=a[0];b[1]=a[1];b[2]=a[2];return b},fromValues:function(a,b,c){var d=new g.ARRAY_TYPE(3);d[0]=a;d[1]=b;d[2]=c;return d},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a},set:function(a,b,c,d){a[0]=b;a[1]=c;a[2]=d;return a},add:function(a,b,c){a[0]=
b[0]+c[0];a[1]=b[1]+c[1];a[2]=b[2]+c[2];return a},subtract:function(a,b,c){a[0]=b[0]-c[0];a[1]=b[1]-c[1];a[2]=b[2]-c[2];return a}};c.sub=c.subtract;c.multiply=function(a,b,c){a[0]=b[0]*c[0];a[1]=b[1]*c[1];a[2]=b[2]*c[2];return a};c.mul=c.multiply;c.divide=function(a,b,c){a[0]=b[0]/c[0];a[1]=b[1]/c[1];a[2]=b[2]/c[2];return a};c.div=c.divide;c.ceil=function(a,b){a[0]=Math.ceil(b[0]);a[1]=Math.ceil(b[1]);a[2]=Math.ceil(b[2]);return a};c.floor=function(a,b){a[0]=Math.floor(b[0]);a[1]=Math.floor(b[1]);
a[2]=Math.floor(b[2]);return a};c.min=function(a,b,c){a[0]=Math.min(b[0],c[0]);a[1]=Math.min(b[1],c[1]);a[2]=Math.min(b[2],c[2]);return a};c.max=function(a,b,c){a[0]=Math.max(b[0],c[0]);a[1]=Math.max(b[1],c[1]);a[2]=Math.max(b[2],c[2]);return a};c.round=function(a,b){a[0]=Math.round(b[0]);a[1]=Math.round(b[1]);a[2]=Math.round(b[2]);return a};c.scale=function(a,b,c){a[0]=b[0]*c;a[1]=b[1]*c;a[2]=b[2]*c;return a};c.scaleAndAdd=function(a,b,c,d){a[0]=b[0]+c[0]*d;a[1]=b[1]+c[1]*d;a[2]=b[2]+c[2]*d;return a};
c.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],f=b[2]-a[2];return Math.sqrt(c*c+d*d+f*f)};c.dist=c.distance;c.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],f=b[2]-a[2];return c*c+d*d+f*f};c.sqrDist=c.squaredDistance;c.length=function(a){var b=a[0],c=a[1];a=a[2];return Math.sqrt(b*b+c*c+a*a)};c.len=c.length;c.squaredLength=function(a){var b=a[0],c=a[1];a=a[2];return b*b+c*c+a*a};c.sqrLen=c.squaredLength;c.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];a[2]=-b[2];return a};c.inverse=function(a,
b){a[0]=1/b[0];a[1]=1/b[1];a[2]=1/b[2];return a};c.normalize=function(a,b){var c=b[0],d=b[1],f=b[2],c=c*c+d*d+f*f;0<c&&(c=1/Math.sqrt(c),a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c);return a};c.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]};c.cross=function(a,b,c){var d=b[0],f=b[1];b=b[2];var g=c[0],k=c[1];c=c[2];a[0]=f*c-b*k;a[1]=b*g-d*c;a[2]=d*k-f*g;return a};c.lerp=function(a,b,c,d){var f=b[0],g=b[1];b=b[2];a[0]=f+d*(c[0]-f);a[1]=g+d*(c[1]-g);a[2]=b+d*(c[2]-b);return a};c.hermite=function(a,b,
c,d,f,g){var k=g*g,h=k*(2*g-3)+1,m=k*(g-2)+g,t=k*(g-1);g=k*(3-2*g);a[0]=b[0]*h+c[0]*m+d[0]*t+f[0]*g;a[1]=b[1]*h+c[1]*m+d[1]*t+f[1]*g;a[2]=b[2]*h+c[2]*m+d[2]*t+f[2]*g;return a};c.bezier=function(a,b,c,d,f,g){var k=1-g,h=k*k,m=g*g,t=h*k,h=3*g*h,k=3*m*k;g*=m;a[0]=b[0]*t+c[0]*h+d[0]*k+f[0]*g;a[1]=b[1]*t+c[1]*h+d[1]*k+f[1]*g;a[2]=b[2]*t+c[2]*h+d[2]*k+f[2]*g;return a};c.random=function(a,b){b=b||1;var c=2*g.RANDOM()*Math.PI,d=2*g.RANDOM()-1,f=Math.sqrt(1-d*d)*b;a[0]=Math.cos(c)*f;a[1]=Math.sin(c)*f;a[2]=
d*b;return a};c.transformMat4=function(a,b,c){var d=b[0],f=b[1];b=b[2];var g=c[3]*d+c[7]*f+c[11]*b+c[15],g=g||1;a[0]=(c[0]*d+c[4]*f+c[8]*b+c[12])/g;a[1]=(c[1]*d+c[5]*f+c[9]*b+c[13])/g;a[2]=(c[2]*d+c[6]*f+c[10]*b+c[14])/g;return a};c.transformMat3=function(a,b,c){var d=b[0],f=b[1];b=b[2];a[0]=d*c[0]+f*c[3]+b*c[6];a[1]=d*c[1]+f*c[4]+b*c[7];a[2]=d*c[2]+f*c[5]+b*c[8];return a};c.transformQuat=function(a,b,c){var d=b[0],f=b[1],g=b[2];b=c[0];var k=c[1],h=c[2];c=c[3];var m=c*d+k*g-h*f,t=c*f+h*d-b*g,q=c*
g+b*f-k*d,d=-b*d-k*f-h*g;a[0]=m*c+d*-b+t*-h-q*-k;a[1]=t*c+d*-k+q*-b-m*-h;a[2]=q*c+d*-h+m*-k-t*-b;return a};c.rotateX=function(a,b,c,d){var f=[],g=[];f[0]=b[0]-c[0];f[1]=b[1]-c[1];f[2]=b[2]-c[2];g[0]=f[0];g[1]=f[1]*Math.cos(d)-f[2]*Math.sin(d);g[2]=f[1]*Math.sin(d)+f[2]*Math.cos(d);a[0]=g[0]+c[0];a[1]=g[1]+c[1];a[2]=g[2]+c[2];return a};c.rotateY=function(a,b,c,d){var f=[],g=[];f[0]=b[0]-c[0];f[1]=b[1]-c[1];f[2]=b[2]-c[2];g[0]=f[2]*Math.sin(d)+f[0]*Math.cos(d);g[1]=f[1];g[2]=f[2]*Math.cos(d)-f[0]*Math.sin(d);
a[0]=g[0]+c[0];a[1]=g[1]+c[1];a[2]=g[2]+c[2];return a};c.rotateZ=function(a,b,c,d){var f=[],g=[];f[0]=b[0]-c[0];f[1]=b[1]-c[1];f[2]=b[2]-c[2];g[0]=f[0]*Math.cos(d)-f[1]*Math.sin(d);g[1]=f[0]*Math.sin(d)+f[1]*Math.cos(d);g[2]=f[2];a[0]=g[0]+c[0];a[1]=g[1]+c[1];a[2]=g[2]+c[2];return a};c.forEach=function(){var a=c.create();return function(b,c,d,f,g,k){c||(c=3);d||(d=0);for(f=f?Math.min(f*c+d,b.length):b.length;d<f;d+=c)a[0]=b[d],a[1]=b[d+1],a[2]=b[d+2],g(a,a,k),b[d]=a[0],b[d+1]=a[1],b[d+2]=a[2];return b}}();
c.angle=function(a,b){var d=c.fromValues(a[0],a[1],a[2]),f=c.fromValues(b[0],b[1],b[2]);c.normalize(d,d);c.normalize(f,f);d=c.dot(d,f);return 1<d?0:Math.acos(d)};c.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"};c.exactEquals=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]};c.equals=function(a,b){var c=a[0],d=a[1],f=a[2],h=b[0],k=b[1],p=b[2];return Math.abs(c-h)<=g.EPSILON*Math.max(1,Math.abs(c),Math.abs(h))&&Math.abs(d-k)<=g.EPSILON*Math.max(1,Math.abs(d),Math.abs(k))&&Math.abs(f-
p)<=g.EPSILON*Math.max(1,Math.abs(f),Math.abs(p))};h.exports=c},function(h,d,f){var g=f(41),c={create:function(){var a=new g.ARRAY_TYPE(4);a[0]=0;a[1]=0;a[2]=0;a[3]=0;return a},clone:function(a){var b=new g.ARRAY_TYPE(4);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},fromValues:function(a,b,c,d){var f=new g.ARRAY_TYPE(4);f[0]=a;f[1]=b;f[2]=c;f[3]=d;return f},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];return a},set:function(a,b,c,d,f){a[0]=b;a[1]=c;a[2]=d;a[3]=f;return a},add:function(a,
b,c){a[0]=b[0]+c[0];a[1]=b[1]+c[1];a[2]=b[2]+c[2];a[3]=b[3]+c[3];return a},subtract:function(a,b,c){a[0]=b[0]-c[0];a[1]=b[1]-c[1];a[2]=b[2]-c[2];a[3]=b[3]-c[3];return a}};c.sub=c.subtract;c.multiply=function(a,b,c){a[0]=b[0]*c[0];a[1]=b[1]*c[1];a[2]=b[2]*c[2];a[3]=b[3]*c[3];return a};c.mul=c.multiply;c.divide=function(a,b,c){a[0]=b[0]/c[0];a[1]=b[1]/c[1];a[2]=b[2]/c[2];a[3]=b[3]/c[3];return a};c.div=c.divide;c.ceil=function(a,b){a[0]=Math.ceil(b[0]);a[1]=Math.ceil(b[1]);a[2]=Math.ceil(b[2]);a[3]=
Math.ceil(b[3]);return a};c.floor=function(a,b){a[0]=Math.floor(b[0]);a[1]=Math.floor(b[1]);a[2]=Math.floor(b[2]);a[3]=Math.floor(b[3]);return a};c.min=function(a,b,c){a[0]=Math.min(b[0],c[0]);a[1]=Math.min(b[1],c[1]);a[2]=Math.min(b[2],c[2]);a[3]=Math.min(b[3],c[3]);return a};c.max=function(a,b,c){a[0]=Math.max(b[0],c[0]);a[1]=Math.max(b[1],c[1]);a[2]=Math.max(b[2],c[2]);a[3]=Math.max(b[3],c[3]);return a};c.round=function(a,b){a[0]=Math.round(b[0]);a[1]=Math.round(b[1]);a[2]=Math.round(b[2]);a[3]=
Math.round(b[3]);return a};c.scale=function(a,b,c){a[0]=b[0]*c;a[1]=b[1]*c;a[2]=b[2]*c;a[3]=b[3]*c;return a};c.scaleAndAdd=function(a,b,c,d){a[0]=b[0]+c[0]*d;a[1]=b[1]+c[1]*d;a[2]=b[2]+c[2]*d;a[3]=b[3]+c[3]*d;return a};c.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],f=b[2]-a[2],g=b[3]-a[3];return Math.sqrt(c*c+d*d+f*f+g*g)};c.dist=c.distance;c.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],f=b[2]-a[2],g=b[3]-a[3];return c*c+d*d+f*f+g*g};c.sqrDist=c.squaredDistance;c.length=function(a){var b=
a[0],c=a[1],d=a[2];a=a[3];return Math.sqrt(b*b+c*c+d*d+a*a)};c.len=c.length;c.squaredLength=function(a){var b=a[0],c=a[1],d=a[2];a=a[3];return b*b+c*c+d*d+a*a};c.sqrLen=c.squaredLength;c.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];a[2]=-b[2];a[3]=-b[3];return a};c.inverse=function(a,b){a[0]=1/b[0];a[1]=1/b[1];a[2]=1/b[2];a[3]=1/b[3];return a};c.normalize=function(a,b){var c=b[0],d=b[1],f=b[2],g=b[3],k=c*c+d*d+f*f+g*g;0<k&&(k=1/Math.sqrt(k),a[0]=c*k,a[1]=d*k,a[2]=f*k,a[3]=g*k);return a};c.dot=function(a,
b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};c.lerp=function(a,b,c,d){var f=b[0],g=b[1],k=b[2];b=b[3];a[0]=f+d*(c[0]-f);a[1]=g+d*(c[1]-g);a[2]=k+d*(c[2]-k);a[3]=b+d*(c[3]-b);return a};c.random=function(a,b){b=b||1;a[0]=g.RANDOM();a[1]=g.RANDOM();a[2]=g.RANDOM();a[3]=g.RANDOM();c.normalize(a,a);c.scale(a,a,b);return a};c.transformMat4=function(a,b,c){var d=b[0],f=b[1],g=b[2];b=b[3];a[0]=c[0]*d+c[4]*f+c[8]*g+c[12]*b;a[1]=c[1]*d+c[5]*f+c[9]*g+c[13]*b;a[2]=c[2]*d+c[6]*f+c[10]*g+c[14]*b;a[3]=c[3]*
d+c[7]*f+c[11]*g+c[15]*b;return a};c.transformQuat=function(a,b,c){var d=b[0],f=b[1],g=b[2],k=c[0],h=c[1],m=c[2];c=c[3];var t=c*d+h*g-m*f,q=c*f+m*d-k*g,v=c*g+k*f-h*d,d=-k*d-h*f-m*g;a[0]=t*c+d*-k+q*-m-v*-h;a[1]=q*c+d*-h+v*-k-t*-m;a[2]=v*c+d*-m+t*-h-q*-k;a[3]=b[3];return a};c.forEach=function(){var a=c.create();return function(b,c,d,f,g,k){c||(c=4);d||(d=0);for(f=f?Math.min(f*c+d,b.length):b.length;d<f;d+=c)a[0]=b[d],a[1]=b[d+1],a[2]=b[d+2],a[3]=b[d+3],g(a,a,k),b[d]=a[0],b[d+1]=a[1],b[d+2]=a[2],b[d+
3]=a[3];return b}}();c.str=function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};c.exactEquals=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]};c.equals=function(a,b){var c=a[0],d=a[1],f=a[2],h=a[3],k=b[0],p=b[1],m=b[2],t=b[3];return Math.abs(c-k)<=g.EPSILON*Math.max(1,Math.abs(c),Math.abs(k))&&Math.abs(d-p)<=g.EPSILON*Math.max(1,Math.abs(d),Math.abs(p))&&Math.abs(f-m)<=g.EPSILON*Math.max(1,Math.abs(f),Math.abs(m))&&Math.abs(h-t)<=g.EPSILON*Math.max(1,Math.abs(h),
Math.abs(t))};h.exports=c},function(h,d,f){var g=f(41),c={create:function(){var a=new g.ARRAY_TYPE(2);a[0]=0;a[1]=0;return a},clone:function(a){var b=new g.ARRAY_TYPE(2);b[0]=a[0];b[1]=a[1];return b},fromValues:function(a,b){var c=new g.ARRAY_TYPE(2);c[0]=a;c[1]=b;return c},copy:function(a,b){a[0]=b[0];a[1]=b[1];return a},set:function(a,b,c){a[0]=b;a[1]=c;return a},add:function(a,b,c){a[0]=b[0]+c[0];a[1]=b[1]+c[1];return a},subtract:function(a,b,c){a[0]=b[0]-c[0];a[1]=b[1]-c[1];return a}};c.sub=c.subtract;
c.multiply=function(a,b,c){a[0]=b[0]*c[0];a[1]=b[1]*c[1];return a};c.mul=c.multiply;c.divide=function(a,b,c){a[0]=b[0]/c[0];a[1]=b[1]/c[1];return a};c.div=c.divide;c.ceil=function(a,b){a[0]=Math.ceil(b[0]);a[1]=Math.ceil(b[1]);return a};c.floor=function(a,b){a[0]=Math.floor(b[0]);a[1]=Math.floor(b[1]);return a};c.min=function(a,b,c){a[0]=Math.min(b[0],c[0]);a[1]=Math.min(b[1],c[1]);return a};c.max=function(a,b,c){a[0]=Math.max(b[0],c[0]);a[1]=Math.max(b[1],c[1]);return a};c.round=function(a,b){a[0]=
Math.round(b[0]);a[1]=Math.round(b[1]);return a};c.scale=function(a,b,c){a[0]=b[0]*c;a[1]=b[1]*c;return a};c.scaleAndAdd=function(a,b,c,d){a[0]=b[0]+c[0]*d;a[1]=b[1]+c[1]*d;return a};c.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)};c.dist=c.distance;c.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d};c.sqrDist=c.squaredDistance;c.length=function(a){var b=a[0];a=a[1];return Math.sqrt(b*b+a*a)};c.len=c.length;c.squaredLength=function(a){var b=a[0];
a=a[1];return b*b+a*a};c.sqrLen=c.squaredLength;c.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];return a};c.inverse=function(a,b){a[0]=1/b[0];a[1]=1/b[1];return a};c.normalize=function(a,b){var c=b[0],d=b[1],c=c*c+d*d;0<c&&(c=1/Math.sqrt(c),a[0]=b[0]*c,a[1]=b[1]*c);return a};c.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]};c.cross=function(a,b,c){b=b[0]*c[1]-b[1]*c[0];a[0]=a[1]=0;a[2]=b;return a};c.lerp=function(a,b,c,d){var f=b[0];b=b[1];a[0]=f+d*(c[0]-f);a[1]=b+d*(c[1]-b);return a};c.random=function(a,
b){b=b||1;var c=2*g.RANDOM()*Math.PI;a[0]=Math.cos(c)*b;a[1]=Math.sin(c)*b;return a};c.transformMat2=function(a,b,c){var d=b[0];b=b[1];a[0]=c[0]*d+c[2]*b;a[1]=c[1]*d+c[3]*b;return a};c.transformMat2d=function(a,b,c){var d=b[0];b=b[1];a[0]=c[0]*d+c[2]*b+c[4];a[1]=c[1]*d+c[3]*b+c[5];return a};c.transformMat3=function(a,b,c){var d=b[0];b=b[1];a[0]=c[0]*d+c[3]*b+c[6];a[1]=c[1]*d+c[4]*b+c[7];return a};c.transformMat4=function(a,b,c){var d=b[0];b=b[1];a[0]=c[0]*d+c[4]*b+c[12];a[1]=c[1]*d+c[5]*b+c[13];return a};
c.forEach=function(){var a=c.create();return function(b,c,d,f,g,k){c||(c=2);d||(d=0);for(f=f?Math.min(f*c+d,b.length):b.length;d<f;d+=c)a[0]=b[d],a[1]=b[d+1],g(a,a,k),b[d]=a[0],b[d+1]=a[1];return b}}();c.str=function(a){return"vec2("+a[0]+", "+a[1]+")"};c.exactEquals=function(a,b){return a[0]===b[0]&&a[1]===b[1]};c.equals=function(a,b){var c=a[0],d=a[1],f=b[0],h=b[1];return Math.abs(c-f)<=g.EPSILON*Math.max(1,Math.abs(c),Math.abs(f))&&Math.abs(d-h)<=g.EPSILON*Math.max(1,Math.abs(d),Math.abs(h))};
h.exports=c},function(h,d){d.removeSignalBinding=function(d,g,c){d.remove(g,c)};d.addSignalBinding=function(d,g,c){d.add(g,c)}},function(h,d){var f=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),g=new Uint32Array(2),c=[],a=2;for(;36>=a;++a){var b=Math.floor(32/Math.log2(a)),e=Math.pow(a,b),l=Math.floor(b/
2),r=Math.pow(a,l),l=Math.pow(a,b-l),n="^[0-"+String.fromCharCode(48+Math.min(9,a-1));10<a&&(n+="a-"+String.fromCharCode(97+a-11),n+="A-"+String.fromCharCode(65+a-11));n+="]{1,"+Math.ceil(64/Math.log2(a))+"}$";c[a]={lowDigits:b,lowBase:e,lowBase1:r,lowBase2:l,pattern:new RegExp(n)}}a=function(){function a(){var b=0>=arguments.length||void 0===arguments[0]?0:arguments[0],c=1>=arguments.length||void 0===arguments[1]?0:arguments[1];if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");
this.low=b;this.high=c}f(a,[{key:"clone",value:function(){return new a(this.low,this.high)}},{key:"assign",value:function(a){this.low=a.low;this.high=a.high}},{key:"toString",value:function(){var a=0>=arguments.length||void 0===arguments[0]?10:arguments[0],b=this.low,d=this.high;if(0===d)return b.toString(a);var d=4294967296*d,e=c[a],f=e.lowBase,e=e.lowDigits,k=d%f,d=Math.floor(d/f),b=b+k,d=d+Math.floor(b/f),b=(b%f).toString(a);return d.toString(a)+"0".repeat(e-b.length)+b}},{key:"parseString",value:function(a){var b=
1>=arguments.length||void 0===arguments[1]?10:arguments[1],d=c[b],e=d.lowDigits,f=d.lowBase,k=d.lowBase1,g=d.lowBase2;if(!d.pattern.test(a))return!1;if(a.length<=e)return this.low=parseInt(a,b),this.high=0,!0;e=a.length-e;d=parseInt(a.substr(e),b);b=parseInt(a.substr(0,e),b);f=Math.floor(b*f/4294967296);k=d+b%4294967296*k%4294967296*g%4294967296;4294967296<k&&(++f,k-=4294967296);if(k>>>0!==k||f>>>0!==f)return!1;this.low=k;this.high=f;return!0}},{key:"valid",value:function(){var a=this.low,b=this.high;
return a>>>0===a&&b>>>0===b}}],[{key:"less",value:function(a,b){return a.high<b.high||a.high===b.high&&a.low<b.low}},{key:"equal",value:function(a,b){return a.low===b.low&&a.high===b.high}},{key:"min",value:function(b,c){return a.less(b,c)?b:c}},{key:"random",value:function(){crypto.getRandomValues(g);return new a(g[0],g[1])}},{key:"parseString",value:function(b){var c=1>=arguments.length||void 0===arguments[1]?10:arguments[1],d=new a;if(!d.parseString(b,c))throw Error("Failed to parse string as uint64 value: "+
JSON.stringify(b)+".");return d}}]);return a}();a.ZERO=new a(0,0);d.Uint64=a},function(h,d){var f=function(){function c(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(a,b,d){b&&c(a.prototype,b);d&&c(a,d);return a}}(),g=function(){function c(){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");this.renderLayers=[null];this.lowValues=[0];this.highValues=
[0]}f(c,[{key:"clear",value:function(){this.renderLayers.length=1;this.lowValues.length=1;this.highValues.length=1}},{key:"register",value:function(a,b){var c=this.renderLayers,d=this.lowValues,f=this.highValues,g=c.length;c[g]=a;d[g]=b.low;f[g]=b.high;return g}},{key:"setMouseState",value:function(a,b){a.pickedRenderLayer=this.renderLayers[b];var c=a.pickedValue;c.low=this.lowValues[b];c.high=this.highValues[b]}}]);return c}();d.PickIDManager=g},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in
e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(54);var b=f(39),e=f(56);f(57);d.KEY_COMMANDS=new Map;f=function(a){for(var c=b.AXES_NAMES[a],e=function(e){var f=0>e?"-":"+";d.KEY_COMMANDS.set("rotate-relative-"+c+f,function(){this.navigationState.pose.rotateRelative(b.kAxes[a],.1*e)});var g=b.vec3.create();d.KEY_COMMANDS.set(""+c+f,function(){var b=this.navigationState;g[0]=0;g[1]=0;g[2]=0;g[a]=e;b.pose.translateVoxelsRelative(g)})},
f=$jscomp.makeIterator([-1,1]),g=f.next();!g.done;g=f.next())e(g.value)};for(var l=0;3>l;++l)f(l);d.KEY_COMMANDS.set("snap",function(){this.navigationState.pose.snap()});d.KEY_COMMANDS.set("zoom-in",function(){this.navigationState.zoomBy(.5)});d.KEY_COMMANDS.set("zoom-out",function(){this.navigationState.zoomBy(2)});var r=b.vec3.create();h=function(f){function k(a,b,c){if(!(this instanceof k))throw new TypeError("Cannot call a class as a function");var d=g(this,Object.getPrototypeOf(k).call(this,
a,b));d.viewer=c;d.mouseX=0;d.mouseY=0;d.mouseStateUpdater=d.updateMouseState.bind(d);b.classList.add("rendered-data-panel");d.registerEventListener(b,"mousemove",d.onMousemove.bind(d));d.registerEventListener(b,"mouseleave",d.onMouseout.bind(d));d.registerEventListener(b,"mousedown",d.onMousedown.bind(d),!1);d.registerEventListener(b,"wheel",d.onMousewheel.bind(d),!1);d.registerEventListener(b,"dblclick",function(){d.viewer.layerManager.invokeAction("select")});return d}c(k,f);a(k,[{key:"onMouseout",
value:function(a){a=this.viewer.mouseState;a.updater=void 0;a.setActive(!1)}},{key:"onKeyCommand",value:function(a){return(a=d.KEY_COMMANDS.get(a))?(a.call(this),!0):!1}},{key:"onMousemove",value:function(a){var b=this.element;a.target===b&&(this.mouseX=a.offsetX-b.clientLeft,this.mouseY=a.offsetY-b.clientTop,a=this.viewer.mouseState,a.updater=this.mouseStateUpdater,a.triggerUpdate())}},{key:"onMousewheel",value:function(a){if(a.ctrlKey)this.onMousemove(a),this.zoomByMouse(e.getWheelZoomAmount(a));
else{var b=this.navigationState;r[0]=0;r[1]=0;r[2]=(0<a.wheelDelta?1:-1)*(a.shiftKey?10:1);b.pose.translateVoxelsRelative(r)}a.preventDefault()}},{key:"onMousedown",value:function(a){if(event.target===this.element&&(this.onMousemove(a),2===a.button&&(a=this.viewer.mouseState,a.updateUnconditionally()))){var c=this.navigationState.pose.position;b.vec3.copy(c.spatialCoordinates,a.position);c.changed.dispatch()}}}]);return k}(h.RenderedPanel);d.RenderedDataPanel=h},function(h,d,f){function g(a,b){if(!(a instanceof
b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
b):a.__proto__=b)}var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var e=f(55),l=f(23);f=function(d){function e(a,b){g(this,e);var d=c(this,Object.getPrototypeOf(e).call(this));d.context=a;d.element=b;d.gl=a.gl;d.registerEventListener(b,"mouseenter",function(a){d.context.setActivePanel(d)});a.addPanel(d);
return d}a(e,d);b(e,[{key:"scheduleRedraw",value:function(){this.context.scheduleRedraw()}},{key:"setGLViewport",value:function(){var a=this.element,b=a.offsetLeft+a.clientLeft,c=a.clientWidth,d=a.clientHeight,e=a.offsetTop+a.clientTop+d,a=this.gl;a.enable(a.SCISSOR_TEST);e=this.context.canvas.height-e;a.viewport(b,e,c,d);a.scissor(b,e,c,d)}},{key:"onKeyCommand",value:function(a){return!1}},{key:"disposed",value:function(){this.context.removePanel(this)}}]);return e}(h.RefCounted);d.RenderedPanel=
f;f=function(d){function f(a){g(this,f);var b=c(this,Object.getPrototypeOf(f).call(this));b.container=a;b.canvas=document.createElement("canvas");b.updateStarted=new l.Signal;b.updateFinished=new l.Signal;b.panels=new Set;b.activePanel=null;b.updatePending=null;b.needsRedraw=!1;var d=b.canvas;d.className="gl-canvas";a.appendChild(d);b.gl=e.initializeWebGL(d);b.registerEventListener(window,"resize",b.onResize.bind(b));return b}a(f,d);b(f,[{key:"disposed",value:function(){null!=this.updatePending&&
(cancelAnimationFrame(this.updatePending),this.updatePending=null)}},{key:"addPanel",value:function(a){this.panels.add(a);null==this.activePanel&&this.setActivePanel(a)}},{key:"setActivePanel",value:function(a){var b=this.activePanel;null!=b&&b.element.attributes.removeNamedItem("isActivePanel");null!=a&&a.element.setAttribute("isActivePanel","true");this.activePanel=a}},{key:"removePanel",value:function(a){this.panels.delete(a);a===this.activePanel&&this.setActivePanel(null);a.dispose()}},{key:"onResize",
value:function(){this.scheduleRedraw();for(var a=$jscomp.makeIterator(this.panels),b=a.next();!b.done;b=a.next())b.value.onResize()}},{key:"scheduleUpdate",value:function(){null===this.updatePending&&(this.updatePending=requestAnimationFrame(this.update.bind(this)))}},{key:"scheduleRedraw",value:function(){this.needsRedraw||(this.needsRedraw=!0,this.scheduleUpdate())}},{key:"update",value:function(){this.updatePending=null;this.updateStarted.dispatch();if(this.needsRedraw){this.needsRedraw=!1;var a=
this.gl,b=this.canvas;b.width=b.offsetWidth;b.height=b.offsetHeight;this.gl.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT);a=$jscomp.makeIterator(this.panels);for(b=a.next();!b.done;b=a.next()){var b=b.value,c=b.element;0!==c.clientWidth&&0!==c.clientHeight&&(b.setGLViewport(),b.draw())}}this.updateFinished.dispatch()}}]);return f}(h.RefCounted);d.DisplayContext=f},function(h,d,f){var g=f(22);d.DEBUG_SHADERS=!1;d.initializeWebGL=function(c){var a={antialias:!1,stencil:!0};d.DEBUG_SHADERS&&
(console.log("DEBUGGING via preserveDrawingBuffer"),a.preserveDrawingBuffer=!0);c=c.getContext("webgl",a)||c.getContext("experimental-webgl",a);c.memoize=new g.Memoize;c.maxTextureSize=c.getParameter(c.MAX_TEXTURE_SIZE);c.maxTextureImageUnits=c.getParameter(c.MAX_TEXTURE_IMAGE_UNITS);c.tempTextureUnit=c.maxTextureImageUnits-1;c.WEBGL_draw_buffers=c.getExtension("WEBGL_draw_buffers");if(!c.WEBGL_draw_buffers)throw Error("WEBGL_draw_buffers extension not available");for(var a=$jscomp.makeIterator(["OES_texture_float",
"OES_element_index_uint"]),b=a.next();!b.done;b=a.next())if(b=b.value,!c.getExtension(b))throw Error(b+" extension not available");return c}},function(h,d){d.getWheelZoomAmount=function(d){var g=0;switch(d.deltaMode){case 0:g=.005;break;case 1:g=.1;break;case 2:g=2}return Math.exp(d.deltaY*g)}},function(h,d){},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a,b){for(var c=$jscomp.makeIterator(z),d=c.next();!d.done;d=c.next())if(d=d.value,d=d(a,b),null!=d)return d;throw Error("No chunk format handler found.");
}var e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),l=function u(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),null===a?void 0:u(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},r=f(20),
n=f(21),k=f(59),p=f(64);h=f(12);var m=f(39),t=f(26),q=f(66),v=f(29),x=f(23),w=m.mat4.create();f=function(b){function d(a,b,e,f){g(this,d);var k=c(this,Object.getPrototypeOf(d).call(this));k.gl=a;k.chunkManager=b;k.layerManager=e;k.navigationState=f;k.dataToViewport=m.mat4.create();k.viewportToDevice=m.mat4.create();k.dataToDevice=m.mat4.create();k.visibleChunks=new Map;k.viewChanged=new x.Signal;k.renderingStale=!0;k.visibleChunksStale=!0;k.visibleLayersStale=!1;k.visibleLayerList=[];k.newVisibleLayers=
new Set;k.offscreenFramebuffer=new q.OffscreenFramebuffer(k.gl,{numDataBuffers:1,depthBuffer:!1,stencilBuffer:!0});m.mat4.identity(k.dataToViewport);k.initializeCounterpart(k.chunkManager.rpc,{type:"SliceView",chunkManager:b.rpcId});k.updateVisibleLayers();k.registerSignalBinding(f.changed.add(function(){k.updateViewportFromNavigationState()}));k.updateViewportFromNavigationState();k.registerSignalBinding(e.layersChanged.add(function(){!k.visibleLayersStale&&k.hasValidViewport&&(k.visibleLayersStale=
!0,setTimeout(k.updateVisibleLayers.bind(k),0))}));k.viewChanged.add(function(){k.renderingStale=!0});k.registerSignalBinding(b.chunkQueueManager.visibleChunksChanged.add(k.viewChanged.dispatch,k.viewChanged));return k}a(d,b);e(d,[{key:"updateViewportFromNavigationState",value:function(){var a=this.navigationState;a.valid&&(a.toMat4(w),this.setViewportToDataMatrix(w))}},{key:"updateVisibleLayers",value:function(){if(!this.hasValidViewport)return!1;this.visibleLayersStale=!1;var a=this.visibleLayers,
b=this.rpc,c={id:this.rpcId},d=this.newVisibleLayers,e=!1,f=this.visibleLayerList;f.length=0;for(var g=$jscomp.makeIterator(this.layerManager.readyRenderLayers()),k=g.next();!k.done;k=g.next())k=k.value,k instanceof p.RenderLayer&&(d.add(k),f.push(k),a.has(k)||(a.set(k,[]),k.redrawNeeded.add(this.viewChanged.dispatch,this.viewChanged),c.layerId=k.rpcId,b.invoke("SliceView.addVisibleLayer",c),e=!0));f=$jscomp.makeIterator(a.keys());for(g=f.next();!g.done;g=f.next())g=g.value,d.has(g)||(a.delete(g),
g.redrawNeeded.remove(this.viewChanged.dispatch,this.viewChanged),c.layerId=g.rpcId,b.invoke("SliceView.removeVisibleLayer",c),e=!0);d.clear();e&&(this.visibleSourcesStale=!0);this.viewChanged.dispatch();return e}},{key:"onViewportChanged",value:function(){var a=this.width,b=this.height,c=this.viewportToDevice,d=this.dataToViewport,e=this.dataToDevice;m.mat4.ortho(c,-a/2,a/2,b/2,-b/2,-1,1);m.mat4.multiply(e,c,d);this.visibleChunksStale=!0;this.viewChanged.dispatch()}},{key:"setViewportSize",value:function(a,
b){return l(Object.getPrototypeOf(d.prototype),"setViewportSize",this).call(this,a,b)?(this.rpc.invoke("SliceView.updateView",{id:this.rpcId,width:a,height:b}),!0):!1}},{key:"onViewportToDataMatrixChanged",value:function(){var a=this.viewportToData,b=this.dataToViewport;m.mat4.invert(b,a);m.rectifyTransformMatrixIfAxisAligned(b);this.rpc.invoke("SliceView.updateView",{id:this.rpcId,viewportToData:a})}},{key:"onHasValidViewport",value:function(){this.updateVisibleLayers()}},{key:"updateRendering",
value:function(){if(this.renderingStale&&this.hasValidViewport&&0!==this.width&&0!==this.height){this.renderingStale=!1;this.maybeUpdateVisibleChunks();var a=this.gl,b=this.offscreenFramebuffer;b.bind(this.width,this.height);a.disable(a.SCISSOR_TEST);a.clearStencil(0);a.clearColor(0,0,0,0);a.colorMask(!0,!0,!0,!0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.STENCIL_TEST);a.disable(a.DEPTH_TEST);a.stencilOpSeparate(a.FRONT_AND_BACK,a.KEEP,a.KEEP,a.REPLACE);for(var c=0,d=$jscomp.makeIterator(this.visibleLayerList),
e=d.next();!e.done;e=d.next())e=e.value,a.clear(a.STENCIL_BUFFER_BIT),a.stencilFuncSeparate(a.FRONT_AND_BACK,a.GREATER,1,1),1===c&&(a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA)),e.draw(this),++c;a.disable(a.BLEND);a.disable(a.STENCIL_TEST);b.unbind()}}},{key:"maybeUpdateVisibleChunks",value:function(){if(!this.visibleChunksStale&&!this.visibleSourcesStale)return!1;this.visibleChunksStale=!1;this.updateVisibleChunks();return!0}},{key:"updateVisibleChunks",value:function(){var a=
this.visibleChunks;this.computeVisibleChunks(function(b){var c=a.get(b);void 0===c?(c=[],a.set(b,c)):c.length=0;return c},function(a,b,c){a=m.vec3Key(c);b[b.length]=a})}}]);return d}(k.SliceViewBase);d.SliceView=f;var z=[];d.registerChunkFormatHandler=function(a){z.push(a)};f=function(d){function f(a,d){g(this,f);var e=c(this,Object.getPrototypeOf(f).call(this,a));e.spec=d;e.chunkFormatHandler=e.registerDisposer(b(a.chunkQueueManager.gl,d));return e}a(f,d);e(f,[{key:"initializeCounterpart",value:function(a,
b){this.spec.toObject(b.spec={});l(Object.getPrototypeOf(f.prototype),"initializeCounterpart",this).call(this,a,b)}},{key:"getValueAt",value:function(a){for(var b=m.vec3.create(),c=this.spec,d=c.chunkLayout,e=d.offset,f=d.size,d=0;3>d;++d)b[d]=Math.floor((a[d]-e[d])/f[d]);d=m.vec3Key(b);d=this.chunks.get(d);if(!d)return null;for(var g=c.voxelSize,k=0;3>k;++k)b[k]=Math.floor((a[k]-e[k]-b[k]*f[k])/g[k]);a=d.chunkDataSize;for(e=0;3>e;++e)if(b[e]>=a[e])return;c=c.numChannels;if(1===c)return d.getChannelValueAt(b,
0);a=Array(c);for(e=0;e<c;++e)a[e]=d.getChannelValueAt(b,e);return a}},{key:"getChunk",value:function(a){return this.chunkFormatHandler.getChunk(this,a)}},{key:"chunkFormat",get:function(){return this.chunkFormatHandler.chunkFormat}}]);return f}(n.ChunkSource);d.VolumeChunkSource=f;n=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this,a));e.chunkGridPosition=b.chunkGridPosition;e.chunkDataSize=b.chunkDataSize||a.spec.chunkDataSize;e.state=r.ChunkState.SYSTEM_MEMORY;
return e}a(d,b);e(d,[{key:"chunkFormat",get:function(){return this.source.chunkFormat}}]);return d}(n.Chunk);d.VolumeChunk=n;h=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this));e.gl=a;e.copyVertexPositionsBuffer=e.registerDisposer(t.Buffer.fromData(e.gl,new Float32Array([-1,-1,0,1,-1,1,0,1,1,1,0,1,1,-1,0,1]),e.gl.ARRAY_BUFFER,e.gl.STATIC_DRAW));e.copyTexCoordsBuffer=e.registerDisposer(t.Buffer.fromData(e.gl,new Float32Array([0,0,0,1,1,1,1,0]),e.gl.ARRAY_BUFFER,
e.gl.STATIC_DRAW));e.textureCoordinateAdjustment=new Float32Array(4);var f=new v.ShaderBuilder(a);f.addVarying("vec2","vTexCoord");f.addUniform("sampler2D","uSampler");f.addInitializer(function(b){a.uniform1i(b.uniform("uSampler"),0)});f.addUniform("vec4","uColorFactor");f.addUniform("vec4","uBackgroundColor");f.addUniform("mat4","uProjectionMatrix");f.addUniform("vec4","uTextureCoordinateAdjustment");f.require(b);f.setFragmentMain("\nvec4 sampledColor = texture2D(uSampler, vTexCoord);\nif (sampledColor.a == 0.0) {\n  sampledColor = uBackgroundColor;\n}\nemit(sampledColor * uColorFactor, vec4(0,0,0,0));\n");
f.addAttribute("vec4","aVertexPosition");f.addAttribute("vec2","aTexCoord");f.setVertexMain("\nvTexCoord = uTextureCoordinateAdjustment.xy + aTexCoord * uTextureCoordinateAdjustment.zw;\ngl_Position = uProjectionMatrix * aVertexPosition;\n");e.shader=e.registerDisposer(f.build());return e}a(d,b);e(d,[{key:"draw",value:function(a,b,c,d,e,f,g,k){var l=this.gl,h=this.shader,m=this.textureCoordinateAdjustment;m[0]=e;m[1]=f;m[2]=g-e;m[3]=k-f;h.bind();l.activeTexture(l.TEXTURE0);l.bindTexture(l.TEXTURE_2D,
a);l.uniformMatrix4fv(h.uniform("uProjectionMatrix"),!1,b);l.uniform4fv(h.uniform("uColorFactor"),c);l.uniform4fv(h.uniform("uBackgroundColor"),d);l.uniform4fv(h.uniform("uTextureCoordinateAdjustment"),m);a=h.attribute("aVertexPosition");this.copyVertexPositionsBuffer.bindToVertexAttrib(a,4);h=h.attribute("aTexCoord");this.copyTexCoordsBuffer.bindToVertexAttrib(h,2);l.drawArrays(l.TRIANGLE_FAN,0,4);l.disableVertexAttribArray(a);l.disableVertexAttribArray(h);l.bindTexture(l.TEXTURE_2D,null)}}],[{key:"get",
value:function(a,b,c){return a.memoize.get(b,function(){return new d(a,c)})}}]);return d}(h.RefCounted);d.SliceViewRenderHelper=h},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?
Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b,c){for(var d=0;3>d;++d)a[d]=Number.POSITIVE_INFINITY,b[d]=Number.NEGATIVE_INFINITY;c=$jscomp.makeIterator(c);for(d=c.next();!d.done;d=c.next())for(var e=d.value.spec,d=e.lowerChunkBound,e=e.upperChunkBound,f=0;3>f;++f)a[f]=Math.min(a[f],d[f]),b[f]=Math.max(b[f],e[f])}function b(a,b,c,d){for(var e=v.FULLY_INSIDE,f=0;3>f;++f){var g;g=a[f];var k=b[f],l=c[f],h=d[f];g=g>=h||k<=l?v.FULLY_OUTSIDE:g>=l&&k<=h?v.FULLY_INSIDE:v.PARTIALLY_INSIDE;switch(g){case v.FULLY_OUTSIDE:return g;
case v.PARTIALLY_INSIDE:e=g}}return e}function e(a,b,c){var d=c.length,e=0;if(1<d)for(var f=0,g=0;g<d;++g){for(var k=c[g],l=0,h=l,m=0;3>m;++m)var n=k.spec.chunkLayout.size[m],l=Math.max(l,n*Math.abs(a[m])),h=Math.max(h,n*Math.abs(b[m]));k=l*h;k>f&&(f=k,e=g)}return c[e]}var l=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();
for(var g=a[Symbol.iterator](),k;!(d=(k=g.next()).done)&&(c.push(k.value),!b||c.length!==b);d=!0);}catch(l){e=!0,f=l}finally{try{if(!d&&g["return"])g["return"]()}finally{if(e)throw f;}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance");}}(),r=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,
d);return b}}(),n=f(60),k=f(61),p=f(62),m=f(63);d.DATA_TYPE_BYTES=m.DATA_TYPE_BYTES;d.DataType=m.DataType;var t=f(39),q=f(39);h=f(11);var v;(function(a){a[a.FULLY_OUTSIDE=0]="FULLY_OUTSIDE";a[a.FULLY_INSIDE=1]="FULLY_INSIDE";a[a.PARTIALLY_INSIDE=2]="PARTIALLY_INSIDE"})(v||(v={}));h=function(d){function f(){g(this,f);var a;a=Object.getPrototypeOf(f).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");a=!a||"object"!==typeof a&&"function"!==typeof a?
this:a;a.width=-1;a.height=-1;a.hasViewportToData=!1;a.hasValidViewport=!1;a.viewportToData=t.mat4.create();a.viewportAxes=[t.vec4.create(),t.vec4.create(),t.vec4.create()];a.previousViewportAxes=[t.vec3.create(),t.vec3.create()];a.centerDataPosition=t.vec3.create();a.viewportPlaneDistanceToOrigin=0;a.visibleChunkLayouts=new Map;a.visibleLayers=new Map;a.visibleSourcesStale=!0;a.pixelSize=0;t.mat4.identity(a.viewportToData);return a}c(f,d);r(f,[{key:"onViewportChanged",value:function(){}},{key:"maybeSetHasValidViewport",
value:function(){!this.hasValidViewport&&-1!==this.width&&-1!==this.height&&this.hasViewportToData&&(this.hasValidViewport=!0,this.onHasValidViewport());if(this.hasValidViewport)this.onViewportChanged()}},{key:"onHasValidViewport",value:function(){}},{key:"setViewportSize",value:function(a,b){return a!==this.width||b!==this.height?(this.width=a,this.height=b,this.maybeSetHasValidViewport(),!0):!1}},{key:"setViewportToDataMatrix",value:function(a){if(this.hasViewportToData&&t.mat4.equals(this.viewportToData,
a))return!1;this.hasViewportToData=!0;var b=this.viewportToData;t.mat4.copy(b,a);t.rectifyTransformMatrixIfAxisAligned(b);t.vec3.transformMat4(this.centerDataPosition,q.kZeroVec,a);a=0;for(var c=this.viewportAxes,d=this.previousViewportAxes,e=0;3>e;++e){var f=c[e];t.vec4.transformMat4(f,q.kAxes[e],b);0===e&&(a=t.vec3.length(f));t.vec4.normalize(f,f)}this.viewportAxes=c;this.previousViewportAxes=d;if(!p.approxEqual(a,this.pixelSize)||.95>t.vec3.dot(c[0],d[0])||.95>t.vec3.dot(c[1],d[1]))t.vec3.copy(d[0],
c[0]),t.vec3.copy(d[1],c[1]),this.visibleSourcesStale=!0,this.pixelSize=a;this.viewportPlaneDistanceToOrigin=t.vec3.dot(this.centerDataPosition,this.viewportAxes[2]);this.onViewportToDataMatrixChanged();this.maybeSetHasValidViewport();return!0}},{key:"onViewportToDataMatrixChanged",value:function(){}},{key:"updateVisibleSources",value:function(){if(this.visibleSourcesStale){this.visibleSourcesStale=!1;var a=1.1*this.pixelSize,b=this.visibleChunkLayouts,c=l(this.viewportAxes,2),d=c[0],f=c[1],g=this.visibleLayers;
b.clear();for(var c=function(c){h=l(c,2);c=h[0];var g=h[1];g.length=0;c=c.sources;for(var k=c.length,m=void 0,n=c[0][0].spec.voxelSize,q=function(b){for(var c=0;3>c;++c){var d=b[c];if(d>a&&d>n[c])return!0}return!1},y=function(a,c){g[g.length++]=a;var d=a.spec.chunkLayout,e=b.get(d);void 0===e&&(e=new Map,b.set(d,e));e.set(a,k-c-1)},m=k-1;;){var p=e(d,f,c[m]);y(p,m);if(0===m||!q(p.spec.voxelSize))break;--m}g.reverse()},g=$jscomp.makeIterator(g),k=g.next();!k.done;k=g.next()){var h;c(k.value)}}}},{key:"computeVisibleChunks",
value:function(c,d){var e=this;this.updateVisibleSources();for(var f=this.centerDataPosition,g=t.vec3.clone(f),l=t.vec3.clone(f),f=t.vec3.create(),h=$jscomp.makeIterator([-this.width/2,this.width/2]),m=h.next();!m.done;m=h.next())for(var m=m.value,n=$jscomp.makeIterator([-this.height/2,this.height/2]),p=n.next();!p.done;p=n.next())p=p.value,t.vec3.scale(f,q.kAxes[0],m),t.vec3.scaleAndAdd(f,f,q.kAxes[1],p),t.vec3.transformMat4(f,f,this.viewportToData),t.vec3.min(g,g,f),t.vec3.max(l,l,f);for(var r=
t.vec3.create(),w=t.vec3.create(),z=t.vec3.create(),x=this.viewportAxes[2],f=0;3>f;++f)0<x[f]&&(z[f]=1);var X=[],N=[];this.visibleChunkLayouts.forEach(function(f,h){function m(){for(var a=0,b=0,c=0;3>c;++c)var d=p[c],e=x[c],f=r[c],g=w[c]-f,k=z[c]*g,a=a+e*d*(f+k),b=b+e*d*(f+g-k);return a<E?!1:b<=E}function n(a){function c(){P=k.partitionArray(X,0,p,function(a){var c=a.spec;switch(b(r,w,c.lowerChunkBound,c.upperChunkBound)){case v.PARTIALLY_INSIDE:return!0;case v.FULLY_INSIDE:N.push(a);default:return!1}})}
if(0!==N.length||0!==P){for(var e=1,f=0;3>f;++f)e*=Math.max(0,w[f]-r[f]);if(0!==e&&m())if(1===e)d(h,q,r,N);else{for(var g;;)if(e=r[a],f=w[a],g=f-e,1===g)a=(a+1)%3;else break;g=e+Math.floor(.5*g);var l=(a+1)%3,y=N.length;w[a]=g;var p=P;c();n(l);N.length=y;P=p;w[a]=f;r[a]=g;c();n(l);r[a]=e;N.length=y;P=p}}}var q=c(h),p=h.size,B=h.offset,E=e.viewportPlaneDistanceToOrigin-t.vec3.dot(B,e.viewportAxes[2]);a(r,w,f.keys());for(var G=0;3>G;++G)r[G]=Math.max(r[G],Math.floor((g[G]-B[G])/p[G])),w[G]=Math.min(w[G],
Math.floor((l[G]-B[G])/p[G]+1));N.length=0;X.length=0;B=$jscomp.makeIterator(f.keys());for(G=B.next();!G.done;G=B.next()){var G=G.value,H=G.spec;switch(b(r,w,H.lowerChunkBound,H.upperChunkBound)){case v.FULLY_INSIDE:N.push(G);break;case v.PARTIALLY_INSIDE:X.push(G)}}var P=X.length;n(0)})}}]);return f}(h.SharedObject);d.SliceViewBase=h;(function(a){a[a.UNKNOWN=0]="UNKNOWN";a[a.IMAGE=1]="IMAGE";a[a.SEGMENTATION=2]="SEGMENTATION"})(d.VolumeType||(d.VolumeType={}));var x=d.VolumeType;d.DEFAULT_CHUNK_DATA_SIZES=
[t.vec3.fromValues(64,64,64)];h=function(){function a(b,c,d,e,f,k,l){g(this,a);this.chunkLayout=b;this.chunkDataSize=c;this.numChannels=d;this.dataType=e;this.lowerVoxelBound=f;this.upperVoxelBound=k;this.compressedSegmentationBlockSize=l;this.chunkBytes=t.prod3(c)*m.DATA_TYPE_BYTES[e]*d;c=this.voxelSize=t.vec3.divide(t.vec3.create(),this.chunkLayout.size,this.chunkDataSize);d=this.lowerChunkBound=t.vec3.create();e=this.upperChunkBound=t.vec3.create();var h=b.size;b=b.offset;for(var n=0;3>n;++n)d[n]=
Math.floor((f[n]*c[n]-b[n])/h[n]),e[n]=Math.floor(((k[n]-1)*c[n]-b[n])/h[n]+1);this.compressedSegmentationBlockSize=l}r(a,[{key:"toObject",value:function(a){this.chunkLayout.toObject(a.chunkLayout={});a.chunkDataSize=this.chunkDataSize;a.numChannels=this.numChannels;a.dataType=this.dataType;a.lowerVoxelBound=this.lowerVoxelBound;a.upperVoxelBound=this.upperVoxelBound;a.compressedSegmentationBlockSize=this.compressedSegmentationBlockSize}}],[{key:"fromObject",value:function(b){return new a(n.ChunkLayout.fromObject(b.chunkLayout),
b.chunkDataSize,b.numChannels,b.dataType,b.lowerVoxelBound,b.upperVoxelBound,b.compressedSegmentationBlockSize)}},{key:"getDefaults",value:function(b){var c=b.voxelSize,e=b.dataType,f=b.lowerVoxelBound,g=b.chunkDataSizes,g=void 0===g?d.DEFAULT_CHUNK_DATA_SIZES:g,k=b.numChannels,l=void 0===k?1:k,h=b.compressedSegmentationBlockSize,q=t.vec3.multiply(t.vec3.create(),f,c);void 0!==h||b.volumeType!==x.SEGMENTATION||e!==m.DataType.UINT32&&e!==m.DataType.UINT64||(h=t.vec3.fromValues(8,8,8));return g.map(function(d){var g=
t.vec3.create();t.vec3.multiply(g,c,d);g=n.ChunkLayout.get(g,q);return new a(g,d,l,e,f,b.upperVoxelBound,h)})}}]);return a}();d.VolumeChunkSpecification=h},function(h,d,f){var g=function(){function a(a,c){for(var d=0;d<c.length;d++){var f=c[d];f.enumerable=f.enumerable||!1;f.configurable=!0;"value"in f&&(f.writable=!0);Object.defineProperty(a,f.key,f)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),c=f(39);h=function(){function a(b,d){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");
this.size=c.vec3.clone(b);this.offset=void 0===d?c.vec3.create():c.vec3.clone(d)}g(a,[{key:"toObject",value:function(a){a.size=this.size;a.offset=this.offset}}],[{key:"get",value:function(b){var d=1>=arguments.length||void 0===arguments[1]?c.kZeroVec:arguments[1],f=a.cache,g=c.vec3Key(b)+"+"+c.vec3Key(d),h=f.get(g);void 0===h&&(h=new a(b,d),f.set(g,h));return h}},{key:"fromObject",value:function(b){return a.get(b.size,b.offset)}}]);return a}();h.cache=new Map;d.ChunkLayout=h},function(h,d){d.partitionArray=
function(d,g,c,a){for(;g<c;){var b=d[g];a(b)?++g:(--c,d[g]=d[c],d[c]=b)}return c};d.maybePadArray=function(d,g){if(d.length===g)return d;var c=new d.constructor(g);c.set(d);return c};d.getFortranOrderStrides=function(d){for(var g=d.length,c=Array(g),a=c[0]=1>=arguments.length||void 0===arguments[1]?1:arguments[1],b=1;b<g;++b)a*=d[b-1],c[b]=a;return c}},function(h,d){d.approxEqual=function(d,g){return d===g?!0:1E-6>Math.abs(d-g)/Math.min(Math.abs(d),Math.abs(g))}},function(h,d){var f=d.DataType||(d.DataType=
{});f[f.UINT8=0]="UINT8";f[f.UINT16=1]="UINT16";f[f.UINT32=2]="UINT32";f[f.UINT64=3]="UINT64";f[f.FLOAT32=4]="FLOAT32";f=d.DataType;d.DATA_TYPE_BYTES=[];d.DATA_TYPE_BYTES[f.UINT8]=1;d.DATA_TYPE_BYTES[f.UINT16]=2;d.DATA_TYPE_BYTES[f.UINT32]=4;d.DATA_TYPE_BYTES[f.UINT64]=8;d.DATA_TYPE_BYTES[f.FLOAT32]=4},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a){for(var b=0,c=0;3>c;++c)0>a[c]&&(b+=1<<c);return b}var e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=
c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),l=f(20);h=f(30);var r=f(59),n=f(65),k=f(12),p=f(39),m=f(8),t=f(26),q=f(29),v=f(11),x=f(23);d.GLSL_TYPE_FOR_DATA_TYPE=new Map([[r.DataType.UINT8,"uint8_t"],[r.DataType.FLOAT32,"float"],[r.DataType.UINT16,"uint16_t"],[r.DataType.UINT32,"uint32_t"],[r.DataType.UINT64,"uint64_t"]]);d.trackableAlphaValue=function(){return new n.TrackableValue(0>=
arguments.length||void 0===arguments[0]?.5:arguments[0],m.verifyFloat01)};var w=function(b){function d(a){g(this,d);var b=c(this,Object.getPrototypeOf(d).call(this));b.outputVertexIndices=b.registerDisposer(t.Buffer.fromData(a,new Float32Array([0,1,2,3,4,5]),a.ARRAY_BUFFER,a.STATIC_DRAW));b.vertexBasePositions=[0,0,0,1,0,0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,1,1,1,1];a=[0,1,2,4,5,3,6,7];for(var e=[0,1,2,5,3,4,6,7],f=[0,1,1,4,4,7,4,7,1,5,0,1,1,4,4,7,0,2,2,5,5,7,5,7,2,6,0,2,2,5,5,7,0,3,3,6,6,7,6,7,3,4,0,3,
3,6,6,7],k=[0,1,2,3,4,5,6,7,1,4,5,0,3,7,2,6,2,6,0,5,7,3,1,4,3,0,6,4,1,2,7,5,4,3,7,1,0,6,5,2,5,2,1,7,6,0,4,3,6,7,3,2,5,4,0,1,7,5,4,6,2,1,3,0],l=[],h=0;8>h;++h)for(var m=0;m<f.length;++m)l.push(a[k[8*e[h]+f[m]]]);b.vertexIndices=new Int32Array(l);return b}a(d,b);e(d,null,[{key:"get",value:function(a){return a.memoize.get("SliceViewShaderBuffers",function(){return new d(a)})}}]);return d}(k.RefCounted),z=function(d){function f(a){g(this,f);var b=c(this,Object.getPrototypeOf(f).call(this));b.data=b.registerDisposer(w.get(a));
return b}a(f,d);e(f,[{key:"defineShader",value:function(a){var b=this.data;a.addAttribute("highp float","aVertexIndexFloat");a.addUniform("highp vec3","uTranslation");a.addUniform("highp mat4","uProjectionMatrix");a.addUniform("highp vec3","uPlaneNormal");a.addUniform("highp float","uPlaneDistance");a.addUniform("highp ivec2","uVertexIndex",24);a.addUniform("highp vec3","uVertexBasePosition",8);a.addInitializer(function(a){a.gl.uniform3fv(a.uniform("uVertexBasePosition"),new Float32Array(b.vertexBasePositions))});
a.addUniform("highp vec3","uChunkSize");a.addVarying("highp vec3","vChunkPosition");a.setVertexMain("\nint vertexIndex = int(aVertexIndexFloat);\nfor (int e = 0; e < 4; ++e) {\n  highp ivec2 vidx = uVertexIndex[vertexIndex*4 + e];\n  highp vec3 v1 = uChunkSize * uVertexBasePosition[vidx.x];\n  highp vec3 v2 = uChunkSize * uVertexBasePosition[vidx.y];\n  highp vec3 vStart = v1 + uTranslation;\n  highp vec3 vDir = v2 - v1;\n  highp float denom = dot(vDir, uPlaneNormal);\n  if (abs(denom) > 0.001) {\n    highp float lambda = (uPlaneDistance - dot(vStart, uPlaneNormal)) / denom;\n    if ((lambda >= -0.001) && (lambda <= (1.0 + 0.001))) {\n      lambda = clamp(lambda, 0.0, 1.0);\n      highp vec3 position = vStart + lambda * vDir;\n      gl_Position = uProjectionMatrix * vec4(position, 1.0);\n      vChunkPosition = mix(uVertexBasePosition[vidx.x], uVertexBasePosition[vidx.y], lambda);\n      break;\n    }\n  }\n}\n")}},
{key:"computeVerticesDebug",value:function(a,c,d,e,f){for(var g=b(d),g=this.data.vertexIndices.subarray(48*g,48*(g+1)),k=[0,0],l=[p.vec3.create(),p.vec3.create()],h=p.vec3.create(),m=p.vec3.create(),n=p.vec3.create(),q=p.vec3.create(),r=p.vec3.create(),u=new Float32Array(this.data.vertexBasePositions),t=function(a){return u.subarray(3*a,3*a+3)},w=0;6>w;++w)for(var x=0;4>x;++x){for(var z=0;2>z;++z)k[z]=g[2*(4*w+x)+z],p.vec3.multiply(l[z],a,t(k[z]));p.vec3.add(h,l[0],e);p.vec3.subtract(m,l[1],l[0]);
z=p.vec3.dot(m,d);if(.001<Math.abs(z)){var v=(c-p.vec3.dot(h,d))/z;if(-.001<=v&&1.001>=v){v=Math.max(0,Math.min(1,v));p.vec3.scaleAndAdd(n,h,m,v);p.vec3.transformMat4(q,p.vec4.fromValues(n[0],n[1],n[2],1),f);p.vec3.scale(r,t(k[0]),1-v);p.vec3.scaleAndAdd(r,r,t(k[1]),v);console.log("vertex "+w+", e = "+x+", at "+q+", vChunkPosition = "+r+", edge dir = "+m+", denom = "+z);break}else console.log("vertex "+w+", e = "+x+", skipped, deom = "+z+", vDir = "+p.vec3Key(m)+", uPlaneNormal = "+p.vec3Key(d)+", lambda="+
v)}else console.log("vertex "+w+", e = "+x+", skipped, deom = "+z+", vDir = "+p.vec3Key(m)+", uPlaneNormal = "+p.vec3Key(d))}}},{key:"beginSlice",value:function(a,c,d,e){var f=e.viewportAxes[2],g=b(f);a.uniformMatrix4fv(c.uniform("uProjectionMatrix"),!1,d);a.uniform3fv(c.uniform("uPlaneNormal"),f.subarray(0,3));a.uniform1f(c.uniform("uPlaneDistance"),e.viewportPlaneDistanceToOrigin);d=c.attribute("aVertexIndexFloat");this.data.outputVertexIndices.bindToVertexAttrib(d,1);a.uniform2iv(c.uniform("uVertexIndex"),
this.data.vertexIndices.subarray(48*g,48*(g+1)))}},{key:"endSlice",value:function(a,b){var c=b.attribute("aVertexIndexFloat");a.disableVertexAttribArray(c)}},{key:"setupChunkSize",value:function(a,b,c){a.uniform3fv(b.uniform("uChunkSize"),c)}},{key:"drawChunk",value:function(a,b,c){a.uniform3fv(b.uniform("uTranslation"),c);a.drawArrays(a.TRIANGLE_FAN,0,6)}}],[{key:"get",value:function(a){return a.memoize.get("sliceview.VolumeSliceVertexComputationManager",function(){return new f(a)})}}]);return f}(k.RefCounted);
f=function(b){function f(a,b){g(this,f);var d=c(this,Object.getPrototypeOf(f).call(this));d.chunkManager=a;d.sources=null;d.shader=void 0;d.shaderUpdated=!0;d.redrawNeeded=new x.Signal;d.rpcId=null;d.shaderError=new n.WatchableValue(void 0);d.vertexComputationManager=z.get(d.gl);Promise.resolve(b).then(function(b){var c=d.sources=b.getSources(a);b=[];for(var c=$jscomp.makeIterator(c),e=c.next();!e.done;e=c.next()){var f=e.value,e=[];b.push(e);for(var f=$jscomp.makeIterator(f),g=f.next();!g.done;g=
f.next())e.push(g.value.rpcId)}c=d.registerDisposer(new v.SharedObject);c.initializeCounterpart(a.rpc,{type:"sliceview/RenderLayer",sources:b});d.rpcId=c.rpcId;b=d.sources[0][0].spec;d.voxelSize=b.voxelSize;d.boundingBox=new p.BoundingBox(b.lowerVoxelBound,b.upperVoxelBound);d.setReady(!0)});return d}a(f,b);e(f,[{key:"initializeShader",value:function(){if(this.shaderUpdated){this.shaderUpdated=!1;try{var a=this.getShader();this.disposeShader();this.shader=a;this.shaderError.value=void 0}catch(b){this.shaderError.value=
b}}}},{key:"disposeShader",value:function(){this.shader&&(this.shader.dispose(),this.shader=void 0)}},{key:"dispose",value:function(){this.disposeShader()}},{key:"getValueAt",value:function(a){for(var b=$jscomp.makeIterator(this.sources),c=b.next();!c.done;c=b.next())for(var c=$jscomp.makeIterator(c.value),d=c.next();!d.done;d=c.next())if(d=d.value.getValueAt(a),null!=d)return d;return null}},{key:"getShaderKey",value:function(){return""}},{key:"getShader",value:function(){var a=this,b=this.getShaderKey()+
"/"+this.chunkFormat.shaderKey;return this.gl.memoize.get(b,function(){return a.buildShader()})}},{key:"buildShader",value:function(){var a=new q.ShaderBuilder(this.gl);this.defineShader(a);return a.build()}},{key:"defineShader",value:function(a){this.vertexComputationManager.defineShader(a);a.addFragmentCode("\nvoid emit(vec4 color) {\n  gl_FragData[0] = color;\n}\n");this.chunkFormat.defineShader(a);a.addFragmentCode("\n"+d.GLSL_TYPE_FOR_DATA_TYPE.get(this.dataType)+" getDataValue() { return getDataValue(0); }\n")}},
{key:"beginSlice",value:function(a){var b=a.dataToDevice,c=this.gl,d=this.shader;d.bind();this.vertexComputationManager.beginSlice(c,d,b,a);return d}},{key:"endSlice",value:function(a){this.vertexComputationManager.endSlice(this.gl,a)}},{key:"draw",value:function(a){var b=a.visibleLayers.get(this);if(0!==b.length&&(this.initializeShader(),void 0!==this.shader)){var c=this.gl,d=p.vec3.create(),e=p.vec3.create(),f=this.beginSlice(a),g=this.vertexComputationManager,k=this.chunkFormat;k.beginDrawing(c,
f);for(var b=$jscomp.makeIterator(b),h=b.next();!h.done;h=b.next()){var h=h.value,m=h.spec.chunkLayout,n=m.offset,q=h.chunks,r=m.size,u=void 0;if(m=a.visibleChunks.get(m))for(var m=$jscomp.makeIterator(m),t=m.next();!t.done;t=m.next())if((t=q.get(t.value))&&t.state===l.ChunkState.GPU_MEMORY){var w=t.chunkDataSize;w!==u&&(u=w,p.vec3.multiply(e,u,h.spec.voxelSize),g.setupChunkSize(c,f,e));p.vec3.multiply(d,r,t.chunkGridPosition);p.vec3.add(d,d,n);k.bindChunk(c,f,t);g.drawChunk(c,f,d)}}k.endDrawing(c,
f);this.endSlice(f)}}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}},{key:"chunkFormat",get:function(){return this.sources[0][0].chunkFormat}},{key:"dataType",get:function(){return this.sources[0][0].spec.dataType}}]);return f}(h.RenderLayer);d.RenderLayer=f},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,
enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),b=f(23);h=function(){function d(a){c(this,d);
this.value_=a;this.changed=new b.Signal}a(d,[{key:"value",get:function(){return this.value_},set:function(a){a!==this.value_&&(this.value_=a,this.changed.dispatch())}}]);return d}();d.WatchableValue=h;h=function(b){function d(a,b){var e=2>=arguments.length||void 0===arguments[2]?a:arguments[2];c(this,d);var f;f=Object.getPrototypeOf(d).call(this,a);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");f=!f||"object"!==typeof f&&"function"!==typeof f?this:f;
f.validator=b;f.defaultValue=e;return f}g(d,b);a(d,[{key:"toJSON",value:function(){return this.value_===this.defaultValue?void 0:this.value_}},{key:"restoreState",value:function(a){if(void 0!==a){var b=this.validator;try{this.value=b(a);return}catch(c){}}a=this.defaultValue;void 0!==a&&(this.value=a)}}]);return d}(h);d.TrackableValue=h},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in
e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var e=f(39),l=f(26),r=f(67),n=f(28);f=function(d){function e(a){var b=1>=arguments.length||void 0===arguments[1]?{}:arguments[1],d=b.numDataBuffers,d=void 0===d?1:d,f=b.depthBuffer,f=void 0===f?!1:f,b=b.stencilBuffer,b=void 0===b?!1:b;g(this,e);var k=c(this,Object.getPrototypeOf(e).call(this));k.gl=a;k.width=Number.NaN;k.height=Number.NaN;k.framebuffer=k.gl.createFramebuffer();
k.depthBuffer=null;k.dataTextures=[];k.attachmentVerified=!1;k.tempPixel=new Uint8Array(4);k.fullAttachmentList=[];k.singleAttachmentList=[k.gl.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL];for(var h=k.dataTextures,l=k.fullAttachmentList,n=0;n<d;++n)h[n]=a.createTexture(),l[n]=a.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL+n;if(f||b)k.depthBuffer=a.createRenderbuffer();k.useStencilBuffer=b;return k}a(e,d);b(e,[{key:"disposed",value:function(){var a=this.gl,b=this.depthBuffer;a.deleteFramebuffer(this.framebuffer);
null!=b&&a.deleteRenderbuffer(b);for(var b=$jscomp.makeIterator(this.dataTextures),c=b.next();!c.done;c=b.next())a.deleteTexture(c.value)}},{key:"resize",value:function(a,b){if(!this.hasSize(a,b)){this.width=a;this.height=b;for(var c=this.gl,d=this.useStencilBuffer,e=this.depthBuffer,f=$jscomp.makeIterator(this.dataTextures),g=f.next();!g.done;g=f.next())r.resizeTexture(c,g.value,a,b);e&&(c.bindRenderbuffer(c.RENDERBUFFER,e),c.renderbufferStorage(c.RENDERBUFFER,d?c.DEPTH_STENCIL:c.DEPTH_COMPONENT16,
a,b),c.bindRenderbuffer(c.RENDERBUFFER,null))}}},{key:"hasSize",value:function(a,b){return this.width===a&&this.height===b}},{key:"bind",value:function(a,b){this.resize(a,b);var c=this.gl,d=this.useStencilBuffer,e=this.depthBuffer;c.bindFramebuffer(c.FRAMEBUFFER,this.framebuffer);e&&c.framebufferRenderbuffer(c.FRAMEBUFFER,d?c.DEPTH_STENCIL_ATTACHMENT:c.DEPTH_ATTACHMENT,c.RENDERBUFFER,e);this.dataTextures.forEach(function(a,b){c.framebufferTexture2D(c.FRAMEBUFFER,c.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL+
b,c.TEXTURE_2D,a,0)});c.WEBGL_draw_buffers.drawBuffersWEBGL(this.fullAttachmentList);this.verifyAttachment();c.viewport(0,0,a,b)}},{key:"unbind",value:function(){var a=this.gl;a.bindFramebuffer(a.FRAMEBUFFER,null)}},{key:"bindSingle",value:function(a){var b=this.gl;b.bindFramebuffer(b.FRAMEBUFFER,this.framebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,this.dataTextures[a],0);b.WEBGL_draw_buffers.drawBuffersWEBGL(this.singleAttachmentList)}},{key:"readPixel",value:function(a,
b,c){var d=this.gl,e=this.tempPixel;try{this.bindSingle(a),d.readPixels(b,c,1,1,d.RGBA,d.UNSIGNED_BYTE,e)}finally{d.bindFramebuffer(d.FRAMEBUFFER,null)}return e}},{key:"readPixelAsUint32",value:function(a,b,c){a=this.readPixel(a,b,c);return a[0]+(a[1]<<8)+(a[2]<<16)+(a[3]<<24)}},{key:"verifyAttachment",value:function(){if(!this.attachmentVerified){var a=this.gl;if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error("Framebuffer configuration not supported");this.attachmentVerified=
!0}}}]);return e}(h.RefCounted);d.OffscreenFramebuffer=f;f=function(d){function f(a){g(this,f);var b=c(this,Object.getPrototypeOf(f).call(this));b.gl=a;b.copyVertexPositionsBuffer=b.registerDisposer(l.Buffer.fromData(b.gl,new Float32Array([-1,-1,0,1,-1,1,0,1,1,1,0,1,1,-1,0,1]),b.gl.ARRAY_BUFFER,b.gl.STATIC_DRAW));b.copyTexCoordsBuffer=b.registerDisposer(l.Buffer.fromData(b.gl,new Float32Array([0,0,0,1,1,1,1,0]),b.gl.ARRAY_BUFFER,b.gl.STATIC_DRAW));b.trivialTextureShader=b.registerDisposer(n.trivialTextureShader(b.gl));
return b}a(f,d);b(f,[{key:"draw",value:function(a){var b=this.gl,c=this.trivialTextureShader;c.bind();b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,a);b.uniform1i(c.uniform("uSampler"),0);b.uniformMatrix4fv(c.uniform("uProjectionMatrix"),!1,e.identityMat4);a=c.attribute("aVertexPosition");this.copyVertexPositionsBuffer.bindToVertexAttrib(a,4);c=c.attribute("aTexCoord");this.copyTexCoordsBuffer.bindToVertexAttrib(c,2);b.drawArrays(b.TRIANGLE_FAN,0,4);b.disableVertexAttribArray(a);b.disableVertexAttribArray(c);
b.bindTexture(b.TEXTURE_2D,null)}}],[{key:"get",value:function(a){return a.memoize.get("OffscreenCopyHelper",function(){return new f(a)})}}]);return f}(h.RefCounted);d.OffscreenCopyHelper=f},function(h,d){function f(d){d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.NEAREST);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.NEAREST);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE)}d.setRawTextureParameters=f;d.resizeTexture=
function(d,c,a,b){var e=4>=arguments.length||void 0===arguments[4]?d.RGBA:arguments[4],h=5>=arguments.length||void 0===arguments[5]?d.UNSIGNED_BYTE:arguments[5];d.activeTexture(d.TEXTURE0+d.tempTextureUnit);d.bindTexture(d.TEXTURE_2D,c);f(d);d.texImage2D(d.TEXTURE_2D,0,e,a,b,0,e,h,null);d.bindTexture(d.TEXTURE_2D,null)}},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:
b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||
!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var e=f(23);f=function(){function c(b,d){a(this,c);this.value_=b;this.defaultValue=d;this.changed=new e.Signal}b(c,[{key:"toggle",value:function(){this.value=!this.value}},{key:"toJSON",value:function(){return this.value_===this.defaultValue?void 0:this.value_}},{key:"restoreState",value:function(a){void 0===a&&(a=this.defaultValue);if(!0===
a||!1===a)this.value=a}},{key:"value",get:function(){return this.value_},set:function(a){a!==this.value_&&(this.value_=a,this.changed.dispatch())}}]);return c}();d.TrackableBoolean=f;f=function(d){function e(b){a(this,e);var c=g(this,Object.getPrototypeOf(e).call(this));c.model=b;c.element=document.createElement("input");var d=c.element;d.type="checkbox";c.registerSignalBinding(b.changed.add(c.updateCheckbox,c));c.updateCheckbox();c.registerEventListener(d,"change",function(a){b.value=this.checked});
return c}c(e,d);b(e,[{key:"updateCheckbox",value:function(){this.element.checked=this.model.value}},{key:"disposed",value:function(){var a=this.element,b=a.parentElement;b&&b.removeChild(a)}}]);return e}(h.RefCounted);d.TrackableBooleanCheckbox=f;h=function(d){function e(b,c){a(this,e);var d=g(this,Object.getPrototypeOf(e).call(this));d.model=b;d.element=c;d.updateVisibility();d.registerSignalBinding(b.changed.add(function(){d.updateVisibility()}));return d}c(e,d);b(e,[{key:"updateVisibility",value:function(){this.element.style.display=
this.model.value?"":"none"}}]);return e}(h.RefCounted);d.ElementVisibilityFromTrackableBoolean=h},function(h,d){d.startRelativeMouseDrag=function(d,g){var c=d.view.document,a=d.screenX,b=d.screenY,e=function(c){var d=a-c.screenX,e=b-c.screenY;a=c.screenX;b=c.screenY;g(c,d,e)},h=d.button,r=function(a){a.button===h&&(c.removeEventListener("mousemove",e,!0),c.removeEventListener("mouseup",r,!1))};c.addEventListener("mousemove",e,!0);c.addEventListener("mouseup",r,!1)}},function(h,d){d.glsl_packFloat01ToFixedPoint=
"\nvec4 packFloat01ToFixedPoint(const float value) {\n  const vec4 shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n  const vec4 mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n  vec4 result = fract(value * shift);\n  result -= result.xxyz * mask;\n  return result * 256.0 / 255.0;\n}\n";d.unpackFloat01FromFixedPoint=function(d){return(d[3]+1/256*d[2]+1/65536*d[1]+1/16777216*d[0])/256};d.glsl_hsvToRgb="\nvec3 hueToRgb(float hue) {\n  float hue6 = hue * 6.0;\n  float r = abs(hue6 - 3.0) - 1.0;\n  float g = 2.0 - abs(hue6 - 2.0);\n  float b = 2.0 - abs(hue6 - 4.0);\n  return clamp(vec3(r, g, b), 0.0, 1.0);\n}\nvec3 hsvToRgb(vec3 c) {\n  vec3 hueRgb = hueToRgb(c.x);\n  return c.z * ((hueRgb - 1.0) * c.y + 1.0);\n}\n";
d.glsl_uint64="\nstruct uint64_t {\n  vec4 low, high;\n};\nuint64_t toUint64(uint64_t x) { return x; }\n";d.glsl_uint8=[d.glsl_uint64,"\nstruct uint8_t {\n  float value;\n};\nfloat toRaw(uint8_t x) { return x.value * 255.0; }\nfloat toNormalized(uint8_t x) { return x.value; }\nuint64_t toUint64(uint8_t x) {\n  uint64_t result;\n  result.low = vec4(x.value, 0.0, 0.0, 0.0);\n  result.high = vec4(0.0, 0.0, 0.0, 0.0);\n  return result;\n}\n"];d.glsl_float="\nfloat toRaw(float x) { return x; }\nfloat toNormalized(float x) { return x; }\n";
d.glsl_uint16=[d.glsl_uint64,"\nstruct uint16_t {\n  vec2 value;\n};\nfloat toRaw(uint16_t x) { return x.value.x * 255.0 + x.value.y * 65280.0; }\nfloat toNormalized(uint16_t x) { return toRaw(x) / 65535.0; }\nuint64_t toUint64(uint16_t x) {\n  uint64_t result;\n  result.low = vec4(x.value, 0.0, 0.0);\n  result.high = vec4(0.0, 0.0, 0.0, 0.0);\n  return result;\n}\n"];d.glsl_uint32=[d.glsl_uint64,"\nstruct uint32_t {\n  vec4 value;\n};\nuint64_t toUint64(uint32_t x) {\n  uint64_t result;\n  result.low = x.value;\n  result.high = vec4(0.0, 0.0, 0.0, 0.0);\n  return result;\n}\n"];
d.glsl_getSubscriptsFromNormalized="\nvec3 getSubscriptsFromNormalized(vec3 normalizedPosition, vec3 size) {\n  return floor(min(normalizedPosition * size, size - 1.0));\n}\n";d.glsl_getFortranOrderIndex="\nfloat getFortranOrderIndex(vec3 subscripts, vec3 size) {\n  return subscripts.x + size.x * (subscripts.y + size.y * subscripts.z);\n}\n";d.glsl_getFortranOrderIndexFromNormalized=[d.glsl_getSubscriptsFromNormalized,d.glsl_getFortranOrderIndex,"\nfloat getFortranOrderIndexFromNormalized(vec3 normalizedPosition, vec3 size) {\n  return getFortranOrderIndex(getSubscriptsFromNormalized(normalizedPosition, size), size);\n}\n"];
d.glsl_imod="\nfloat imod(float x, float y) {\n  return x - y * floor(x / y);\n}\n";d.glsl_exactDot="\nfloat exactDot(vec4 a, vec4 b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\nfloat exactDot(vec3 a, vec3 b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n";d.fract=function(d){return d-Math.floor(d)};d.step=function(d,g){return g<d?0:1};d.mod=function(d,g){return d%g};d.exp2=function(d){return Math.pow(2,d)};d.glsl_packFloat="\nvec4 packFloatIntoVec4(float f) {\n  float magnitude = abs(f); \n  if (magnitude == 0.0) {\n     return vec4(0,0,0,0);\n  }\n  float sign =  step(0.0, -f);\n  float exponent = floor(log2(magnitude)); \n  float mantissa = magnitude / exp2(exponent); \n  // Denormalized values if all exponent bits are zero\n  if (mantissa < 1.0) {\n     exponent -= 1.0;\n  }\n\n  exponent +=  127.0;\n\n  vec4 result;\n  result[3] = 128.0 * sign + floor(exponent / 2.0);\n  result[2] = 128.0 * mod(exponent, 2.0) +  mod(floor(mantissa * float(128.0)),128.0);\n  result[1] = floor( mod(floor(mantissa* exp2(float(23.0 - 8.0))), exp2(8.0)));\n  result[0] = floor( exp2(23.0)* mod(mantissa, exp2(-15.0)));\n  return result / 255.0;\n}\n";
d.glsl_debugFunctions=[d.glsl_packFloat];d.encodeBytesToFloat32=function(d){d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength);for(var g=d.length,c=new Float32Array(g),a=0;a<g;++a)c[a]=d[a]/255;return c};d.setVec4FromUint32=function(d,g){for(var c=0;4>c;++c)d[c]=(g>>8*c&255)/255;return d};d.getUint32FromVec4=function(d){return 255*d[0]+65280*d[1]+16711680*d[2]+4278190080*d[3]}},function(h,d){},function(h,d){},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){var c=JSON.stringify({hostnames:a,token:b}),d=A.get(c);if(void 0!==d)return d;d=v.sendHttpRequest(v.openShardedHttpRequest(a,"/ocp/ca/"+b+"/info/"),"json");A.set(c,d);return d}
function b(b,c){var d=c.match(B);if(null===d)throw Error("Invalid volume path "+JSON.stringify(c));var e=x.stableStringify({hostnames:b,path:c}),f=D.get(e);if(void 0!==f)return f;var g=d[1],k=d[2],h=x.parseQueryStringParameters(d[3]||""),d=a(b,g).then(function(a){return new y(b,g,a,k,h)});D.set(e,d);return d}function e(a){var c=a.match(E);if(null===c)throw Error("Invalid ndstore volume path: "+JSON.stringify(a));return b([c[1]],c[2])}function l(a){var b=JSON.stringify(a),c=H.get(b);if(void 0!==c)return c;
a=v.sendHttpRequest(v.openShardedHttpRequest(a,"/ocp/ca/public_tokens/"),"json").then(function(a){return x.parseArray(a,x.verifyString)});H.set(b,a);return a}function r(b,c){var d=c.match(/^(?:([^\/]+)(?:\/([^\/]*))?)?$/);if(null===d)return Promise.reject(null);if(void 0===d[2]){var e=function(){var a=d[1]||"";return{v:l(b).then(function(b){return{offset:0,completions:t.getPrefixMatchesWithDescriptions(a,b,function(a){return a+"/"},function(a){})}})}}();if("object"===typeof e)return e.v}return w.cancellableThen(a(b,
d[1]),function(a){var b=[];"object"!==typeof a||null===a||Array.isArray(a)||function(){var c=a.channels;if("object"===typeof c&&null!==c&&!Array.isArray(c)){var e=Object.keys(c);b=t.getPrefixMatchesWithDescriptions(d[2],e,function(a){return a},function(a){a=c[a];return a.channel_type+" ("+a.datatype+")"})}}();return{offset:d[1].length+1,completions:b}})}function n(a){var b=a.match(E);return null===b?Promise.reject(null):w.cancellableThen(r([b[1]],b[2]),function(a){return t.applyCompletionOffset(b[1].length+
1,a)})}var k=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(17);var p=f(59),m=f(58),t=f(18),q=f(39),v=f(14),x=f(8),w=f(9),z=new Map;z.set("image",p.VolumeType.IMAGE);z.set("annotation",p.VolumeType.SEGMENTATION);var C=new Set(["npz","raw","jpeg"]),u=function(a){function b(a,c,d,e,f,k,h){g(this,b);c=Object.getPrototypeOf(b).call(this,
a,c);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");c=!c||"object"!==typeof c&&"function"!==typeof c?this:c;c.hostnames=d;c.key=e;c.channel=f;c.resolution=k;c.encoding=h;c.initializeCounterpart(a.rpc,{type:"ndstore/VolumeChunkSource",hostnames:d,key:e,channel:f,resolution:k,encoding:h});return c}c(b,a);k(b,[{key:"toString",value:function(){return"ndstore:volume:"+this.hostnames[0]+"/"+this.key+"/"+this.channel+"/"+this.resolution+"/"+this.encoding}}]);
return b}(m.VolumeChunkSource);d.VolumeChunkSource=u;var y=function(){function a(b,c,d,e,f){g(this,a);this.hostnames=b;this.key=c;this.response=d;this.parameters=f;b=d.channels;c=Object.keys(b);if(void 0===e){if(1!==c.length)throw Error("Dataset contains multiple channels: "+JSON.stringify(c));e=c[0]}else if(-1===c.indexOf(e))throw Error("Specified channel "+JSON.stringify(e)+" is not one of the supported channels "+JSON.stringify(c));this.channel=e;e=b[e];b=z.get(e.channel_type);void 0===b&&(b=p.VolumeType.UNKNOWN);
this.volumeType=b;this.dataType=x.verifyObjectProperty(e,"datatype",function(a){return x.verifyEnumString(a,p.DataType)});this.numChannels=1}k(a,[{key:"getSources",value:function(a){var b=this,c=[],d=this.volumeType,e=this.response.dataset,f=x.verifyOptionalString(this.parameters.encoding);if(void 0===f)f=d===p.VolumeType.IMAGE?"jpeg":"npz";else if(!C.has(f))throw Error("Invalid encoding: "+JSON.stringify(f)+".");for(var g=function(g){var k=x.parseIntVec(q.vec3.create(),e.neariso_imagesize[g]),h=
x.parseFiniteVec(q.vec3.create(),e.neariso_voxelres[g]),l=[];c.push(l);for(var m=x.parseFiniteVec(q.vec3.create(),e.neariso_offset[g]),n=q.vec3.create(),r=q.vec3.create(),y=0;3>y;++y){var w=m[y];n[y]=Math.ceil(w);r[y]=Math.floor(w+k[y])}k=function(c){var d=x.stableStringify({spec:c,key:b.key,channel:b.channel,resolution:g});l.push(a.getChunkSource(u,d,function(){return new u(a,c,b.hostnames,b.key,b.channel,g,f)}))};h=$jscomp.makeIterator(p.VolumeChunkSpecification.getDefaults({volumeType:d,voxelSize:h,
dataType:b.dataType,lowerVoxelBound:n,upperVoxelBound:r}));for(n=h.next();!n.done;n=h.next())k(n.value)},k=$jscomp.makeIterator(Object.keys(e.neariso_imagesize)),h=k.next();!h.done;h=k.next())g(h.value);return c}},{key:"getMeshSource",value:function(a){return null}}]);return a}();d.MultiscaleVolumeChunkSource=y;var B=/^([^\/?]+)(?:\/([^\/?]+))?(?:\?(.*))?$/,A=new Map;d.getVolumeInfo=a;var D=new Map;d.getShardedVolume=b;var E=/^((?:http|https):\/\/[^\/?]+)\/(.*)$/;d.getVolume=e;var H=new Map;d.getPublicTokens=
l;d.tokenAndChannelCompleter=r;d.volumeCompleter=n;h.registerDataSourceFactory("ndstore",{description:"NDstore",volumeCompleter:n,getVolume:e})},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,
{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function b(a,b,c){A.verifyObject(a);var d=A.verifyObjectProperty(a,"Base",function(a){return new E(a)});switch(d.typeName){case "uint8blk":case "grayscale8":return new G(a,b,d,x.VolumeType.IMAGE,c);case "imagetile":return new Q(a,b,d);case "labels64":case "labelblk":return new G(a,
b,d,x.VolumeType.SEGMENTATION,c);default:throw Error("DVID data type "+JSON.stringify(d.typeName)+" is not supported.");}}function e(a){try{for(var b=A.verifyObjectAsMap(a,function(a){return new T(a)}),c=new Map,d=$jscomp.makeIterator(b),e=d.next();!e.done;e=d.next()){var f=t(e.value,2),g=f[0],k=f[1];c.set(g,k);for(var h=$jscomp.makeIterator(k.vnodes),l=h.next();!l.done;l=h.next()){var m=l.value;if(m!==g){var n=new T(k);c.set(m,n)}}}for(var q=$jscomp.makeIterator(c),u=q.next();!u.done;u=q.next()){var p=
t(u.value,2);p[1].uuid=p[0]}return c}catch(r){throw Error("Failed to parse DVID repositories info: "+r.message);}}function l(a){var b=A.stableStringify(a),c=N.get(b);void 0===c&&(c=B.sendHttpRequest(B.openShardedHttpRequest(a,"/api/repos/info","GET"),"json").then(function(a){return new X(a)}),a="repository info for DVID server "+a[0],C.StatusMessage.forPromise(c,{initialMessage:"Retrieving "+a+".",delay:!0,errorPrefix:"Error retrieving "+a+": "}),N.set(b,c));return c}function r(a,b,c){return l(a).then(function(d){d=
d.getNode(b);if(void 0===d)throw Error("Invalid node: "+JSON.stringify(b)+".");var e=d.dataInstances.get(c);if(!(e instanceof G||e instanceof Q))throw Error("Invalid data instance "+c+".");var f=A.stableStringify({baseUrls:a,nodeKey:d.uuid,dataInstanceKey:c}),g=ca.get(f);void 0===g&&(g=new ja(a,d.uuid,c,e),ca.set(f,g));return g})}function n(a){var b=a.match(ya);if(null===b)throw Error("Invalid DVID URL: "+JSON.stringify(a)+".");return r([b[1]],b[2],b[3])}function k(a,b){return{offset:0,completions:u.getPrefixMatchesWithDescriptions(b,
a.dataInstances.values(),function(a){return a.name},function(a){return""+a.base.typeName})}}function p(a,b){var c=b.match(/^(?:([^\/]+)(?:\/([^\/]*))?)?$/);if(null===c)throw Error("Invalid DVID URL syntax.");if(void 0===c[2])return{offset:0,completions:u.getPrefixMatchesWithDescriptions(b,a.repositories.values(),function(a){return a.uuid+"/"},function(a){return a.alias+": "+a.description})};var d=c[1],e=a.getNode(d);return u.applyCompletionOffset(d.length+1,k(e,c[2]))}function m(a){a=a.match(/^((?:http|https):\/\/[^\/]+)\/(.*)$/);
if(null===a)return Promise.reject(null);var b=a[1],c=a[2];return l([b]).then(function(a){return u.applyCompletionOffset(b.length+1,p(a,c))})}var t=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var g=a[Symbol.iterator](),k;!(d=(k=g.next()).done)&&(c.push(k.value),!b||c.length!==b);d=!0);}catch(h){e=!0,f=h}finally{try{if(!d&&
g["return"])g["return"]()}finally{if(e)throw f;}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance");}}(),q=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),v=f(75);h=f(17);var x=f(59),w=f(60),z=f(58),C=f(4),u=f(18),y=f(39),B=f(14),A=f(8),D=new Map;D.set("uint8",x.DataType.UINT8);
D.set("uint32",x.DataType.UINT32);D.set("uint64",x.DataType.UINT64);var E=function(){function b(c){a(this,b);this.obj=c;A.verifyObject(c);A.verifyObjectProperty(c,"TypeName",A.verifyString)}q(b,[{key:"typeName",get:function(){return this.obj.TypeName}}]);return b}();d.DataInstanceBaseInfo=E;f=function za(b,c,d){a(this,za);this.obj=b;this.name=c;this.base=d};d.DataInstanceInfo=f;var H=function(b){function d(b,c,e){a(this,d);c=g(this,Object.getPrototypeOf(d).call(this,b,c));c.parameters=e;c.initializeCounterpart(b.rpc,
{type:"dvid/VolumeChunkSource",parameters:e});return c}c(d,b);q(d,[{key:"toString",value:function(){return v.volumeSourceToString(this.parameters)}}]);return d}(z.VolumeChunkSource);d.VolumeChunkSource=H;var G=function(b){function d(b,c,e,f,k){a(this,d);e=g(this,Object.getPrototypeOf(d).call(this,b,c,e));e.volumeType=f;b=A.verifyObjectProperty(b,"Extended",A.verifyObject);f=A.verifyObjectProperty(b,"Values",function(a){return A.parseArray(a,A.verifyObject)});if(1>f.length)throw Error("Expected Extended.Values property to have length >= 1, but received: ${JSON.stringify(extendedValues)}.");
e.numLevels=1;for(k=new Set(k);k.has(c+"_"+e.numLevels.toString());)e.numLevels+=1;e.dataType=A.verifyObjectProperty(f[0],"DataType",function(a){return A.verifyMapKey(a,D)});e.lowerVoxelBound=A.verifyObjectProperty(b,"MinPoint",function(a){return A.parseIntVec(y.vec3.create(),a)});e.upperVoxelBound=A.verifyObjectProperty(b,"MaxPoint",function(a){return A.parseIntVec(y.vec3.create(),a)});e.voxelSize=A.verifyObjectProperty(b,"VoxelSize",function(a){return A.parseFixedLengthArray(y.vec3.create(),a,A.verifyFinitePositiveFloat)});
e.numChannels=1;return e}c(d,b);q(d,[{key:"getSources",value:function(a,b){for(var c=this,d=[],e=function(e){var f=y.vec3.clone(c.voxelSize);f[0]*=Math.pow(2,e);f[1]*=Math.pow(2,e);f[2]*=Math.pow(2,e);for(var g=y.vec3.create(),k=y.vec3.create(),h=0;3>h;++h)g[h]=Math.floor(c.voxelSize[h]/f[h]*c.lowerVoxelBound[h]),k[h]=Math.ceil(c.voxelSize[h]/f[h]*c.upperVoxelBound[h]);g=b.dataInstanceKey;0<e&&(g+="_"+e.toString());var l={baseUrls:b.baseUrls,nodeKey:b.nodeKey,dataInstanceKey:g,level:e.toString()};
e=Array.from(x.VolumeChunkSpecification.getDefaults({voxelSize:f,dataType:c.dataType,numChannels:c.numChannels,lowerVoxelBound:c.lowerVoxelBound,upperVoxelBound:c.upperVoxelBound,volumeType:c.volumeType})).map(function(b){return a.getChunkSource(H,A.stableStringify(l),function(){return new H(a,b,l)})});d.push(e)},f=0;f<this.numLevels;++f)e(f);return d}}]);return d}(f);d.VolumeDataInstanceInfo=G;var P=function Ba(b){a(this,Ba);A.verifyObject(b);this.resolution=A.verifyObjectProperty(b,"Resolution",
function(a){return A.parseFixedLengthArray(y.vec3.create(),a,A.verifyFinitePositiveFloat)});this.tileSize=A.verifyObjectProperty(b,"TileSize",function(a){return A.parseFixedLengthArray(y.vec3.create(),a,A.verifyPositiveInt)})};d.TileLevelInfo=P;var R=[[0,1],[0,2],[1,2]],W=function(b){function d(b,c,e){a(this,d);c=g(this,Object.getPrototypeOf(d).call(this,b,c));c.parameters=e;c.initializeCounterpart(b.rpc,{type:"dvid/TileChunkSource",parameters:e});return c}c(d,b);q(d,[{key:"toString",value:function(){return v.tileSourceToString(this.parameters)}}]);
return d}(z.VolumeChunkSource);d.TileChunkSource=W;var Q=function(b){function d(b,c,e){a(this,d);c=g(this,Object.getPrototypeOf(d).call(this,b,c,e));b=A.verifyObjectProperty(b,"Extended",A.verifyObject);c.levels=A.verifyObjectProperty(b,"Levels",function(a){return A.verifyObjectAsMap(a,function(a){return new P(a)})});e=c.levels.get("0");if(void 0===e)throw Error("Level 0 is not defined.");c.voxelSize=e.resolution;var f=A.verifyObjectProperty(b,"MinTileCoord",function(a){return A.parseFixedLengthArray(y.vec3.create(),
a,A.verifyInt)}),k=A.verifyObjectProperty(b,"MaxTileCoord",function(a){return A.parseFixedLengthArray(y.vec3.create(),a,A.verifyInt)});c.lowerVoxelBound=y.vec3.multiply(y.vec3.create(),e.tileSize,f);c.upperVoxelBound=y.vec3.multiply(y.vec3.create(),e.tileSize,k);b=A.verifyObjectProperty(b,"Encoding",function(a){return a});switch(b){case 2:c.encoding=v.TileEncoding.JPEG;break;default:throw Error("Unsupported tile encoding: "+JSON.stringify(b)+".");}return c}c(d,b);q(d,[{key:"getSources",value:function(a,
b){for(var c=this,d=[],e=function(e){k=t(e,2);var f=k[0],g=k[1];e=R.map(function(d){for(var e=y.vec3.clone(c.voxelSize),k=y.vec3.fromValues(1,1,1),h=0;2>h;++h)e[d[h]]=g.resolution[d[h]],k[d[h]]=g.tileSize[d[h]];for(var h=w.ChunkLayout.get(y.vec3.multiply(y.vec3.create(),e,k)),l=y.vec3.create(),m=y.vec3.create(),n=0;3>n;++n)l[n]=Math.floor(c.voxelSize[n]/e[n]*c.lowerVoxelBound[n]),m[n]=Math.ceil(c.voxelSize[n]/e[n]*c.upperVoxelBound[n]);var q=new x.VolumeChunkSpecification(h,k,c.numChannels,c.dataType,
l,m),u={baseUrls:b.baseUrls,nodeKey:b.nodeKey,dataInstanceKey:b.dataInstanceKey,encoding:c.encoding,level:f,dims:d[0]+"_"+d[1]};return a.getChunkSource(H,A.stableStringify(u),function(){return new W(a,q,u)})});d.push(e)},f=$jscomp.makeIterator(this.levels),g=f.next();!g.done;g=f.next()){var k;e(g.value)}return d}},{key:"dataType",get:function(){return x.DataType.UINT8}},{key:"volumeType",get:function(){return x.VolumeType.IMAGE}},{key:"numChannels",get:function(){return 1}}]);return d}(f);d.TileDataInstanceInfo=
Q;d.parseDataInstance=b;var T=function aa(c){a(this,aa);this.errors=[];this.dataInstances=new Map;this.vnodes=new Set;if(c instanceof aa)this.alias=c.alias,this.description=c.description,this.errors=c.errors,this.dataInstances=c.dataInstances;else{A.verifyObject(c);this.alias=A.verifyObjectProperty(c,"Alias",A.verifyString);this.description=A.verifyObjectProperty(c,"Description",A.verifyString);for(var d=A.verifyObjectProperty(c,"DataInstances",A.verifyObject),e=Object.keys(d),f=$jscomp.makeIterator(e),
g=f.next();!g.done;g=f.next()){g=g.value;try{this.dataInstances.set(g,b(d[g],g,e))}catch(k){g="Failed to parse data instance "+JSON.stringify(g)+": "+k.message,console.log(g),this.errors.push(g)}}c=A.verifyObjectProperty(c,"DAG",A.verifyObject);c=A.verifyObjectProperty(c,"Nodes",A.verifyObject);c=$jscomp.makeIterator(Object.keys(c));for(d=c.next();!d.done;d=c.next())this.vnodes.add(d.value)}};d.RepositoryInfo=T;d.parseRepositoriesInfo=e;var X=function(){function b(c){a(this,b);this.repositories=e(c)}
q(b,[{key:"getNode",value:function(a){for(var b=[],c=$jscomp.makeIterator(this.repositories.keys()),d=c.next();!d.done;d=c.next())d=d.value,d.startsWith(a)&&b.push(d);if(1!==b.length)throw Error("Node key "+JSON.stringify(a)+" matches "+JSON.stringify(b)+" nodes.");return this.repositories.get(b[0])}}]);return b}();d.ServerInfo=X;var N=new Map;d.getServerInfo=l;var ja=function(){function b(c,d,e,f){a(this,b);this.baseUrls=c;this.nodeKey=d;this.dataInstanceKey=e;this.info=f}q(b,[{key:"getSources",
value:function(a){return this.info.getSources(a,{baseUrls:this.baseUrls,nodeKey:this.nodeKey,dataInstanceKey:this.dataInstanceKey})}},{key:"getMeshSource",value:function(a){return null}},{key:"dataType",get:function(){return this.info.dataType}},{key:"numChannels",get:function(){return this.info.numChannels}},{key:"volumeType",get:function(){return this.info.volumeType}}]);return b}();d.MultiscaleVolumeChunkSource=ja;var ca=new Map;d.getShardedVolume=r;var ya=/^((?:http|https):\/\/[^\/]+)\/([^\/]+)\/([^\/]+)$/;
d.getVolume=n;d.completeInstanceName=k;d.completeNodeAndInstance=p;d.volumeCompleter=m;h.registerDataSourceFactory("dvid",{description:"DVID",volumeCompleter:m,getVolume:n})},function(h,d){(function(d){d[d.JPEG=0]="JPEG"})(d.TileEncoding||(d.TileEncoding={}));var f=d.TileEncoding;d.volumeSourceToString=function(d){return"dvid:volume:"+d.baseUrls[0]+"/"+d.nodeKey+"/"+d.dataInstanceKey+"/"+d.level};d.tileSourceToString=function(d){return"dvid:volume:"+d.baseUrls[0]+"/"+d.nodeKey+"/"+d.dataInstanceKey+
"/"+d.dims+"/"+d.level+"/"+f[d.encoding]}},function(h,d,f){function g(c){return a.getShardedVolume(b,c)}function c(c){return a.tokenAndChannelCompleter(b,c)}h=f(17);var a=f(73),b=["http://openconnecto.me","http://www.openconnecto.me"];d.getVolume=g;d.volumeCompleter=c;h.registerDataSourceFactory("openconnectome",{description:"NDstore server hosted at openconnecto.me",getVolume:g,volumeCompleter:c})},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a,b,c,d){return a.getChunkSource(D,
JSON.stringify({baseUrls:b,path:c,lod:d}),function(){return new D(a,b,c,d)})}function e(a,c,d){c=x.parseSpecialUrl(c);c=n(c,2);return b(a,c[0],c[1],d)}function l(a,b){var c=w.stableStringify({baseUrls:a,path:b}),d=E.get(c);if(void 0!==d)return d;d=x.sendHttpRequest(x.openShardedHttpRequest(a,b+"/info"),"json").then(function(c){return new A(a,b,c)});E.set(c,d);return d}function r(a){a=x.parseSpecialUrl(a);a=n(a,2);return l(a[0],a[1])}var n=function(){return function(a,b){if(Array.isArray(a))return a;
$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var g=a[Symbol.iterator](),k;!(d=(k=g.next()).done)&&(c.push(k.value),!b||c.length!==b);d=!0);}catch(h){e=!0,f=h}finally{try{if(!d&&g["return"])g["return"]()}finally{if(e)throw f;}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance");}}(),k=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=
c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(17);var p=f(78),m=f(19),t=f(59),q=f(58),v=f(39),x=f(14),w=f(8),z=new Map;z.set("uint8",t.DataType.UINT8);z.set("uint32",t.DataType.UINT32);z.set("uint64",t.DataType.UINT64);var C=new Map;C.set("image",t.VolumeType.IMAGE);C.set("segmentation",t.VolumeType.SEGMENTATION);var u=new Map;u.set("raw",p.VolumeChunkEncoding.RAW);
u.set("jpeg",p.VolumeChunkEncoding.JPEG);u.set("compressed_segmentation",p.VolumeChunkEncoding.COMPRESSED_SEGMENTATION);var y=function(b){function d(a,b,e,f,k){g(this,d);b=c(this,Object.getPrototypeOf(d).call(this,a,b));b.baseUrls=e;b.path=f;b.encoding=k;b.initializeCounterpart(a.rpc,{type:"precomputed/VolumeChunkSource",baseUrls:e,path:f,encoding:k});return b}a(d,b);k(d,[{key:"toString",value:function(){return"precomputed:volume:"+this.baseUrls[0]+"/"+this.path}}]);return d}(q.VolumeChunkSource);
d.VolumeChunkSource=y;var B=function G(a){g(this,G);if("object"!==typeof a||Array.isArray(a))throw Error("Failed to parse volume metadata.");this.resolution=w.parseFiniteVec(v.vec3.create(),a.resolution);this.voxelOffset=w.parseIntVec(v.vec3.create(),a.voxel_offset);this.size=w.parseIntVec(v.vec3.create(),a.size);this.chunkSizes=w.parseArray(a.chunk_sizes,function(a){return w.parseFiniteVec(v.vec3.create(),a)});if(0===this.chunkSizes.length)throw Error("No chunk sizes specified.");var b=a.encoding,
c=u.get(b);if(void 0===c)throw Error("Invalid chunk encoding: "+JSON.stringify(b));this.encoding=c;c===p.VolumeChunkEncoding.COMPRESSED_SEGMENTATION&&(this.compressedSegmentationBlockSize=w.parseIntVec(v.vec3.create(),a.compressed_segmentation_block_size));this.key=a.key;if("string"!==typeof this.key)throw Error("No key specified.");},A=function(){function a(b,c,d){g(this,a);this.baseUrls=b;this.path=c;this.response=d;if("object"!==typeof d||Array.isArray(d))throw Error("Failed to parse volume metadata.");
c=d.data_type;b=z.get(c);if(void 0===b)throw Error("Invalid data type: "+JSON.stringify(c));c=d.num_channels;if("number"!==typeof c)throw Error("Invalid number of channels.");this.numChannels=c;this.dataType=b;b=d.type;c=C.get(b);if(void 0===c)throw Error("Invalid volume type: "+JSON.stringify(b));this.volumeType=c;b=d.mesh;if(void 0!==b&&"string"!==typeof b)throw Error('Invalid "mesh" field.');this.mesh=b;this.scales=w.parseArray(d.scales,function(a){return new B(a)})}k(a,[{key:"getMeshSource",value:function(a){var c=
this.mesh;return void 0===c?null:b(a,this.baseUrls,this.path+"/"+c,0)}},{key:"getSources",value:function(a){var b=this;return this.scales.map(function(c){return t.VolumeChunkSpecification.getDefaults({voxelSize:c.resolution,dataType:b.dataType,numChannels:b.numChannels,lowerVoxelBound:c.voxelOffset,upperVoxelBound:v.vec3.add(v.vec3.create(),c.voxelOffset,c.size),volumeType:b.volumeType,chunkDataSizes:c.chunkSizes,compressedSegmentationBlockSize:c.compressedSegmentationBlockSize}).map(function(d){var e=
b.path+"/"+c.key,f=w.stableStringify({spec:d,baseUrls:b.baseUrls,path:e,encoding:c.encoding});return a.getChunkSource(y,f,function(){return new y(a,d,b.baseUrls,e,c.encoding)})})})}}]);return a}();d.MultiscaleVolumeChunkSource=A;var D=function(b){function d(a,b,e,f){g(this,d);a=c(this,Object.getPrototypeOf(d).call(this,a));a.baseUrls=b;a.path=e;a.lod=f;a.initializeCounterpart(a.chunkManager.rpc,{type:"precomputed/MeshSource",baseUrls:b,path:e,lod:f});return a}a(d,b);k(d,[{key:"toString",value:function(){return"precomputed:mesh:"+
this.baseUrls[0]+"/"+this.path}}]);return d}(m.MeshSource);d.MeshSource=D;d.getShardedMeshSource=b;d.getMeshSource=e;var E=new Map;d.getShardedVolume=l;d.getVolume=r;h.registerDataSourceFactory("precomputed",{description:"Precomputed file-backed data source",getVolume:r,getMeshSource:e})},function(h,d){var f=d.VolumeChunkEncoding||(d.VolumeChunkEncoding={});f[f.RAW=0]="RAW";f[f.JPEG=1]="JPEG";f[f.COMPRESSED_SEGMENTATION=2]="COMPRESSED_SEGMENTATION"},function(h,d,f){function g(a,b){if(!(a instanceof
b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
b):a.__proto__=b)}function b(a){v.verifyObject(a);return{key:v.verifyObjectProperty(a,"key",v.verifyString),lowerVoxelBound:v.verifyObjectProperty(a,"lowerVoxelBound",function(a){return v.parseIntVec(t.vec3.create(),a)}),upperVoxelBound:v.verifyObjectProperty(a,"upperVoxelBound",function(a){return v.parseIntVec(t.vec3.create(),a)}),voxelSize:v.verifyObjectProperty(a,"voxelSize",function(a){return v.parseFixedLengthArray(t.vec3.create(),a,v.verifyFinitePositiveFloat)}),chunkDataSizes:v.verifyObjectProperty(a,
"chunkDataSizes",function(a){return void 0===a?a:v.parseArray(a,function(a){return v.parseFixedLengthArray(t.vec3.create(),a,v.verifyPositiveInt)})})}}function e(a,b){var c=v.stableStringify({baseUrls:a,key:b}),d=C.get(b);if(void 0!==d)return d;d=q.sendHttpRequest(q.openShardedHttpRequest(a,"/neuroglancer/info/"+b),"json").then(function(c){return new z(a,b,c)});C.set(c,d);return d}function l(a){var b=a.match(u);if(null===b)throw Error("Invalid python volume path: "+JSON.stringify(a));return e([b[1]],
b[2])}var r=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(17);var n=f(80),k=f(19),p=f(59),m=f(58),t=f(39),q=f(14),v=f(8),x=function(b){function d(a,b,e){g(this,d);b=c(this,Object.getPrototypeOf(d).call(this,a,b));b.parameters=e;b.initializeCounterpart(a.rpc,{type:"python/VolumeChunkSource",parameters:e});
return b}a(d,b);r(d,[{key:"toString",value:function(){return n.volumeSourceToString(this.parameters)}}]);return d}(m.VolumeChunkSource);d.VolumeChunkSource=x;var w=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this,a));e.parameters=b;e.initializeCounterpart(e.chunkManager.rpc,{type:"python/MeshSource",parameters:b});return e}a(d,b);r(d,[{key:"toString",value:function(){return n.meshSourceToString(this.parameters)}}]);return d}(k.MeshSource);d.MeshSource=w;var z=
function(){function a(c,d,e){g(this,a);this.baseUrls=c;this.key=d;this.response=e;v.verifyObject(e);this.dataType=v.verifyObjectProperty(e,"dataType",function(a){return v.verifyEnumString(a,p.DataType)});this.volumeType=v.verifyObjectProperty(e,"volumeType",function(a){return v.verifyEnumString(a,p.VolumeType)});this.numChannels=v.verifyObjectProperty(e,"numChannels",v.verifyPositiveInt);this.encoding=v.verifyObjectProperty(e,"encoding",function(a){return v.verifyEnumString(a,n.VolumeChunkEncoding)});
this.scales=v.verifyObjectProperty(e,"scales",function(a){return v.parseArray(a,b)})}r(a,[{key:"getSources",value:function(a){var b=this,c=this.numChannels,d=this.dataType,e=this.volumeType,f=this.encoding;return this.scales.map(function(g){return p.VolumeChunkSpecification.getDefaults({voxelSize:g.voxelSize,dataType:d,volumeType:e,numChannels:c,lowerVoxelBound:g.lowerVoxelBound,upperVoxelBound:g.upperVoxelBound,chunkDataSizes:g.chunkDataSizes}).map(function(c){var d={baseUrls:b.baseUrls,key:g.key,
encoding:f};return a.getChunkSource(x,v.stableStringify(d),function(){return new x(a,c,d)})})})}},{key:"getMeshSource",value:function(a){var b={baseUrls:this.baseUrls,key:this.key};return a.getChunkSource(w,v.stableStringify(b),function(){return new w(a,b)})}}]);return a}();d.MultiscaleVolumeChunkSource=z;var C=new Map;d.getShardedVolume=e;var u=/^((?:http|https):\/\/[^\/?]+)\/(.*)$/;d.getVolume=l;h.registerDataSourceFactory("python",{description:"Python-served volume",getVolume:l})},function(h,d){(function(d){d[d.JPEG=
0]="JPEG";d[d.NPZ=1]="NPZ";d[d.RAW=2]="RAW"})(d.VolumeChunkEncoding||(d.VolumeChunkEncoding={}));var f=d.VolumeChunkEncoding;d.volumeSourceToString=function(d){return"python:volume:"+d.baseUrls[0]+"/"+d.key+"/"+f[d.encoding]};d.meshSourceToString=function(d){return"python:mesh:"+d.baseUrls[0]+"/"+d.key}},function(h,d,f){var g=f(82),c=f(83);window.addEventListener("DOMContentLoaded",function(){var a=window.viewer=c.makeDefaultViewer();g.makeDefaultKeyBindings(a.keyMap)})},function(h,d){d.makeDefaultKeyBindings=
function(d){d.bind("arrowleft","x-");d.bind("arrowright","x+");d.bind("arrowup","y-");d.bind("arrowdown","y+");d.bind("comma","z-");d.bind("period","z+");d.bind("keyz","snap");d.bind("control+equal","zoom-in");d.bind("control+shift+equal","zoom-in");d.bind("control+minus","zoom-out");d.bind("keyr","rotate-relative-z-");d.bind("keye","rotate-relative-z+");d.bind("shift+arrowdown","rotate-relative-x-");d.bind("shift+arrowup","rotate-relative-x+");d.bind("shift+arrowleft","rotate-relative-y-");d.bind("shift+arrowright",
"rotate-relative-y+");d.bind("keyl","recolor");d.bind("keyx","clear-segments");d.bind("keys","toggle-show-slices");d.bind("keyb","toggle-scale-bar");d.bind("keya","toggle-axis-lines");for(var g=1;9>=g;++g)d.bind("digit"+g,"toggle-layer-"+g);d.bind("keyn","add-layer");d.bind("keyh","help");d.bind("space","toggle-layout")}},function(h,d,f){f(84);f(85);var g=f(54),c=f(93);d.makeDefaultViewer=function(){var a=new g.DisplayContext(document.getElementById("container"));return new c.Viewer(a)}},function(h,
d){},function(h,d,f){f(86);f(89)},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,
enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function C(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),null===a?void 0:C(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=
!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),l=f(59);h=f(58);var r=f(87),n=f(12),k=f(39),p=f(51),m=f(88),t=f(70),q=function(b){function d(a,b,e,f){g(this,d);var k=c(this,Object.getPrototypeOf(d).call(this));k.chunkDataSize=b;k.channelStride=b[0]*b[1]*b[2];m.compute3dTextureLayout(k,a,e,b[0],b[1],b[2]*f);return k}a(d,b);e(d,null,[{key:"get",value:function(a,b,c,e){return a.memoize.get("sliceview.UncompressedTextureLayout:"+k.vec3Key(b)+","+
c+","+e,function(){return new d(a,b,c,e)})}}]);return d}(n.RefCounted),v=function(d){function f(a,b,d,e){g(this,f);e=c(this,Object.getPrototypeOf(f).call(this,e));e.dataType=b;e.numChannels=d;switch(b){case l.DataType.UINT8:e.texelsPerElement=1;e.textureFormat=a.LUMINANCE;e.texelType=a.UNSIGNED_BYTE;e.arrayElementsPerTexel=1;e.arrayConstructor=Uint8Array;break;case l.DataType.UINT16:e.texelsPerElement=1;e.textureFormat=a.LUMINANCE_ALPHA;e.texelType=a.UNSIGNED_BYTE;e.arrayElementsPerTexel=2;e.arrayConstructor=
Uint8Array;break;case l.DataType.UINT64:e.texelsPerElement=2;e.textureFormat=a.RGBA;e.texelType=a.UNSIGNED_BYTE;e.arrayElementsPerTexel=4;e.arrayConstructor=Uint8Array;break;case l.DataType.UINT32:e.texelsPerElement=1;e.textureFormat=a.RGBA;e.texelType=a.UNSIGNED_BYTE;e.arrayElementsPerTexel=4;e.arrayConstructor=Uint8Array;break;case l.DataType.FLOAT32:e.texelsPerElement=1;e.textureFormat=a.LUMINANCE;e.texelType=a.FLOAT;e.arrayElementsPerTexel=1;e.arrayConstructor=Float32Array;break;default:throw Error("Unsupported dataType: "+
b);}e.textureAccessHelper=new m.OneDimensionalTextureAccessHelper("chunkData",e.texelsPerElement);return e}a(f,d);e(f,[{key:"defineShader",value:function(a){b(Object.getPrototypeOf(f.prototype),"defineShader",this).call(this,a);this.textureAccessHelper.defineShader(a);1<this.numChannels?(a.addUniform("highp float","uChannelStride"),a.addFragmentCode("\nfloat getChannelOffset(int channelIndex) {\n  return float(channelIndex) * uChannelStride;\n}\n")):a.addFragmentCode("float getChannelOffset(int channelIndex) { return 0.0; }");
a.addFragmentCode("\nfloat getIndexIntoChunk (int channelIndex) {\n  vec3 chunkDataPosition = getPositionWithinChunk();\n  return chunkDataPosition.x + uChunkDataSize.x * (chunkDataPosition.y + uChunkDataSize.y * chunkDataPosition.z) + getChannelOffset(channelIndex);\n}\n");switch(this.dataType){case l.DataType.UINT8:a.addFragmentCode(t.glsl_uint8);a.addFragmentCode("\nuint8_t getDataValue (int channelIndex) {\n  uint8_t result;\n  vec4 temp;\n  "+this.textureAccessHelper.readTextureValue+"(uVolumeChunkSampler, getIndexIntoChunk(channelIndex), temp);\n  result.value = temp.x;\n  return result;\n}\n");
break;case l.DataType.FLOAT32:a.addFragmentCode(t.glsl_float);a.addFragmentCode("\nfloat getDataValue (int channelIndex) {\n  vec4 temp;\n  "+this.textureAccessHelper.readTextureValue+"(uVolumeChunkSampler, getIndexIntoChunk(channelIndex), temp);\n  return temp.x;\n}\n");break;case l.DataType.UINT16:a.addFragmentCode(t.glsl_uint16);a.addFragmentCode("\nuint16_t getDataValue (int channelIndex) {\n  uint16_t result;\n  vec4 temp;\n  "+this.textureAccessHelper.readTextureValue+"(uVolumeChunkSampler, getIndexIntoChunk(channelIndex), temp);\n  result.value = temp.xw;\n  return result;\n}\n");
break;case l.DataType.UINT32:a.addFragmentCode(t.glsl_uint32);a.addFragmentCode("\nuint32_t getDataValue (int channelIndex) {\n  uint32_t result;\n  "+this.textureAccessHelper.readTextureValue+"(uVolumeChunkSampler, getIndexIntoChunk(channelIndex), result.value);\n  return result;\n}\n");break;case l.DataType.UINT64:a.addFragmentCode(t.glsl_uint64),a.addFragmentCode("\nuint64_t getDataValue (int channelIndex) {\n  uint64_t result;\n  "+this.textureAccessHelper.readTextureValue+"(uVolumeChunkSampler, getIndexIntoChunk(channelIndex), result.low, result.high);\n  return result;\n}\n")}}},
{key:"setupTextureLayout",value:function(a,b,c){1<this.numChannels&&a.uniform1f(b.uniform("uChannelStride"),c.channelStride);this.textureAccessHelper.setupTextureLayout(a,b,c)}},{key:"getTextureLayout",value:function(a,b){return q.get(a,b,this.texelsPerElement,this.numChannels)}},{key:"setTextureData",value:function(a,b,c){m.setOneDimensionalTextureData(a,b,c,this.arrayElementsPerTexel,this.textureFormat,this.texelType,this.arrayConstructor)}}],[{key:"get",value:function(a,b,c){var d="sliceview.UncompressedChunkFormat:"+
b+":"+c;return a.memoize.get(d,function(){return new f(a,b,c,d)})}}]);return f}(r.SingleTextureChunkFormat);d.ChunkFormat=v;var x=function(b){function d(){g(this,d);return c(this,Object.getPrototypeOf(d).apply(this,arguments))}a(d,b);e(d,[{key:"setTextureData",value:function(a){var b=this.source,c=b.chunkFormatHandler,d=c.chunkFormat,e=void 0;this.textureLayout=this.chunkDataSize===b.spec.chunkDataSize?e=c.textureLayout.addRef():e=d.getTextureLayout(a,this.chunkDataSize);this.chunkFormat.setTextureData(a,
e,this.data)}},{key:"getChannelValueAt",value:function(a,b){var c=this.chunkDataSize,d=a[0]+c[0]*(a[1]+c[1]*(a[2]+c[2]*b)),e=this.chunkFormat.dataType,c=this.data;switch(e){case l.DataType.UINT8:case l.DataType.FLOAT32:case l.DataType.UINT16:case l.DataType.UINT32:return c[d];case l.DataType.UINT64:return d*=2,new p.Uint64(c[d],c[d+1])}throw Error("Invalid data type: "+e);}}]);return d}(r.SingleTextureVolumeChunk);d.UncompressedVolumeChunk=x;var w=function(b){function d(a,b){g(this,d);var e=c(this,
Object.getPrototypeOf(d).call(this));e.chunkFormat=e.registerDisposer(v.get(a,b.dataType,b.numChannels));e.textureLayout=e.registerDisposer(e.chunkFormat.getTextureLayout(a,b.chunkDataSize));return e}a(d,b);e(d,[{key:"getChunk",value:function(a,b){return new x(a,b)}}]);return d}(n.RefCounted);d.UncompressedChunkFormatHandler=w;h.registerChunkFormatHandler(function(a,b){return null==b.compressedSegmentationBlockSize?new w(a,b):null})},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function m(a,
b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),null===a?void 0:m(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(58);var l=f(12),r=f(67);
$jscomp.initSymbol();var n=Symbol("SingleTextureVolumeChunk.textureUnit");$jscomp.initSymbol();var k=Symbol("SingleTextureVolumeChunk.textureLayout");d.glsl_getPositionWithinChunk="\nvec3 getPositionWithinChunk () {\n  return floor(min(vChunkPosition * uChunkDataSize, uChunkDataSize - 1.0));\n}\n";f=function(b){function f(a){g(this,f);var b=c(this,Object.getPrototypeOf(f).call(this));b.shaderKey=a;return b}a(f,b);e(f,[{key:"defineShader",value:function(a){a.addTextureSampler2D("uVolumeChunkSampler",
n);a.addUniform("highp vec3","uChunkDataSize");a.addFragmentCode(d.glsl_getPositionWithinChunk)}},{key:"beginDrawing",value:function(a,b){var c=b.textureUnit(n);a.activeTexture(a.TEXTURE0+c);b[k]=null}},{key:"endDrawing",value:function(a,b){a.bindTexture(a.TEXTURE_2D,null);b[k]=null}},{key:"bindChunk",value:function(a,b,c){var d=c.textureLayout;b[k]!==d&&(b[k]=d,this.setupTextureLayout(a,b,d),a.uniform3fv(b.uniform("uChunkDataSize"),c.chunkDataSize));a.bindTexture(a.TEXTURE_2D,c.texture)}}]);return f}(l.RefCounted);
d.SingleTextureChunkFormat=f;f=function(d){function f(a,b){g(this,f);var d=c(this,Object.getPrototypeOf(f).call(this,a,b));d.texture=null;d.data=b.data;return d}a(f,d);e(f,[{key:"copyToGPU",value:function(a){b(Object.getPrototypeOf(f.prototype),"copyToGPU",this).call(this,a);var c=this.texture=a.createTexture();a.bindTexture(a.TEXTURE_2D,c);a.pixelStorei(a.UNPACK_ALIGNMENT,1);r.setRawTextureParameters(a);this.setTextureData(a);a.bindTexture(a.TEXTURE_2D,null)}},{key:"freeGPUMemory",value:function(a){b(Object.getPrototypeOf(f.prototype),
"freeGPUMemory",this).call(this,a);a.deleteTexture(this.texture);this.texture=null;this.textureLayout.dispose();this.textureLayout=null}}]);return f}(h.VolumeChunk);d.SingleTextureVolumeChunk=f},function(h,d,f){var g=function(){function a(a,c){for(var d=0;d<c.length;d++){var f=c[d];f.enumerable=f.enumerable||!1;f.configurable=!0;"value"in f&&(f.writable=!0);Object.defineProperty(a,f.key,f)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),c=f(61);d.compute3dTextureLayout=function(a,
b,c,d,f,g){var k=b.maxTextureSize;b=void 0;var h=d*f*g;if(c*d<=k&&f*g<=k)b=d;else if(c*d*f<=k&&g<=k)b=d*f;else if(b=Math.ceil(h/k),b*c>k)throw Error("Chunk data size exceeds maximum texture size: "+c+" * "+h);d=Math.ceil(h/b);a.textureWidth=b*c;a.textureHeight=d;a.textureAccessCoefficients=Float32Array.of(1/b,1/(b*d))};d.compute1dTextureLayout=function(a,b,c,d){var f=b.maxTextureSize;b=Math.ceil(d/f);if(b*c>f)throw Error("Number of elements exceeds maximum texture size: "+c+" * "+d);d=Math.ceil(d/
b);a.textureWidth=b*c;a.textureHeight=d;a.textureAccessCoefficients=Float32Array.of(1/b,1/(b*d))};d.setOneDimensionalTextureData=function(a,b,d,f,g,h,k){f*=b.textureWidth*b.textureHeight;d.constructor!==k&&(d=new k(d.buffer,d.byteOffset,d.byteLength/k.BYTES_PER_ELEMENT));d=c.maybePadArray(d,f);a.texImage2D(a.TEXTURE_2D,0,g,b.textureWidth,b.textureHeight,0,g,h,d)};h=function(){function a(b,c){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.key=b;this.texelsPerElement=
c;this.uniformName="uTextureAccessCoefficients_"+this.key;this.readTextureValue="readTextureValue_"+this.key}g(a,[{key:"defineShader",value:function(a){var c=this.texelsPerElement,d=this.uniformName;a.addUniform("highp vec2",d);for(var f="\nvoid "+this.readTextureValue+"(highp sampler2D sampler, float index",g=0;g<c;++g)f+=", out vec4 output"+g;f+=") {\n  index += "+.5/this.texelsPerElement+";\n  vec2 texCoords = vec2(fract(index * "+d+".x),\n                        index * "+d+".y);\n";for(g=0;g<
c;++g)f+="\n  output"+g+" = texture2D(sampler, vec2(texCoords.x + "+d+".x * "+(g/c).toFixed(8)+", texCoords.y));\n";a.addFragmentCode(f+"\n}\n")}},{key:"setupTextureLayout",value:function(a,c,d){a.uniform2fv(c.uniform(this.uniformName),d.textureAccessCoefficients)}}]);return a}();d.OneDimensionalTextureAccessHelper=h},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function B(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),
null===a?void 0:B(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),l=f(59),r=f(90),n=f(92);h=f(58);var k=f(64),p=f(87),m=f(12),t=f(39),q=f(51),v=f(88),x=f(70),w=function(b){function d(a,b,e,f){g(this,d);var k=c(this,Object.getPrototypeOf(d).call(this));
k.chunkDataSize=b;k.subchunkSize=e;v.compute1dTextureLayout(k,a,1,f);a=k.subchunkGridSize=t.vec3.create();for(f=0;3>f;++f)a[f]=Math.ceil(b[f]/e[f]);return k}a(d,b);e(d,null,[{key:"get",value:function(a,b,c,e){return a.memoize.get("sliceview.CompressedSegmentationTextureLayout:"+t.vec3Key(b)+","+t.vec3Key(c)+","+e,function(){return new d(a,b,c,e)})}}]);return d}(m.RefCounted),z=function(d){function f(a,b,d,e){g(this,f);e=c(this,Object.getPrototypeOf(f).call(this,e));e.dataType=a;e.subchunkSize=b;e.numChannels=
d;e.textureAccessHelper=new v.OneDimensionalTextureAccessHelper("chunkData",1);return e}a(f,d);e(f,[{key:"defineShader",value:function(a){b(Object.getPrototypeOf(f.prototype),"defineShader",this).call(this,a);this.textureAccessHelper.defineShader(a);var c=function(a){return"compressedSegmentationChunkFormat_"+a};a.addUniform("highp vec3","uSubchunkGridSize");a.addFragmentCode(x.glsl_getFortranOrderIndexFromNormalized);var d=this.dataType,e=k.GLSL_TYPE_FOR_DATA_TYPE.get(d);d===l.DataType.UINT64?a.addFragmentCode(x.glsl_uint64):
a.addFragmentCode(x.glsl_uint32);e="\nvec4 "+c("readTextureValue")+"(float offset) {\n  vec4 result;\n  "+this.textureAccessHelper.readTextureValue+"(uVolumeChunkSampler, offset, result);\n  return result;\n}\nfloat "+c("getChannelOffset")+"(int channelIndex) {\n  if (channelIndex == 0) {\n    return "+this.numChannels+".0;\n  }\n  vec4 v = "+c("readTextureValue")+"(float(channelIndex));\n  return v.x * 255.0 + v.y * 255.0 * 256.0 + v.z * 255.0 * 256.0 * 256.0;\n}\n"+e+" getDataValue (int channelIndex) {\n  const vec3 uSubchunkSize = "+
t.vec3.str(this.subchunkSize)+";\n\n  vec3 chunkPosition = getPositionWithinChunk();\n\n  // TODO: maybe premultiply this and store as uniform.\n  vec3 subchunkGridPosition = floor(chunkPosition / uSubchunkSize);\n  float subchunkGridOffset = getFortranOrderIndex(subchunkGridPosition, uSubchunkGridSize);\n\n  float channelOffset = "+c("getChannelOffset")+"(channelIndex);\n\n  // TODO: Maybe just combine this offset into subchunkGridStrides.\n  float subchunkHeaderOffset = subchunkGridOffset * 2.0 + channelOffset;\n\n  vec4 subchunkHeader0 = "+
c("readTextureValue")+"(subchunkHeaderOffset);\n  vec4 subchunkHeader1 = "+c("readTextureValue")+"(subchunkHeaderOffset + 1.0);\n\n  float outputValueOffset = dot(subchunkHeader0.xyz, vec3(255, 256 * 255, 256 * 256 * 255)) + channelOffset;\n  float encodingBits = subchunkHeader0[3] * 255.0;\n  if (encodingBits > 0.0) {\n    vec3 subchunkPosition = floor(min(chunkPosition - subchunkGridPosition * uSubchunkSize, uSubchunkSize - 1.0));\n    float subchunkOffset = getFortranOrderIndex(subchunkPosition, uSubchunkSize);\n    highp float encodedValueBaseOffset = dot(subchunkHeader1.xyz, vec3(255.0, 256.0 * 255.0, 256.0 * 256.0 * 255.0)) + channelOffset;\n    highp float encodedValueOffset = floor(encodedValueBaseOffset + subchunkOffset * encodingBits / 32.0);\n    vec4 encodedValue = "+
c("readTextureValue")+"(encodedValueOffset);\n    float wordOffset = mod(subchunkOffset * encodingBits, 32.0);\n    // If the value is in the first byte, then 0 <= wordOffset < 8.\n    // We need to mod by 2**encodedBits\n    float wordShifter = pow(2.0, -wordOffset);\n    float encodedValueMod = pow(2.0, encodingBits);\n    float encodedValueShifted;\n    if (wordOffset < 16.0) {\n      encodedValueShifted = dot(encodedValue.xy, vec2(255.0, 255.0 * 256.0));\n    } else {\n      encodedValueShifted = dot(encodedValue.zw, vec2(255.0 * 256.0 * 256.0, 255.0 * 256.0 * 256.0 * 256.0));\n    }\n    encodedValueShifted = floor(encodedValueShifted * wordShifter);\n    float decodedValue = mod(encodedValueShifted, encodedValueMod);\n    outputValueOffset += decodedValue * "+
(this.dataType===l.DataType.UINT64?"2.0":"1.0")+";\n  }\n  "+e+" result;\n";e=d===l.DataType.UINT64?e+("\n  result.low = "+c("readTextureValue")+"(outputValueOffset);\n  result.high = "+c("readTextureValue")+"(outputValueOffset+1.0);\n"):e+("\n  result.value = "+c("readTextureValue")+"(outputValueOffset);\n");a.addFragmentCode(e+"\n  return result;\n}\n")}},{key:"setupTextureLayout",value:function(a,b,c){a.uniform3fv(b.uniform("uSubchunkGridSize"),c.subchunkGridSize);this.textureAccessHelper.setupTextureLayout(a,
b,c)}},{key:"setTextureData",value:function(a,b,c){v.setOneDimensionalTextureData(a,b,c,4,a.RGBA,a.UNSIGNED_BYTE,Uint8Array)}},{key:"getTextureLayout",value:function(a,b,c){return w.get(a,b,this.subchunkSize,c)}}],[{key:"get",value:function(a,b,c,d){var e="sliceview.CompressedSegmentationChunkFormat:"+b+":"+t.vec3Key(c)+":"+d;return a.memoize.get(e,function(){return new f(b,c,d,e)})}}]);return f}(p.SingleTextureChunkFormat);d.ChunkFormat=z;var C=function(b){function d(){g(this,d);return c(this,Object.getPrototypeOf(d).apply(this,
arguments))}a(d,b);e(d,[{key:"setTextureData",value:function(a){var b=this.data,c=this.chunkFormat,d=this.textureLayout=c.getTextureLayout(a,this.chunkDataSize,b.length);c.setTextureData(a,d,b)}},{key:"getChannelValueAt",value:function(a,b){var c=this.chunkDataSize,d=this.chunkFormat,e=this.data,f=e[b];if(d.dataType===l.DataType.UINT64){var g=new q.Uint64;n.readSingleChannelValue(g,e,f,c,d.subchunkSize,a);return g}return r.readSingleChannelValue(e,f,c,d.subchunkSize,a)}}]);return d}(p.SingleTextureVolumeChunk);
d.CompressedSegmentationVolumeChunk=C;var u=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this)),f=b.dataType;if(f!==l.DataType.UINT64&&f!==l.DataType.UINT32)throw Error("Unsupported compressed segmentation data type: "+l.DataType[f]);e.chunkFormat=e.registerDisposer(z.get(a,b.dataType,b.compressedSegmentationBlockSize,b.numChannels));return e}a(d,b);e(d,[{key:"getChunk",value:function(a,b){return new C(a,b)}}]);return d}(m.RefCounted);d.CompressedSegmentationChunkFormatHandler=
u;h.registerChunkFormatHandler(function(a,b){return null!=b.compressedSegmentationBlockSize?new u(a,b):null})},function(h,d,f){function g(b,c,d,f,g){c=a.decodeValueOffset(b,c,d,f,g,1)+c;return b[c]}function c(b,c,d,f,g){var k=f[0]*f[1]*f[2]*1;if(k!==b.length)throw Error("Output length "+b.length+" is not equal to expected length "+k+".");for(var k=f[0],h=f[1],m=f[2],t=[0,0,0],q=0,v=0;v<m;++v){t[2]=v;for(var x=0;x<h;++x){t[1]=x;for(var w=0;w<k;++w){t[0]=w;var z=a.decodeValueOffset(c,d,f,g,t,1)+d;b[q++]=
c[z]}}}return b}var a=f(91);d.readSingleChannelValue=g;d.readValue=function(a,c,d,f,h){return g(a,c+a[h[3]],d,f,h)};d.decodeChannel=c;d.decodeChannels=function(a,d,f,g,h){var k=g[0]*g[1]*g[2]*1,p=k*g[3];if(p!==a.length)throw Error("Output length "+a.length+" is not equal to expected length "+p+".");for(var p=g[3],m=0;m<p;++m)c(a.subarray(k*m,k*(m+1)),d,f+d[m],g,h);return a}},function(h,d){d.decodeValueOffset=function(d,g,c,a,b,e){for(var h=0,r=0,n=1,k=1,p=0;3>p;++p)var m=b[p],t=a[p],q=m%t,h=h+Math.floor(m/
t)*n,n=n*Math.ceil(c[p]/t),r=r+q*k,k=k*t;a=g+2*h;c=d[a];a=d[a+1];b=c&16777215;c=c>>24&255;0<c&&(b+=e*(d[(g+a&16777215)+Math.floor(r*c/32)]>>r*c%32&(1<<c)-1));return b}},function(h,d,f){function g(b,c,d,f,g,k){d=a.decodeValueOffset(c,d,f,g,k,2)+d;b.low=c[d];b.high=c[d+1];return b}function c(b,c,d,f,g){var k=f[0]*f[1]*f[2]*2;if(k!==b.length)throw Error("Output length "+b.length+" is not equal to expected length "+k+".");for(var k=f[0],h=f[1],m=f[2],t=[0,0,0],q=0,v=0;v<m;++v){t[2]=v;for(var x=0;x<h;++x){t[1]=
x;for(var w=0;w<k;++w){t[0]=w;var z=a.decodeValueOffset(c,d,f,g,t,2)+d;b[q++]=c[z];b[q++]=c[z+1]}}}return b}var a=f(91);d.readSingleChannelValue=g;d.readValue=function(a,c,d,f,h,k){return g(a,c,d+c[k[3]],f,h,k)};d.decodeChannel=c;d.decodeChannels=function(a,d,f,g,h){var k=g[0]*g[1]*g[2]*2,p=k*g[3];if(p!==a.length)throw Error("Output length "+a.length+" is not equal to expected length "+p+".");for(var p=g[3],m=0;m<p;++m)c(a.subarray(k*m,k*(m+1)),d,f+d[m],g,h);return a}},function(h,d,f){function g(a,
b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?
Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a){var b=d.LAYOUTS.find(function(b){return b[0]===a});if(void 0===b)throw Error("Invalid layout name: "+JSON.stringify(a)+".");return b}function e(a){return b(a)[0]}var l=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),r=f(20),n=f(21),k=f(94),p=f(30),m=
f(99),t=f(140),q=f(100),v=f(143),x=f(144),w=f(95),z=f(24),C=f(145),u=f(58),y=f(122),B=f(68),A=f(65),D=f(147);h=f(12);var E=f(7),H=f(39),G=f(96),P=f(11),R=f(23);f(148);f(111);f(71);var W=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this));e.rootElement=a;e.viewer=b;var f=b.makeOrthogonalSliceViews(),k=b.display,h={mouseState:b.mouseState,layerManager:b.layerManager,navigationState:b.perspectiveNavigationState,showSliceViews:b.showPerspectiveSliceViews,showAxisLines:b.showAxisLines},
l={mouseState:b.mouseState,layerManager:b.layerManager,navigationState:b.navigationState,showAxisLines:b.showAxisLines,showScaleBar:b.showScaleBar},m={mouseState:b.mouseState,layerManager:b.layerManager,navigationState:b.navigationState,showAxisLines:b.showAxisLines,showScaleBar:new B.TrackableBoolean(!1,!1)},n=[v.withFlex(1,v.box("column",[v.withFlex(1,v.box("row",[v.withFlex(1,function(a){a.className="gllayoutcell noselect";e.registerDisposer(new y.SliceViewPanel(k,a,f[0],l))}),v.withFlex(1,function(a){a.className=
"gllayoutcell noselect";e.registerDisposer(new y.SliceViewPanel(k,a,f[1],m))})])),v.withFlex(1,v.box("row",[v.withFlex(1,function(a){a.className="gllayoutcell noselect";a=e.registerDisposer(new z.PerspectivePanel(k,a,h));for(var b=$jscomp.makeIterator(f),c=b.next();!c.done;c=b.next())a.sliceViews.add(c.value.addRef())}),v.withFlex(1,function(a){a.className="gllayoutcell noselect";e.registerDisposer(new y.SliceViewPanel(k,a,f[2],m))})]))]))];v.box("row",n)(a);k.onResize();return e}a(d,b);l(d,[{key:"disposed",
value:function(){E.removeChildren(this.rootElement)}}]);return d}(h.RefCounted);d.FourPanelLayout=W;var Q=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this));e.rootElement=a;e.viewer=b;var f=b.makeSliceView(),k={mouseState:b.mouseState,layerManager:b.layerManager,navigationState:b.navigationState,showAxisLines:b.showAxisLines,showScaleBar:b.showScaleBar};v.box("row",[v.withFlex(1,function(a){e.registerDisposer(new y.SliceViewPanel(b.display,a,f,k))})])(a);b.display.onResize();
return e}a(d,b);l(d,[{key:"disposed",value:function(){E.removeChildren(this.rootElement)}}]);return d}(h.RefCounted);d.SinglePanelLayout=Q;d.LAYOUTS=[["4panel",function(a,b){return new W(a,b)}],["xy",function(a,b){return new Q(a,b)}]];d.getLayoutByName=b;d.validateLayoutName=e;f=function(f){function h(a){g(this,h);var b=c(this,Object.getPrototypeOf(h).call(this));b.display=a;b.navigationState=b.registerDisposer(new x.NavigationState);b.perspectiveNavigationState=new x.NavigationState(new x.Pose(b.navigationState.position),
1);b.mouseState=new p.MouseSelectionState;b.layerManager=b.registerDisposer(new p.LayerManager);b.showAxisLines=new B.TrackableBoolean(!0,!0);b.showScaleBar=new B.TrackableBoolean(!0,!0);b.showPerspectiveSliceViews=new B.TrackableBoolean(!0,!0);b.layerSelectedValues=b.registerDisposer(new p.LayerSelectedValues(b.layerManager,b.mouseState));b.worker=new P.RPC(new Worker("chunk_worker.bundle.js"));b.resetInitiated=new R.Signal;b.chunkQueueManager=new n.ChunkQueueManager(b.worker,b.display.gl,{gpuMemory:new r.AvailableCapacity(1E6,
1E9),systemMemory:new r.AvailableCapacity(1E7,2E9),download:new r.AvailableCapacity(32,Number.POSITIVE_INFINITY)});b.chunkManager=new n.ChunkManager(b.chunkQueueManager);b.keyMap=new G.KeySequenceMap;b.keyCommands=new Map;b.layerSpecification=new q.LayerListSpecification(b.layerManager,b.chunkManager,b.worker,b.layerSelectedValues,b.navigationState.voxelSize);b.layoutName=new A.TrackableValue(d.LAYOUTS[0][0],e);b.registerSignalBinding(a.updateStarted.add(b.onUpdateDisplay,b));b.registerSignalBinding(a.updateFinished.add(b.onUpdateDisplayFinished,
b));b.registerEventListener(document,"contextmenu",function(a){a.preventDefault();return!1});D.registerTrackable("layers",b.layerSpecification);D.registerTrackable("navigation",b.navigationState);D.registerTrackable("showAxisLines",b.showAxisLines);D.registerTrackable("showScaleBar",b.showScaleBar);D.registerTrackable("perspectiveOrientation",b.perspectiveNavigationState.pose.orientation);D.registerTrackable("perspectiveZoom",b.perspectiveNavigationState.zoomFactor);D.registerTrackable("showSlices",
b.showPerspectiveSliceViews);D.registerTrackable("layout",b.layoutName);b.registerSignalBinding(b.navigationState.changed.add(b.handleNavigationStateChanged,b));b.layerManager.initializePosition(b.navigationState.position);b.layerManager.layersChanged.add(function(){0===b.layerManager.managedLayers.length&&(b.navigationState.voxelSize.reset(),b.navigationState.reset(),b.perspectiveNavigationState.pose.orientation.reset(),b.perspectiveNavigationState.zoomFactor.reset(),b.resetInitiated.dispatch(),
b.layerManager.initializePosition(b.navigationState.position),w.overlaysOpen||new m.LayerDialog(b.layerSpecification))});b.registerSignalBinding(b.chunkQueueManager.visibleChunksChanged.add(function(){b.layerSelectedValues.handleLayerChange()}));b.chunkQueueManager.visibleChunksChanged.add(a.scheduleRedraw,a);b.makeUI();b.registerDisposer(new G.GlobalKeyboardShortcutHandler(b.keyMap,b.onKeyCommand.bind(b)));b.layoutName.changed.add(function(){if(void 0!==b.dataDisplayLayout){var a=b.dataDisplayLayout.rootElement;
b.dataDisplayLayout.dispose();b.createDataDisplayLayout(a)}});var f=b.keyCommands;f.set("toggle-layout",function(){this.toggleLayout()});f.set("snap",function(){this.navigationState.pose.snap()});f.set("add-layer",function(){this.layerPanel.addLayerMenu();return!0});f.set("help",b.showHelpDialog);a=function(a){f.set("toggle-layer-"+a,function(){var b=a-1,c=this.layerManager.managedLayers;b<c.length&&(b=c[b],b.setVisible(!b.visible))})};for(var k=1;9>=k;++k)a(k);a=function(a){f.set(a,function(){this.layerManager.invokeAction(a)})};
for(var k=$jscomp.makeIterator(["recolor","clear-segments"]),l=k.next();!l.done;l=k.next())a(l.value);f.set("toggle-axis-lines",function(){this.showAxisLines.toggle()});f.set("toggle-scale-bar",function(){this.showScaleBar.toggle()});b.keyCommands.set("toggle-show-slices",function(){this.showPerspectiveSliceViews.toggle()});0===b.layerManager.managedLayers.length&&new m.LayerDialog(b.layerSpecification);return b}a(h,f);l(h,[{key:"makeUI",value:function(){var a=this,b=this.display,c=document.createElement("div");
c.setAttribute("class","gllayoutcontainer noselect");b.container.appendChild(c);v.box("column",[v.box("row",[v.withFlex(1,function(b){return new C.PositionStatusPanel(b,a)}),function(b){var c=document.createElement("button");c.className="help-button";c.textContent="?";c.title="Help";b.appendChild(c);a.registerEventListener(c,"click",function(){a.showHelpDialog()})}]),function(b){a.layerPanel=new t.LayerPanel(b,a.layerSpecification)},v.withFlex(1,function(b){a.createDataDisplayLayout(b)})])(c);this.display.onResize()}},
{key:"createDataDisplayLayout",value:function(a){this.dataDisplayLayout=(0,b(this.layoutName.value)[1])(a,this)}},{key:"toggleLayout",value:function(){var a=b(this.layoutName.value),a=d.LAYOUTS.indexOf(a);this.layoutName.value=d.LAYOUTS[(a+1)%d.LAYOUTS.length][0]}},{key:"showHelpDialog",value:function(){new k.KeyBindingHelpDialog(this.keyMap)}},{key:"onUpdateDisplay",value:function(){D.delayHashUpdate();this.chunkQueueManager.chunkUpdateDeadline=null}},{key:"onUpdateDisplayFinished",value:function(){this.mouseState.updateIfStale()}},
{key:"onKeyCommand",value:function(a){var b=this.keyCommands.get(a);return b&&b.call(this)?!0:(b=this.display.activePanel)?b.onKeyCommand(a):!1}},{key:"makeSliceView",value:function(a){var b=void 0,b=void 0===a?this.navigationState:new x.NavigationState(new x.Pose(this.navigationState.pose.position,x.OrientationState.makeRelative(this.navigationState.pose.orientation,a)),this.navigationState.zoomFactor);return new u.SliceView(this.gl,this.chunkManager,this.layerManager,b)}},{key:"makeOrthogonalSliceViews",
value:function(){var a=[];a.push(this.makeSliceView(void 0));var b=H.quat.rotateX(H.quat.create(),H.quat.create(),Math.PI/2);a.push(this.makeSliceView(b));b=H.quat.rotateY(H.quat.create(),H.quat.create(),Math.PI/2);a.push(this.makeSliceView(b));return a}},{key:"handleNavigationStateChanged",value:function(){var a=this.chunkQueueManager;null===a.chunkUpdateDeadline&&(a.chunkUpdateDeadline=Date.now()+10);this.mouseState.stale=!0}},{key:"gl",get:function(){return this.display.gl}}]);return h}(h.RefCounted);
d.Viewer=f},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function c(a){return a.startsWith("key")?a.substring(3):a.startsWith("digit")||a.startsWith("arrow")?a.substring(5):a}function a(a){return a.split("+").map(c).join("+")}
var b=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var c=[],d=!0,f=!1,g=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var h=a[Symbol.iterator](),t;!(d=(t=h.next()).done)&&(c.push(t.value),!b||c.length!==b);d=!0);}catch(q){f=!0,g=q}finally{try{if(!d&&h["return"])h["return"]()}finally{if(f)throw g;}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance");
}}();h=f(95);f(98);d.formatKeyName=c;d.formatKeyStroke=a;f=function(c){function d(c){if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");var e;e=Object.getPrototypeOf(d).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;var f=e.content;f.classList.add("describe-key-bindings");var g=document.createElement("div"),h=document.createElement("div");h.className="dl";
c=$jscomp.makeIterator(c.entries());for(var t=c.next();!t.done;t=c.next()){var q=b(t.value,2),t=q[0],q=q[1],v=document.createElement("div"),x=document.createElement("div");x.className="definition-outer-container";v.className="definition-container";var w=document.createElement("div");w.className="dt";w.textContent=t.map(a).join(" ");t=document.createElement("div");t.className="dd";t.textContent=q;v.appendChild(w);v.appendChild(t);h.appendChild(x);x.appendChild(v)}g.appendChild(h);f.appendChild(g);
return e}g(d,c);return d}(h.Overlay);d.KeyBindingHelpDialog=f},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var c=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=
!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var a=f(96);f(97);d.overlaysOpen=0;var b=new a.KeySequenceMap;b.bind("escape","close");f=function(e){function f(){var c=0>=arguments.length||void 0===arguments[0]?b:arguments[0];if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var e;e=Object.getPrototypeOf(f).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e.keySequenceMap=c;++d.overlaysOpen;var g=e.container=document.createElement("div");g.className="overlay";var h=e.content=document.createElement("div");h.className="overlay-content";g.appendChild(h);document.body.appendChild(g);e.keyboardShortcutHandler=e.registerDisposer(new a.GlobalKeyboardShortcutHandler(c,e.commandReceived.bind(e)));return e}g(f,e);c(f,[{key:"commandReceived",value:function(a){"close"===a&&this.dispose();return!1}},{key:"disposed",
value:function(){--d.overlaysOpen;document.body.removeChild(this.container)}}]);return f}(h.RefCounted);d.Overlay=f},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a){return(a.ctrlKey?1:0)|(a.altKey?2:0)|(a.metaKey?4:0)|(a.shiftKey?8:0)}function e(a,b){var c="";b&1&&(c+="control+");b&2&&(c+="alt+");b&4&&(c+="meta+");b&8&&(c+="shift+");return c+a}function l(a){return a.code.toLowerCase()}function r(a){a=a.toLowerCase().replace(" ","");for(var b=a.split("+"),c=void 0,
d=0,b=$jscomp.makeIterator(b),f=b.next();!f.done;f=b.next())switch(f=f.value,f){case "control":d|=1;break;case "alt":d|=2;break;case "meta":d|=4;break;case "shift":d|=8;break;default:c=void 0===c?f:null}if(null==c)throw Error("Invalid stroke "+JSON.stringify(a));return e(c,d)}function n(a){"string"===typeof a&&(a=a.replace(/[ +]*\+[ +]*/g,"+").replace(/[ ]+/g," ").toLowerCase(),a=a.split(" "));a=a.map(r);if(0===a.length)throw Error("Key sequence must not be empty");return a}function k(a){return JSON.stringify(a.join(" "))}
function p(a){function b(r,t){for(;;)switch(c){case 0:u=1>=w.length||void 0===w[1]?[]:w[1],n=$jscomp.makeIterator(a),m=n.next();case 1:if(m.done){c=3;break}l=m.value;h=q(l,2);k=h[0];g=h[1];f=[].concat($jscomp.arrayFromIterable(u),[k]);if("string"!==typeof g){c=4;break}c=6;return{value:[f,g],done:!1};case 6:if(void 0===t){c=7;break}c=-1;throw t;case 7:c=5;break;case 4:e=$jscomp.makeIterator(p(g,f));case 8:if((d=e.next(r)).done){c=9;break}c=10;return{value:d.value,done:!1};case 10:if(void 0===t){c=
11;break}c=-1;throw t;case 11:c=8;break;case 9:case 5:case 2:m=n.next();c=1;break;case 3:c=-1;default:return{value:void 0,done:!0}}}var c=0,d,e,f,g,k,h,l,m,n,u,w=arguments,r={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();r[Symbol.iterator]=function(){return this};return r}function m(a,b,c){void 0===y&&(y=new z(window,new u,function(){return!1}));B.push([y.keySequenceMap,y.handler,A]);
y.setKeySequenceMap(a);y.handler=b;A=c}function t(){var a=B.pop(),a=q(a,3),b=a[1],c=a[2];y.setKeySequenceMap(a[0]);y.handler=b;A=c}var q=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var g=a[Symbol.iterator](),k;!(d=(k=g.next()).done)&&(c.push(k.value),!b||c.length!==b);d=!0);}catch(h){e=!0,f=h}finally{try{if(!d&&g["return"])g["return"]()}finally{if(e)throw f;
}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance");}}(),v=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var x=new Set("f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 escape pause".split(" ")),w=new Set("color date datetime datetime-local email month number password search tel text time url week".split(" ")),
z=function(d){function f(a,b,d){g(this,f);var e=c(this,Object.getPrototypeOf(f).call(this));e.target=a;e.keySequenceMap=b;e.handler=d;e.modifierShortcutsAreGlobal=!0;e.allShortcutsAreGlobal=!1;e.allowSpaceKeyOnButtons=!1;e.reset();e.registerEventListener(a,"keydown",e.handleKeyDown.bind(e),!0);return e}a(f,d);v(f,[{key:"reset",value:function(){this.currentNode=this.keySequenceMap.root;this.lastStrokeTime=Number.NEGATIVE_INFINITY}},{key:"setKeySequenceMap",value:function(a){this.keySequenceMap=a;this.reset()}},
{key:"shouldIgnoreEvent",value:function(a,b){var c=b.target,d=c.tagName;if(c===this.target)return!1;var e="TEXTAREA"===d||"INPUT"===d||"BUTTON"===d||"SELECT"===d,f=!e&&(c.isContentEditable||c.ownerDocument&&"on"===c.ownerDocument.designMode);return!e&&!f||this.allShortcutsAreGlobal||x.has(a)?!1:f||this.modifierShortcutsAreGlobal&&(b.altKey||b.ctrlKey||b.metaKey)?!0:"INPUT"===d&&w.has(c.type)?"enter"!==a:"INPUT"===d||"BUTTON"===d?this.allowSpaceKeyOnButtons?!1:"space"===a:!0}},{key:"handleKeyDown",
value:function(a){var c=l(a);if(!this.shouldIgnoreEvent(c,a)){var c=e(c,b(a)),d=this.keySequenceMap.root,f=this.currentNode,g=f.get(c),k=Date.now();f!==d&&(void 0===g||k>this.lastStrokeTime+1500)&&(this.currentNode=d,g=f.get(c));void 0!==g&&("string"===typeof g?(this.reset(),this.handler(g)&&a.preventDefault()):(this.currentNode=g,this.lastStrokeTime=k,a.preventDefault()))}}}]);return f}(h.RefCounted);d.KeyboardShortcutHandler=z;d.getEventStrokeIdentifier=function(a){return e(l(a),b(a))};var C;(function(a){a[a.CONTROL=
1]="CONTROL";a[a.ALT=2]="ALT";a[a.META=4]="META";a[a.SHIFT=8]="SHIFT"})(C||(C={}));d.getEventModifierMask=b;d.getStrokeIdentifier=e;d.getEventKeyName=l;d.parseKeyStroke=r;d.parseKeySequence=n;d.formatKeySequence=k;var u=function(){function a(b){g(this,a);this.root=new Map;void 0!==b&&this.bindMultiple(b)}v(a,[{key:"bind",value:function(a,b){for(var c=n(a),d=this.root,e=c.length-1,f=0;f<e;++f){var g=c[f],h=d.get(g);void 0===h&&(h=new Map,d.set(g,h));if("string"===typeof h)throw Error("Error binding key sequence "+
k(c)+": prefix "+k(c.slice(0,f+1))+" is already bound to action "+JSON.stringify(h));d=h}e=c[e];f=d.get(e);if(void 0!==f)throw Error("Key sequence "+k(c)+" is already bound to action "+JSON.stringify(f));d.set(e,b)}},{key:"bindMultiple",value:function(a){for(var b=$jscomp.makeIterator(Object.keys(a)),c=b.next();!c.done;c=b.next())c=c.value,this.bind(c,a[c])}},{key:"entries",value:function(){return p(this.root)}}]);return a}();d.KeySequenceMap=u;var y=void 0,B=[],A=void 0;d.pushGlobalKeyboardHandler=
m;d.popGlobalKeyboardHandler=t;C=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this));e.keySequenceMap=a;e.handler=b;m(a,b,e);return e}a(d,b);v(d,[{key:"disposed",value:function(){if(A===this)t();else{var a=this,b=B.findIndex(function(b){return b[2]===a});B.splice(b,1)}}}]);return d}(h.RefCounted);d.GlobalKeyboardShortcutHandler=C},function(h,d){},function(h,d){},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in
e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),b=f(17),e=f(100);h=f(95);var l=f(59),r=f(9),n=f(132),k=f(133),p=f(138);f(139);f=function(d){function f(a,c){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var d=g(this,Object.getPrototypeOf(f).call(this));d.manager=a;d.existingLayer=c;d.statusElement=document.createElement("div");d.submitElement=document.createElement("button");d.namePromptElement=
document.createElement("label");d.nameInputElement=document.createElement("input");d.sourceValid=!1;d.nameValid=!0;var h=d.content;h.classList.add("add-layer-overlay");var l=document.createElement("form");l.className="source-form";d.registerEventListener(l,"submit",function(a){a.preventDefault();d.validateSource(!0)});var m=document.createElement("label");m.textContent="Source:";var u=d.sourceInput=d.registerDisposer(new k.AutocompleteTextInput({completer:function(a){return r.cancellableThen(b.volumeCompleter(a),
function(a){return{completions:a.completions,makeElement:k.makeCompletionElementWithDescription,offset:a.offset,showSingleResult:!0}})},delay:0}));u.element.classList.add("add-layer-source");u.inputElement.addEventListener("blur",function(a){d.validateSource(!1)});d.submitElement.disabled=!0;u.inputChanged.add(function(){r.cancelPromise(d.volumePromise);d.volumePromise=void 0;d.sourceValid=!1;d.submitElement.disabled=!0;d.statusElement.textContent=""});l.appendChild(m);l.appendChild(u.element);n.associateLabelWithElement(m,
u.inputElement);m=p.makeHiddenSubmitButton();l.appendChild(m);h.appendChild(l);var y=d.statusElement,B=d.namePromptElement,A=d.nameInputElement,l=d.submitElement;y.className="dialog-status";m=document.createElement("form");m.className="name-form";B.textContent="Name:";A.className="add-layer-name";A.autocomplete="off";A.spellcheck=!1;A.type="text";d.registerEventListener(A,"input",function(){d.validateName()});l.type="submit";n.associateLabelWithElement(B,A);m.appendChild(B);m.appendChild(A);m.appendChild(l);
h.appendChild(m);h.appendChild(y);void 0!==c?(void 0!==c.sourceUrl?(u.value=c.sourceUrl,d.validateSource()):d.sourceValid=!0,u.disabled=!0,A.value=c.name,d.validateName(),l.textContent="Save",A.focus()):(h=d.manager.layerManager.managedLayers,0<h.length&&(h=h[h.length-1],h instanceof e.ManagedUserLayerWithSpecification&&(h=h.sourceUrl,void 0!==h&&(y=b.findSourceGroup(h),u.value=h.substring(0,y),u.inputElement.setSelectionRange(0,y)))),u.inputElement.focus(),l.textContent="Add Layer");d.registerEventListener(m,
"submit",function(a){a.preventDefault();d.submit()});return d}c(f,d);a(f,[{key:"isNameValid",value:function(){var a=this.nameInputElement.value;if(""===a)return!1;a=this.manager.layerManager.getLayerByName(a);return void 0===a||a===this.existingLayer}},{key:"submit",value:function(){this.sourceValid&&this.isNameValid()&&(this.existingLayer?(this.existingLayer.name=this.nameInputElement.value,this.manager.layerManager.layersChanged.dispatch()):this.manager.layerManager.addManagedLayer(this.manager.getLayer(this.nameInputElement.value,
this.sourceInput.value)),this.dispose())}},{key:"validateName",value:function(){var a=this.nameInputElement;(this.nameValid=this.isNameValid())?(a.classList.add("valid-input"),a.classList.remove("invalid-input")):(a.classList.remove("valid-input"),a.classList.add("invalid-input"));this.validityChanged()}},{key:"validityChanged",value:function(){this.submitElement.disabled=!(this.nameValid&&this.sourceValid)}},{key:"validateSource",value:function(){var a=this,c=0>=arguments.length||void 0===arguments[0]?
!1:arguments[0],d=this.sourceInput.value;if(""!==d){try{var e=b.suggestLayerName(d),f=this.nameInputElement;if(""===this.nameInputElement.value){for(var g=e,k=0;void 0!==this.manager.layerManager.getLayerByName(g);)g=e+ ++k;f.value=g;f.setSelectionRange(0,g.length);this.validateName()}c&&f.focus()}catch(h){this.setError(h.message);return}this.setInfo("Validating volume source...");c=new Promise(function(a){a(b.getVolume(d))});this.volumePromise=r.cancellableThen(c,function(b){a.sourceValid=!0;a.setInfo(l.VolumeType[b.volumeType].toLowerCase()+
": "+b.numChannels+"-channel "+l.DataType[b.dataType].toLowerCase());a.validityChanged()});c.catch(function(b){b!==r.CANCELLED&&a.setError(b.message)})}}},{key:"setInfo",value:function(a){this.statusElement.className="dialog-status dialog-status-info";this.statusElement.textContent=a}},{key:"setError",value:function(a){this.statusElement.className="dialog-status dialog-status-error";this.statusElement.textContent=a}}]);return f}(h.Overlay);d.LayerDialog=f},function(h,d,f){function g(a,b){if(!(a instanceof
b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
b):a.__proto__=b)}function b(a){return p.StatusMessage.forPromise(new Promise(function(b){b(l.getVolume(a))}),{initialMessage:"Retrieving metadata for volume "+a+".",delay:!0,errorPrefix:"Error retrieving metadata for volume "+a+": "})}var e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),l=f(17),r=f(101);
h=f(30);var n=f(114),k=f(59),p=f(4),m=f(12),t=f(8),q=f(23);d.getVolumeWithStatusMessage=b;var v=function(b){function d(a,b,e){g(this,d);a=c(this,Object.getPrototypeOf(d).call(this,a));a.initialSpecification=b;a.manager=e;return a}a(d,b);e(d,[{key:"toJSON",value:function(){var a=this.layer;if(!a)return this.initialSpecification;a=a.toJSON();this.visible||(a.visible=!1);return a}}]);return d}(h.ManagedUserLayer);d.ManagedUserLayerWithSpecification=v;f=function(d){function f(a,b,d,e,k){g(this,f);var h=
c(this,Object.getPrototypeOf(f).call(this));h.layerManager=a;h.chunkManager=b;h.worker=d;h.layerSelectedValues=e;h.voxelSize=k;h.changed=new q.Signal;h.registerSignalBinding(a.layersChanged.add(h.changed.dispatch,h.changed));h.registerSignalBinding(a.specificationChanged.add(h.changed.dispatch,h.changed));return h}a(f,d);e(f,[{key:"restoreState",value:function(a){t.verifyObject(a);this.layerManager.clear();for(var b=$jscomp.makeIterator(Object.keys(a)),c=b.next();!c.done;c=b.next())c=c.value,this.layerManager.addManagedLayer(this.getLayer(c,
a[c]))}},{key:"getLayer",value:function(a,c){var d=new v(a,c,this);"string"===typeof c&&(c={source:c});t.verifyObject(c);var e=t.verifyObjectProperty(c,"type",t.verifyOptionalString);d.visible=t.verifyObjectProperty(c,"visible",function(a){if(void 0===a||!0===a)return!0;if(!1===a)return!1;throw Error("Expected boolean, but received: "+JSON.stringify(a)+".");});var f=d.sourceUrl=t.verifyObjectProperty(c,"source",t.verifyOptionalString);if(void 0===e){var g=this;if(void 0===f)throw Error("Either layer 'type' or 'source' URL must be specified.");
b(f).then(function(a){if(-1!==g.layerManager.managedLayers.indexOf(d))switch(a.volumeType){case k.VolumeType.IMAGE:a=new r.ImageUserLayer(g,c);d.layer=a;break;case k.VolumeType.SEGMENTATION:a=new n.SegmentationUserLayer(g,c);d.layer=a;break;default:throw Error("Unsupported source type.");}})}else if("image"===e)d.layer=new r.ImageUserLayer(this,c);else if("segmentation"===e)d.layer=new n.SegmentationUserLayer(this,c);else throw Error("Layer type not specified.");return d}},{key:"toJSON",value:function(){for(var a=
{},b=0,c=$jscomp.makeIterator(this.layerManager.managedLayers),d=c.next();!d.done;d=c.next())d=d.value,a[d.name]=d.toJSON(),++b;return 0===b?void 0:a}}]);return f}(m.RefCounted);d.LayerListSpecification=f},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==
typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,
c);d&&a(b,d);return b}}();f(102);var e=f(103),l=f(32);h=f(30);var r=f(100),n=f(95),k=f(104),p=f(64),m=f(12),t=f(7),q=f(106);f(108);f(109);f(110);f(111);f(112);f(113)(e);f=function(d){function e(a,b){g(this,e);var d=c(this,Object.getPrototypeOf(e).call(this));d.opacity=p.trackableAlphaValue(.5);d.fragmentMain=k.getTrackableFragmentMain();var f=b.source;if("string"!==typeof f)throw Error("Invalid image layer specification");d.opacity.restoreState(b.opacity);d.fragmentMain.restoreState(b.shader);d.registerSignalBinding(d.fragmentMain.changed.add(function(){d.specificationChanged.dispatch()}));
d.volumePath=f;f=new k.ImageRenderLayer(a.chunkManager,r.getVolumeWithStatusMessage(f),d.opacity,d.fragmentMain);d.renderLayer=f;d.addRenderLayer(f);return d}a(e,d);b(e,[{key:"toJSON",value:function(){var a={type:"image"};a.source=this.volumePath;a.opacity=this.opacity.toJSON();a.shader=this.fragmentMain.toJSON();return a}},{key:"makeDropdown",value:function(a){return new x(a,this)}}]);return e}(h.UserLayer);d.ImageUserLayer=f;var v=function(d){function f(a){g(this,f);var b=c(this,Object.getPrototypeOf(f).call(this));
b.layer=a;b.changingValue=!1;b.debouncedValueUpdater=l(function(){b.changingValue=!0;try{b.layer.fragmentMain.value=b.textEditor.getValue()}finally{b.changingValue=!1}},500);b.textEditor=e(function(a){},{value:b.layer.fragmentMain.value,mode:"glsl",gutters:["CodeMirror-lint-markers"]});b.textEditor.on("change",function(){b.setValidState(void 0);b.debouncedValueUpdater()});b.registerSignalBinding(b.layer.fragmentMain.changed.add(function(){b.changingValue||b.textEditor.setValue(b.layer.fragmentMain.value)}));
b.registerSignalBinding(b.layer.renderLayer.shaderError.changed.add(function(){b.updateErrorState()}));b.updateErrorState();return b}a(f,d);b(f,[{key:"updateErrorState",value:function(){this.layer.renderLayer.shaderUpdated&&this.setValidState(void 0);var a=this.layer.renderLayer.shaderError.value;void 0!==a?(this.textEditor.setOption("lint",{getAnnotations:function(){if("ShaderCompilationError"===a.name){var b=function(){var b=a.source.split("\n").indexOf(k.FRAGMENT_MAIN_START)+2;return{v:a.errorMessages.map(function(a){return{message:a.message,
severity:"error",from:e.Pos(void 0===a.line?0:a.line-b)}})}}();if("object"===typeof b)return b.v}else return"ShaderLinkError"===a.name?[{message:a.log,severity:"error",from:e.Pos(0)}]:[{message:a.message,severity:"error",from:e.Pos(0)}]}}),this.setValidState(!1)):(this.textEditor.setOption("lint",void 0),this.setValidState(!0))}},{key:"setValidState",value:function(a){var b=this.element;b.classList.remove("invalid-input");b.classList.remove("valid-input");!0===a?b.classList.add("valid-input"):!1===
a&&b.classList.add("invalid-input")}},{key:"disposed",value:function(){this.debouncedValueUpdater.flush();this.debouncedValueUpdater=void 0;t.removeFromParent(this.element);this.textEditor=void 0}},{key:"element",get:function(){return this.textEditor.getWrapperElement()}}]);return f}(m.RefCounted),x=function(d){function e(a,b){g(this,e);var d=c(this,Object.getPrototypeOf(e).call(this));d.element=a;d.layer=b;d.opacityWidget=d.registerDisposer(new q.RangeWidget(d.layer.opacity));d.codeWidget=d.registerDisposer(new v(d.layer));
a.classList.add("image-dropdown");var f=d.opacityWidget,k=document.createElement("div");k.className="image-dropdown-top-row";f.promptElement.textContent="Opacity";f=document.createElement("div");f.style.flex="1";var h=document.createElement("a"),l=document.createElement("button");l.type="button";l.textContent="?";l.className="help-link";h.appendChild(l);h.title="Documentation on image layer rendering";h.target="_blank";h.href="https://github.com/google/neuroglancer/blob/master/src/neuroglancer/sliceview/image_layer_rendering.md";
l=document.createElement("button");l.innerHTML="&square;";l.className="maximize-button";l.title="Show larger editor view";d.registerEventListener(l,"click",function(){new w(d.layer)});k.appendChild(d.opacityWidget.element);k.appendChild(f);k.appendChild(l);k.appendChild(h);a.appendChild(k);a.appendChild(d.codeWidget.element);d.codeWidget.textEditor.refresh();return d}a(e,d);b(e,[{key:"onShow",value:function(){this.codeWidget.textEditor.refresh()}}]);return e}(h.UserLayerDropdown),w=function(b){function d(a){g(this,
d);var b=c(this,Object.getPrototypeOf(d).call(this));b.layer=a;b.codeWidget=b.registerDisposer(new v(b.layer));b.content.classList.add("image-layer-shader-overlay");b.content.appendChild(b.codeWidget.element);b.codeWidget.textEditor.refresh();return b}a(d,b);return d}(n.Overlay)},function(h,d,f){(function(d){d(f(103))})(function(d){function c(a,b){function c(a){if(!e.parentNode)return d.off(document,"mousemove",c);e.style.top=Math.max(0,a.clientY-e.offsetHeight-5)+"px";e.style.left=a.clientX+5+"px"}
var e=document.createElement("div");e.className="CodeMirror-lint-tooltip";e.appendChild(b.cloneNode(!0));document.body.appendChild(e);d.on(document,"mousemove",c);c(a);null!=e.style.opacity&&(e.style.opacity=1);return e}function a(a){a.parentNode&&(null==a.style.opacity&&a.parentNode&&a.parentNode.removeChild(a),a.style.opacity=0,setTimeout(function(){a.parentNode&&a.parentNode.removeChild(a)},600))}function b(b,e,f){function k(){d.off(f,"mouseout",k);h&&(a(h),h=null)}var h=c(b,e),l=setInterval(function(){if(h)for(var a=
f;;a=a.parentNode){a&&11==a.nodeType&&(a=a.host);if(a==document.body)return;if(!a){k();break}}if(!h)return clearInterval(l)},400);d.on(f,"mouseout",k)}function e(a,c,d){this.marked=[];this.options=c;this.timeout=null;this.hasGutter=d;this.onMouseOver=function(c){var d=c.target||c.srcElement;if(/\bCodeMirror-lint-mark-/.test(d.className)){for(var d=d.getBoundingClientRect(),e=a.findMarksAt(a.coordsChar({left:(d.left+d.right)/2,top:(d.top+d.bottom)/2},"client")),d=[],f=0;f<e.length;++f){var g=e[f].__annotation;
g&&d.push(g)}if(d.length){e=c.target||c.srcElement;f=document.createDocumentFragment();for(g=0;g<d.length;g++)f.appendChild(n(d[g]));b(c,f,e)}}};this.waitingFor=0}function f(a){var b=a.state.lint;b.hasGutter&&a.clearGutter("CodeMirror-lint-markers");for(a=0;a<b.marked.length;++a)b.marked[a].clear();b.marked.length=0}function h(a,c,e,f){var k=document.createElement("div"),l=k;k.className="CodeMirror-lint-marker-"+c;e&&(l=k.appendChild(document.createElement("div")),l.className="CodeMirror-lint-marker-multiple");
if(0!=f)d.on(l,"mouseover",function(c){b(c,a,l)});return k}function n(a){var b=a.severity;b||(b="error");var c=document.createElement("div");c.className="CodeMirror-lint-message-"+b;c.appendChild(document.createTextNode(a.message));return c}function k(a,b,c){function e(){k=-1;a.off("change",e)}var f=a.state.lint,k=++f.waitingFor;a.on("change",e);b(a.getValue(),function(b,c){a.off("change",e);f.waitingFor==k&&(c&&b instanceof d&&(b=c),m(a,b))},c,a)}function p(a){var b=a.state.lint.options,c=b.options||
b,e=b.getAnnotations||a.getHelper(d.Pos(0,0),"lint");e&&(b.async||e.async?k(a,e,c):m(a,e(a.getValue(),c,a)))}function m(a,b){f(a);for(var c=a.state.lint,d=c.options,e=[],g=0;g<b.length;++g){var k=b[g],m=k.from.line;(e[m]||(e[m]=[])).push(k)}for(g=0;g<e.length;++g)if(k=e[g]){for(var m=null,p=c.hasGutter&&document.createDocumentFragment(),t=0;t<k.length;++t){var D=k[t],E=D.severity;E||(E="error");"error"!=m&&(m=E);d.formatAnnotation&&(D=d.formatAnnotation(D));c.hasGutter&&p.appendChild(n(D));D.to&&
c.marked.push(a.markText(D.from,D.to,{className:"CodeMirror-lint-mark-"+E,__annotation:D}))}c.hasGutter&&a.setGutterMarker(g,"CodeMirror-lint-markers",h(p,m,1<k.length,c.options.tooltips))}if(d.onUpdateLinting)d.onUpdateLinting(b,e,a)}function t(a){var b=a.state.lint;b&&(clearTimeout(b.timeout),b.timeout=setTimeout(function(){p(a)},b.options.delay||500))}d.defineOption("lint",!1,function(a,b,c){c&&c!=d.Init&&(f(a),!1!==a.state.lint.options.lintOnChange&&a.off("change",t),d.off(a.getWrapperElement(),
"mouseover",a.state.lint.onMouseOver),clearTimeout(a.state.lint.timeout),delete a.state.lint);if(b){var k=a.getOption("gutters");c=!1;for(var h=0;h<k.length;++h)"CodeMirror-lint-markers"==k[h]&&(c=!0);k=a.state;b instanceof Function?b={getAnnotations:b}:b&&!0!==b||(b={});c=k.lint=new e(a,b,c);if(!1!==c.options.lintOnChange)a.on("change",t);if(0!=c.options.tooltips)d.on(a.getWrapperElement(),"mouseover",c.onMouseOver);p(a)}});d.defineExtension("performLint",function(){this.state.lint&&p(this)})})},
function(h,d,f){(function(d){h.exports=d()})(function(){function d(a,b){if(!(this instanceof d))return new d(a,b);this.options=b=b?Ca(b):{};Ca(wf,b,!1);q(b);var e=b.value;"string"==typeof e&&(e=new ra(e,b.mode,null,b.lineSeparator));this.doc=e;var f=new d.inputStyles[b.inputStyle](this),f=this.display=new c(a,e,f);f.wrapper.CodeMirror=this;k(this);h(this);b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");b.autofocus&&!Pb&&f.input.focus();z(this);this.state={keyMaps:[],overlays:[],
modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new db,keySeq:null,specialChars:null};var ga=this;S&&11>ba&&setTimeout(function(){ga.display.input.reset(!0)},20);xf(this);Sd||(yf(),Sd=!0);wb(this);this.curOp.forceUpdate=!0;Td(this,e);b.autofocus&&!Pb||ga.hasFocus()?setTimeout(Qb(dd,this),20):Rb(this);for(var l in xb)if(xb.hasOwnProperty(l))xb[l](this,b[l],Ud);A(this);b.finishInit&&b.finishInit(this);
for(e=0;e<ed.length;++e)ed[e](this);yb(this);ha&&b.lineWrapping&&"optimizelegibility"==getComputedStyle(f.lineDiv).textRendering&&(f.lineDiv.style.textRendering="auto")}function c(a,b,c){this.input=c;this.scrollbarFiller=I("div",null,"CodeMirror-scrollbar-filler");this.scrollbarFiller.setAttribute("cm-not-content","true");this.gutterFiller=I("div",null,"CodeMirror-gutter-filler");this.gutterFiller.setAttribute("cm-not-content","true");this.lineDiv=I("div",null,"CodeMirror-code");this.selectionDiv=
I("div",null,null,"position: relative; z-index: 1");this.cursorDiv=I("div",null,"CodeMirror-cursors");this.measure=I("div",null,"CodeMirror-measure");this.lineMeasure=I("div",null,"CodeMirror-measure");this.lineSpace=I("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");this.mover=I("div",[I("div",[this.lineSpace],"CodeMirror-lines")],null,"position: relative");this.sizer=I("div",[this.mover],"CodeMirror-sizer");this.sizerWidth=
null;this.heightForcer=I("div",null,null,"position: absolute; height: "+Vd+"px; width: 1px;");this.gutters=I("div",null,"CodeMirror-gutters");this.lineGutter=null;this.scroller=I("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll");this.scroller.setAttribute("tabIndex","-1");this.wrapper=I("div",[this.scrollbarFiller,this.gutterFiller,this.scroller],"CodeMirror");S&&8>ba&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0);ha||Xa&&Pb||(this.scroller.draggable=!0);a&&
(a.appendChild?a.appendChild(this.wrapper):a(this.wrapper));this.reportedViewFrom=this.reportedViewTo=this.viewFrom=this.viewTo=b.first;this.view=[];this.externalMeasured=this.renderedView=null;this.lastWrapHeight=this.lastWrapWidth=this.viewOffset=0;this.updateLineNumbers=null;this.nativeBarWidth=this.barHeight=this.barWidth=0;this.scrollbarsClipped=!1;this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null;this.alignWidgets=!1;this.maxLine=this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=
null;this.maxLineLength=0;this.maxLineChanged=!1;this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null;this.shift=!1;this.activeTouch=this.selForContextMenu=null;c.init(this)}function a(a){a.doc.mode=d.getMode(a.options,a.doc.modeOption);b(a)}function b(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.frontier=a.doc.first;Sb(a,100);a.state.modeGen++;a.curOp&&pa(a)}function e(a){var b=eb(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/
Tb(a.display)-3);return function(e){if(fb(a.doc,e))return 0;var f=0;if(e.widgets)for(var k=0;k<e.widgets.length;k++)e.widgets[k].height&&(f+=e.widgets[k].height);return c?f+(Math.ceil(e.text.length/d)||1)*b:f+b}}function f(a){var b=a.doc,c=e(a);b.iter(function(a){var b=c(a);b!=a.height&&Ja(a,b)})}function h(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");Ub(a)}function n(a){k(a);pa(a);setTimeout(function(){B(a)},
20)}function k(a){var b=a.display.gutters,c=a.options.gutters;gb(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(I("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none";p(a)}function p(a){a.display.sizer.style.marginLeft=a.display.gutters.offsetWidth+"px"}function m(a){if(0==a.height)return 0;for(var b=a.text.length,c,d=a;c=hb(d,!0);)c=c.find(0,!0),d=c.from.line,b+=c.from.ch-c.to.ch;
for(d=a;c=hb(d,!1);)c=c.find(0,!0),b-=d.text.length-c.from.ch,d=c.to.line,b+=d.text.length-c.to.ch;return b}function t(a){var b=a.display;a=a.doc;b.maxLine=J(a,a.first);b.maxLineLength=m(b.maxLine);b.maxLineChanged=!0;a.iter(function(a){var c=m(a);c>b.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)})}function q(a){var b=ka(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):-1<b&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,
1))}function v(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+fd(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+Ka(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function x(a,b,c){this.cm=c;var d=this.vert=I("div",[I("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),
e=this.horiz=I("div",[I("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a(d);a(e);K(d,"scroll",function(){d.clientHeight&&b(d.scrollTop,"vertical")});K(e,"scroll",function(){e.clientWidth&&b(e.scrollLeft,"horizontal")});this.checkedZeroWidth=!1;S&&8>ba&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function w(){}function z(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&Vb(a.display.wrapper,a.display.scrollbars.addClass));
a.display.scrollbars=new d.scrollbarModel[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller);K(b,"mousedown",function(){a.state.focused&&setTimeout(function(){a.display.input.focus()},0)});b.setAttribute("cm-not-content","true")},function(b,c){"horizontal"==c?zb(a,b):Wb(a,b)},a);a.display.scrollbars.addClass&&Xb(a.display.wrapper,a.display.scrollbars.addClass)}function C(a,b){b||(b=v(a));var c=a.display.barWidth,d=a.display.barHeight;u(a,b);for(var e=
0;4>e&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&Q(a),u(a,v(a)),c=a.display.barWidth,d=a.display.barHeight}function u(a,b){var c=a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px";c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px";c.heightForcer.style.borderBottom=d.bottom+"px solid transparent";d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=
d.right+"px"):c.scrollbarFiller.style.display="";d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function y(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop,d=Math.floor(d-a.lineSpace.offsetTop),e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,d=ib(b,d),e=ib(b,e);if(c&&c.ensure){var f=c.ensure.from.line;
c=c.ensure.to.line;f<d?(d=f,e=ib(b,La(J(b,f))+a.wrapper.clientHeight)):Math.min(c,b.lastLine())>=e&&(d=ib(b,La(J(b,c))-a.wrapper.clientHeight),e=c)}return{from:d,to:Math.max(e,d+1)}}function B(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=E(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",k=0;k<c.length;k++)if(!c[k].hidden){a.options.fixedGutter&&c[k].gutter&&(c[k].gutter.style.left=f);var g=c[k].alignable;if(g)for(var h=
0;h<g.length;h++)g[h].style.left=f}a.options.fixedGutter&&(b.gutters.style.left=d+e+"px")}}function A(a){if(!a.options.lineNumbers)return!1;var b=a.doc,b=D(a.options,b.first+b.size-1),c=a.display;if(b.length!=c.lineNumChars){var d=c.measure.appendChild(I("div",[I("div",b)],"CodeMirror-linenumber CodeMirror-gutter-elt")),e=d.firstChild.offsetWidth,d=d.offsetWidth-e;c.lineGutter.style.width="";c.lineNumInnerWidth=Math.max(e,c.lineGutter.offsetWidth-d)+1;c.lineNumWidth=c.lineNumInnerWidth+d;c.lineNumChars=
c.lineNumInnerWidth?b.length:-1;c.lineGutter.style.width=c.lineNumWidth+"px";p(a);return!0}return!1}function D(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function E(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function H(a,b,c){var d=a.display;this.viewport=b;this.visible=y(d,a.doc,b);this.editorIsHidden=!d.wrapper.offsetWidth;this.wrapperHeight=d.wrapper.clientHeight;this.wrapperWidth=d.wrapper.clientWidth;this.oldDisplayWidth=jb(a);this.force=
c;this.dims=X(a);this.events=[]}function G(a,b){var c=a.display,d=a.doc;if(b.editorIsHidden)return Ya(a),!1;if(!b.force&&b.visible.from>=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&0==Wd(a))return!1;A(a)&&(Ya(a),b.dims=X(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),k=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFrom<f&&20>f-c.viewFrom&&(f=Math.max(d.first,c.viewFrom));c.viewTo>
k&&20>c.viewTo-k&&(k=Math.min(e,c.viewTo));Za&&(f=gd(a.doc,f),k=Xd(a.doc,k));d=f!=c.viewFrom||k!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;e=a.display;0==e.view.length||f>=e.viewTo||k<=e.viewFrom?(e.view=uc(a,f,k),e.viewFrom=f):(e.viewFrom>f?e.view=uc(a,f,e.viewFrom).concat(e.view):e.viewFrom<f&&(e.view=e.view.slice(kb(a,f))),e.viewFrom=f,e.viewTo<k?e.view=e.view.concat(uc(a,e.viewTo,k)):e.viewTo>k&&(e.view=e.view.slice(0,kb(a,k))));e.viewTo=k;c.viewOffset=La(J(a.doc,
c.viewFrom));a.display.mover.style.top=c.viewOffset+"px";k=Wd(a);if(!d&&0==k&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;f=Ma();4<k&&(c.lineDiv.style.display="none");N(a,c.updateLineNumbers,b.dims);4<k&&(c.lineDiv.style.display="");c.renderedView=c.view;f&&Ma()!=f&&f.offsetHeight&&f.focus();gb(c.cursorDiv);gb(c.selectionDiv);c.gutters.style.height=c.sizer.style.minHeight=0;d&&(c.lastWrapHeight=b.wrapperHeight,c.lastWrapWidth=b.wrapperWidth,
Sb(a,400));c.updateLineNumbers=null;return!0}function P(a,b){for(var c=b.viewport,d=!0;;d=!1){if(!d||!a.options.lineWrapping||b.oldDisplayWidth==jb(a))if(c&&null!=c.top&&(c={top:Math.min(a.doc.height+fd(a.display)-hd(a),c.top)}),b.visible=y(a.display,a.doc,c),b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)break;if(!G(a,b))break;Q(a);d=v(a);Yb(a);C(a,d);W(a,d)}b.signal(a,"update",a);if(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)b.signal(a,
"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo}function R(a,b){var c=new H(a,b);if(G(a,c)){Q(a);P(a,c);var d=v(a);Yb(a);C(a,d);W(a,d);c.finish()}}function W(a,b){a.display.sizer.style.minHeight=b.docHeight+"px";a.display.heightForcer.style.top=b.docHeight+"px";a.display.gutters.style.height=b.docHeight+a.display.barHeight+Ka(a)+"px"}function Q(a){a=a.display;for(var b=a.lineDiv.offsetTop,c=0;c<a.view.length;c++){var d=
a.view[c],e;if(!d.hidden){if(S&&8>ba){var f=d.node.offsetTop+d.node.offsetHeight;e=f-b;b=f}else e=d.node.getBoundingClientRect(),e=e.bottom-e.top;f=d.line.height-e;2>e&&(e=eb(a));if(.001<f||-.001>f)if(Ja(d.line,e),T(d.line),d.rest)for(e=0;e<d.rest.length;e++)T(d.rest[e])}}}function T(a){if(a.widgets)for(var b=0;b<a.widgets.length;++b)a.widgets[b].height=a.widgets[b].node.parentNode.offsetHeight}function X(a){for(var b=a.display,c={},d={},e=b.gutters.clientLeft,f=b.gutters.firstChild,k=0;f;f=f.nextSibling,
++k)c[a.options.gutters[k]]=f.offsetLeft+f.clientLeft+e,d[a.options.gutters[k]]=f.clientWidth;return{fixedPos:E(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function N(a,b,c){function d(b){var c=b.nextSibling;ha&&Da&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b);return c}for(var e=a.display,f=a.options.lineNumbers,k=e.lineDiv,g=k.firstChild,h=e.view,e=e.viewFrom,l=0;l<h.length;l++){var m=h[l];if(!m.hidden)if(m.node&&
m.node.parentNode==k){for(;g!=m.node;)g=d(g);g=f&&null!=b&&b<=e&&m.lineNumber;m.changes&&(-1<ka(m.changes,"gutter")&&(g=!1),ja(a,m,e,c));g&&(gb(m.lineNumber),m.lineNumber.appendChild(document.createTextNode(D(a.options,e))));g=m.node.nextSibling}else{var n=Ba(a,m,e,c);k.insertBefore(n,g)}e+=m.size}for(;g;)g=d(g)}function ja(a,b,c,d){for(var e=0;e<b.changes.length;e++){var f=b.changes[e];if("text"==f){var f=b,k=f.text.className,g=ya(a,f);f.text==f.node&&(f.node=g.pre);f.text.parentNode.replaceChild(g.pre,
f.text);f.text=g.pre;g.bgClass!=f.bgClass||g.textClass!=f.textClass?(f.bgClass=g.bgClass,f.textClass=g.textClass,ub(f)):k&&(f.text.className=k)}else if("gutter"==f)za(a,b,c,d);else if("class"==f)ub(b);else if("widget"==f){f=a;k=b;g=d;k.alignable&&(k.alignable=null);for(var h=k.node.firstChild,l=void 0;h;h=l)l=h.nextSibling,"CodeMirror-linewidget"==h.className&&k.node.removeChild(h);aa(f,k,g)}}b.changes=null}function ca(a){a.node==a.text&&(a.node=I("div",null,null,"position: relative"),a.text.parentNode&&
a.text.parentNode.replaceChild(a.node,a.text),a.node.appendChild(a.text),S&&8>ba&&(a.node.style.zIndex=2));return a.node}function ya(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):Yd(a,b)}function ub(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;b&&(b+=" CodeMirror-linebackground");if(a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=
ca(a);a.background=c.insertBefore(I("div",null,b),c.firstChild)}a.line.wrapClass?ca(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");a.text.className=(a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass)||""}function za(a,b,c,d){b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null);b.gutterBackground&&(b.node.removeChild(b.gutterBackground),b.gutterBackground=null);if(b.line.gutterClass){var e=ca(b);b.gutterBackground=I("div",null,"CodeMirror-gutter-background "+
b.line.gutterClass,"left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px");e.insertBefore(b.gutterBackground,b.text)}var f=b.line.gutterMarkers;if(a.options.lineNumbers||f){var e=ca(b),k=b.gutter=I("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px");a.display.input.setUneditable(k);e.insertBefore(k,b.text);b.line.gutterClass&&(k.className+=" "+b.line.gutterClass);!a.options.lineNumbers||f&&f["CodeMirror-linenumbers"]||
(b.lineNumber=k.appendChild(I("div",D(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px")));if(f)for(b=0;b<a.options.gutters.length;++b)c=a.options.gutters[b],(e=f.hasOwnProperty(c)&&f[c])&&k.appendChild(I("div",[e],"CodeMirror-gutter-elt","left: "+d.gutterLeft[c]+"px; width: "+d.gutterWidth[c]+"px"))}}function Ba(a,b,c,d){var e=ya(a,b);b.text=b.node=e.pre;e.bgClass&&(b.bgClass=e.bgClass);e.textClass&&
(b.textClass=e.textClass);ub(b);za(a,b,c,d);aa(a,b,d);return b.node}function aa(a,b,c){Mb(a,b.line,b,c,!0);if(b.rest)for(var d=0;d<b.rest.length;d++)Mb(a,b.rest[d],b,c,!1)}function Mb(a,b,c,d,e){if(b.widgets){var f=ca(c),k=0;for(b=b.widgets;k<b.length;++k){var g=b[k],h=I("div",[g.node],"CodeMirror-linewidget");g.handleMouseEvents||h.setAttribute("cm-ignore-events","true");var l=g,m=h,n=d;if(l.noHScroll){(c.alignable||(c.alignable=[])).push(m);var p=n.wrapperWidth;m.style.left=n.fixedPos+"px";l.coverGutter||
(p-=n.gutterTotalWidth,m.style.paddingLeft=n.gutterTotalWidth+"px");m.style.width=p+"px"}l.coverGutter&&(m.style.zIndex=5,m.style.position="relative",l.noHScroll||(m.style.marginLeft=-n.gutterTotalWidth+"px"));a.display.input.setUneditable(h);e&&g.above?f.insertBefore(h,c.gutter||c.text):f.appendChild(h);ta(g,"redraw")}}}function Nb(a){return F(a.line,a.ch)}function bb(a,b){return 0>L(a,b)?b:a}function Wa(a,b){return 0>L(a,b)?a:b}function cb(a){a.state.focused||(a.display.input.focus(),dd(a))}function Ia(a,
b,c,d,e){var f=a.doc;a.display.shift=!1;d||(d=f.sel);var k=a.state.pasteIncoming||"paste"==e,g=f.splitLines(b),h=null;if(k&&1<d.ranges.length)if(qa&&qa.text.join("\n")==b){if(0==d.ranges.length%qa.text.length)for(var h=[],l=0;l<qa.text.length;l++)h.push(f.splitLines(qa.text[l]))}else g.length==d.ranges.length&&(h=vc(g,function(a){return[a]}));for(l=d.ranges.length-1;0<=l;l--){var m=d.ranges[l],n=m.from(),p=m.to();m.empty()&&(c&&0<c?n=F(n.line,n.ch-c):a.state.overwrite&&!k?p=F(p.line,Math.min(J(f,
p.line).text.length,p.ch+V(g).length)):qa&&qa.lineWise&&qa.text.join("\n")==b&&(n=p=F(n.line,0)));m=a.curOp.updateInput;n={from:n,to:p,text:h?h[l%h.length]:g,origin:e||(k?"paste":a.state.cutIncoming?"cut":"+input")};Ab(a.doc,n);ta(a,"inputRead",a,n)}b&&!k&&Ob(a,b);Bb(a);a.curOp.updateInput=m;a.curOp.typing=!0;a.state.pasteIncoming=a.state.cutIncoming=!1}function sc(a,b){var c=a.clipboardData&&a.clipboardData.getData("text/plain");if(c)return a.preventDefault(),b.isReadOnly()||b.options.disableInput||
va(b,function(){Ia(b,c,0,null,"paste")}),!0}function Ob(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var c=a.doc.sel,d=c.ranges.length-1;0<=d;d--){var e=c.ranges[d];if(!(100<e.head.ch||d&&c.ranges[d-1].head.line==e.head.line)){var f=a.getModeAt(e.head),k=!1;if(f.electricChars)for(var g=0;g<f.electricChars.length;g++){if(-1<b.indexOf(f.electricChars.charAt(g))){k=Zb(a,e.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(J(a.doc,e.head.line).text.slice(0,e.head.ch))&&
(k=Zb(a,e.head.line,"smart"));k&&ta(a,"electricInput",a,e.head.line)}}}function Od(a){for(var b=[],c=[],d=0;d<a.doc.sel.ranges.length;d++){var e=a.doc.sel.ranges[d].head.line,e={anchor:F(e,0),head:F(e+1,0)};c.push(e);b.push(a.getRange(e.anchor,e.head))}return{text:b,ranges:c}}function Pd(a){a.setAttribute("autocorrect","off");a.setAttribute("autocapitalize","off");a.setAttribute("spellcheck","false")}function bd(a){this.cm=a;this.prevInput="";this.pollingFast=!1;this.polling=new db;this.hasSelection=
this.inaccurateSelection=!1;this.composing=null}function Qd(){var a=I("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),b=I("div",[a],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");ha?a.style.width="1000px":a.setAttribute("wrap","off");Cb&&(a.style.border="1px solid black");Pd(a);return b}function cd(a){this.cm=a;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new db;this.gracePeriod=
!1}function Rd(a,b){var c=id(a,b.line);if(!c||c.hidden)return null;var d=J(a.doc,b.line),c=Zd(c,d,b.line),d=Ea(d),e="left";d&&(e=wc(d,b.ch)%2?"right":"left");c=$d(c.map,b.ch,e);c.offset="right"==c.collapse?c.end:c.start;return c}function vb(a,b){b&&(a.bad=!0);return a}function tc(a,b,c){var d;if(b==a.display.lineDiv){d=a.display.lineDiv.childNodes[c];if(!d)return vb(a.clipPos(F(a.display.viewTo-1)),!0);b=null;c=0}else for(d=b;;d=d.parentNode){if(!d||d==a.display.lineDiv)return null;if(d.parentNode&&
d.parentNode==a.display.lineDiv)break}for(var e=0;e<a.display.view.length;e++){var f=a.display.view[e];if(f.node==d)return uf(f,b,c)}}function uf(a,b,c){function d(b,c,e){for(var f=-1;f<(l?l.length:0);f++)for(var U=0>f?h.map:l[f],Sa=0;Sa<U.length;Sa+=3){var k=U[Sa+2];if(k==b||k==c){c=Y(0>f?a.line:a.rest[f]);f=U[Sa]+e;if(0>e||k!=b)f=U[Sa+(e?1:0)];return F(c,f)}}}var e=a.text.firstChild,f=!1;if(!b||!jd(e,b))return vb(F(Y(a.line),0),!0);if(b==e&&(f=!0,b=e.childNodes[c],c=0,!b))return c=a.rest?V(a.rest):
a.line,vb(F(Y(c),c.text.length),f);var k=3==b.nodeType?b:null,g=b;k||1!=b.childNodes.length||3!=b.firstChild.nodeType||(k=b.firstChild,c&&(c=k.nodeValue.length));for(;g.parentNode!=e;)g=g.parentNode;var h=a.measure,l=h.maps;if(b=d(k,g,c))return vb(b,f);e=g.nextSibling;for(k=k?k.nodeValue.length-c:0;e;e=e.nextSibling){if(b=d(e,e.firstChild,0))return vb(F(b.line,b.ch-k),f);k+=e.textContent.length}g=g.previousSibling;for(k=c;g;g=g.previousSibling){if(b=d(g,g.firstChild,-1))return vb(F(b.line,b.ch+k),
f);k+=e.textContent.length}}function vf(a,b,c,d,e){function f(a){return function(b){return b.id==a}}function k(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)""==c&&(c=b.textContent.replace(/\u200b/g,"")),g+=c;else{var c=b.getAttribute("cm-marker"),U;if(c)b=a.findMarks(F(d,0),F(e+1,0),f(+c)),b.length&&(U=b[0].find())&&(g+=lb(a.doc,U.from,U.to).join(l));else if("false"!=b.getAttribute("contenteditable")){for(U=0;U<b.childNodes.length;U++)k(b.childNodes[U]);/^(pre|div|p)$/i.test(b.nodeName)&&
(h=!0)}}}else 3==b.nodeType&&(b=b.nodeValue)&&(h&&(g+=l,h=!1),g+=b)}for(var g="",h=!1,l=a.doc.lineSeparator();;){k(b);if(b==c)break;b=b.nextSibling}return g}function Ra(a,b){this.ranges=a;this.primIndex=b}function Z(a,b){this.anchor=a;this.head=b}function Fa(a,b){var c=a[b];a.sort(function(a,b){return L(a.from(),b.from())});b=ka(a,c);for(c=1;c<a.length;c++){var d=a[c],e=a[c-1];if(0<=L(e.to(),d.from())){var f=Wa(e.from(),d.from()),k=bb(e.to(),d.to()),d=e.empty()?d.from()==d.head:e.from()==e.head;c<=
b&&--b;a.splice(--c,2,new Z(d?k:f,d?f:k))}}return new Ra(a,b)}function Na(a,b){return new Ra([new Z(a,b||a)],0)}function O(a,b){if(b.line<a.first)return F(a.first,0);var c=a.first+a.size-1;if(b.line>c)return F(c,J(a,c).text.length);var c=J(a,b.line).text.length,d=b.ch,c=null==d||d>c?F(b.line,c):0>d?F(b.line,0):b;return c}function $b(a,b){return b>=a.first&&b<a.first+a.size}function ae(a,b){for(var c=[],d=0;d<b.length;d++)c[d]=O(a,b[d]);return c}function ac(a,b,c,d){return a.cm&&a.cm.display.shift||
a.extend?(a=b.anchor,d&&(b=0>L(c,a),b!=0>L(d,a)?(a=c,c=d):b!=0>L(c,d)&&(c=d)),new Z(a,c)):new Z(d||c,c)}function xc(a,b,c,d){ia(a,new Ra([ac(a,a.sel.primary(),b,c)],0),d)}function be(a,b,c){for(var d=[],e=0;e<a.sel.ranges.length;e++)d[e]=ac(a,a.sel.ranges[e],b[e],null);b=Fa(d,a.sel.primIndex);ia(a,b,c)}function kd(a,b,c,d){var e=a.sel.ranges.slice(0);e[b]=c;ia(a,Fa(e,a.sel.primIndex),d)}function zf(a,b,c){c={ranges:b.ranges,update:function(b){this.ranges=[];for(var c=0;c<b.length;c++)this.ranges[c]=
new Z(O(a,b[c].anchor),O(a,b[c].head))},origin:c&&c.origin};ea(a,"beforeSelectionChange",a,c);a.cm&&ea(a.cm,"beforeSelectionChange",a.cm,c);return c.ranges!=b.ranges?Fa(c.ranges,c.ranges.length-1):b}function ce(a,b,c){var d=a.history.done,e=V(d);e&&e.ranges?(d[d.length-1]=b,yc(a,b,c)):ia(a,b,c)}function ia(a,b,c){yc(a,b,c);b=a.sel;var d=a.cm?a.cm.curOp.id:NaN,e=a.history,f=c&&c.origin,k;if(!(k=d==e.lastSelOp)&&(k=f&&e.lastSelOrigin==f)&&!(k=e.lastModTime==e.lastSelTime&&e.lastOrigin==f)){k=V(e.done);
var g=f.charAt(0);k="*"==g||"+"==g&&k.ranges.length==b.ranges.length&&k.somethingSelected()==b.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}k?e.done[e.done.length-1]=b:zc(b,e.done);e.lastSelTime=+new Date;e.lastSelOrigin=f;e.lastSelOp=d;c&&!1!==c.clearRedo&&de(e.undone)}function yc(a,b,c){if(Aa(a,"beforeSelectionChange")||a.cm&&Aa(a.cm,"beforeSelectionChange"))b=zf(a,b,c);var d=c&&c.bias||(0>L(b.primary().head,a.sel.primary().head)?-1:1);ee(a,fe(a,
b,d,!0));c&&!1===c.scroll||!a.cm||Bb(a.cm)}function ee(a,b){b.equals(a.sel)||(a.sel=b,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,ge(a.cm)),ta(a,"cursorActivity",a))}function he(a){ee(a,fe(a,a.sel,null,!1),Oa)}function fe(a,b,c,d){for(var e,f=0;f<b.ranges.length;f++){var k=b.ranges[f],g=b.ranges.length==a.sel.ranges.length&&a.sel.ranges[f],h=ld(a,k.anchor,g&&g.anchor,c,d),g=ld(a,k.head,g&&g.head,c,d);if(e||h!=k.anchor||g!=k.head)e||(e=b.ranges.slice(0,f)),e[f]=new Z(h,g)}return e?
Fa(e,b.primIndex):b}function Db(a,b,c,d,e){var f=J(a,b.line);if(f.markedSpans)for(var k=0;k<f.markedSpans.length;++k){var g=f.markedSpans[k],h=g.marker;if((null==g.from||(h.inclusiveLeft?g.from<=b.ch:g.from<b.ch))&&(null==g.to||(h.inclusiveRight?g.to>=b.ch:g.to>b.ch))){if(e&&(ea(h,"beforeCursorEnter"),h.explicitlyCleared))if(f.markedSpans){--k;continue}else break;if(h.atomic){if(c){var k=h.find(0>d?1:-1),l;if(0>d?h.inclusiveRight:h.inclusiveLeft)k=ie(a,k,-d,k&&k.line==b.line?f:null);if(k&&k.line==
b.line&&(l=L(k,c))&&(0>d?0>l:0<l))return Db(a,k,b,d,e)}c=h.find(0>d?-1:1);if(0>d?h.inclusiveLeft:h.inclusiveRight)c=ie(a,c,d,c.line==b.line?f:null);return c?Db(a,c,b,d,e):null}}}return b}function ld(a,b,c,d,e){d=d||1;b=Db(a,b,c,d,e)||!e&&Db(a,b,c,d,!0)||Db(a,b,c,-d,e)||!e&&Db(a,b,c,-d,!0);return b?b:(a.cantEdit=!0,F(a.first,0))}function ie(a,b,c,d){return 0>c&&0==b.ch?b.line>a.first?O(a,F(b.line-1)):null:0<c&&b.ch==(d||J(a,b.line)).text.length?b.line<a.first+a.size-1?F(b.line+1,0):null:new F(b.line,
b.ch+c)}function Yb(a){a.display.input.showSelection(a.display.input.prepareSelection())}function je(a,b){for(var c=a.doc,d={},e=d.cursors=document.createDocumentFragment(),f=d.selection=document.createDocumentFragment(),k=0;k<c.sel.ranges.length;k++)if(!1!==b||k!=c.sel.primIndex){var g=c.sel.ranges[k];if(!(g.from().line>=a.display.viewTo||g.to().line<a.display.viewFrom)){var h=g.empty();(h||a.options.showCursorWhenSelecting)&&ke(a,g.head,e);h||Af(a,g,f)}}return d}function ke(a,b,c){b=Ta(a,b,"div",
null,null,!a.options.singleCursorHeightPerLine);var d=c.appendChild(I("div","\u00a0","CodeMirror-cursor"));d.style.left=b.left+"px";d.style.top=b.top+"px";d.style.height=Math.max(0,b.bottom-b.top)*a.options.cursorHeight+"px";b.other&&(a=c.appendChild(I("div","\u00a0","CodeMirror-cursor CodeMirror-secondarycursor")),a.style.display="",a.style.left=b.other.left+"px",a.style.top=b.other.top+"px",a.style.height=.85*(b.other.bottom-b.other.top)+"px")}function Af(a,b,c){function d(a,b,c,oa){0>b&&(b=0);
b=Math.round(b);oa=Math.round(oa);g.appendChild(I("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?m-a:c)+"px; height: "+(oa-b)+"px"))}function e(b,c,f){var U=J(k,b),Sa=U.text.length,g,h;Bf(Ea(U),c||0,null==f?Sa:f,function(e,k,ga){var n=Ac(a,F(b,e),"div",U,"left"),sa,p;e==k?(sa=n,ga=p=n.left):(sa=Ac(a,F(b,k-1),"div",U,"right"),"rtl"==ga&&(ga=n,n=sa,sa=ga),ga=n.left,p=sa.right);null==c&&0==e&&(ga=l);3<sa.top-n.top&&(d(ga,n.top,null,n.bottom),ga=l,
n.bottom<sa.top&&d(ga,n.bottom,null,sa.top));null==f&&k==Sa&&(p=m);if(!g||n.top<g.top||n.top==g.top&&n.left<g.left)g=n;if(!h||sa.bottom>h.bottom||sa.bottom==h.bottom&&sa.right>h.right)h=sa;ga<l+1&&(ga=l);d(ga,sa.top,p-ga,sa.bottom)});return{start:g,end:h}}var f=a.display,k=a.doc,g=document.createDocumentFragment(),h=le(a.display),l=h.left,m=Math.max(f.sizerWidth,jb(a)-f.sizer.offsetLeft)-h.right,f=b.from();b=b.to();if(f.line==b.line)e(f.line,f.ch,b.ch);else{var n=J(k,f.line),h=J(k,b.line),h=Pa(n)==
Pa(h),f=e(f.line,f.ch,h?n.text.length+1:null).end;b=e(b.line,h?0:null,b.ch).start;h&&(f.top<b.top-2?(d(f.right,f.top,null,f.bottom),d(l,b.top,b.left,b.bottom)):d(f.right,f.top,b.left-f.right,f.bottom));f.bottom<b.top&&d(l,f.bottom,null,b.top)}c.appendChild(g)}function md(a){if(a.state.focused){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursorDiv.style.visibility="";0<a.options.cursorBlinkRate?b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):
0>a.options.cursorBlinkRate&&(b.cursorDiv.style.visibility="hidden")}}function Sb(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.viewTo&&a.state.highlight.set(b,Qb(Cf,a))}function Cf(a){var b=a.doc;b.frontier<b.first&&(b.frontier=b.first);if(!(b.frontier>=a.display.viewTo)){var c=+new Date+a.options.workTime,d=$a(b.mode,bc(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var k=f.styles,g=f.text.length>a.options.maxHighlightLength,
h=me(a,f,g?$a(b.mode,d):d,!0);f.styles=h.styles;var l=f.styleClasses;(h=h.classes)?f.styleClasses=h:l&&(f.styleClasses=null);l=!k||k.length!=f.styles.length||l!=h&&(!l||!h||l.bgClass!=h.bgClass||l.textClass!=h.textClass);for(h=0;!l&&h<k.length;++h)l=k[h]!=f.styles[h];l&&e.push(b.frontier);f.stateAfter=g?d:$a(b.mode,d)}else f.text.length<=a.options.maxHighlightLength&&nd(a,f.text,d),f.stateAfter=0==b.frontier%5?$a(b.mode,d):null;++b.frontier;if(+new Date>c)return Sb(a,a.options.workDelay),!0});e.length&&
va(a,function(){for(var b=0;b<e.length;b++)Ua(a,e[b],"text")})}}function Df(a,b,c){for(var d,e,f=a.doc,k=c?-1:b-(a.doc.mode.innerMode?1E3:100);b>k;--b){if(b<=f.first)return f.first;var g=J(f,b-1);if(g.stateAfter&&(!c||b<=f.frontier))return b;g=Ga(g.text,null,a.options.tabSize);if(null==e||d>g)e=b-1,d=g}return e}function bc(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=Df(a,b,c),k=f>d.first&&J(d,f-1).stateAfter,k=k?$a(d.mode,k):Ef(d.mode);d.iter(f,b,function(c){nd(a,c.text,k);
c.stateAfter=f==b-1||0==f%5||f>=e.viewFrom&&f<e.viewTo?$a(d.mode,k):null;++f});c&&(d.frontier=f);return k}function fd(a){return a.mover.offsetHeight-a.lineSpace.offsetHeight}function le(a){if(a.cachedPaddingH)return a.cachedPaddingH;var b=wa(a.measure,I("pre","x")),b=window.getComputedStyle?window.getComputedStyle(b):b.currentStyle,b={left:parseInt(b.paddingLeft),right:parseInt(b.paddingRight)};isNaN(b.left)||isNaN(b.right)||(a.cachedPaddingH=b);return b}function Ka(a){return Vd-a.display.nativeBarWidth}
function jb(a){return a.display.scroller.clientWidth-Ka(a)-a.display.barWidth}function hd(a){return a.display.scroller.clientHeight-Ka(a)-a.display.barHeight}function Zd(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;d<a.rest.length;d++)if(a.rest[d]==b)return{map:a.measure.maps[d],cache:a.measure.caches[d]};for(d=0;d<a.rest.length;d++)if(Y(a.rest[d])>c)return{map:a.measure.maps[d],cache:a.measure.caches[d],before:!0}}function id(a,b){if(b>=a.display.viewFrom&&b<a.display.viewTo)return a.display.view[kb(a,
b)];var c=a.display.externalMeasured;if(c&&b>=c.lineN&&b<c.lineN+c.size)return c}function Bc(a,b){var c=Y(b),d=id(a,c);d&&!d.text?d=null:d&&d.changes&&(ja(a,d,c,X(a)),a.curOp.forceUpdate=!0);if(!d){var e;e=Pa(b);d=Y(e);e=a.display.externalMeasured=new ne(a.doc,e,d);e.lineN=d;d=e.built=Yd(a,e);e.text=d.pre;wa(a.display.lineMeasure,d.pre);d=e}c=Zd(d,b,c);return{line:b,view:d,rect:null,map:c.map,cache:c.cache,before:c.before,hasHeights:!1}}function Cc(a,b,c,d,e){b.before&&(c=-1);var f=c+(d||"");if(b.cache.hasOwnProperty(f))a=
b.cache[f];else{b.rect||(b.rect=b.view.text.getBoundingClientRect());if(!b.hasHeights){var k=b.view,g=b.rect,h=a.options.lineWrapping,l=h&&jb(a);if(!k.measure.heights||h&&k.measure.width!=l){var m=k.measure.heights=[];if(h)for(k.measure.width=l,k=k.text.firstChild.getClientRects(),h=0;h<k.length-1;h++){var l=k[h],n=k[h+1];2<Math.abs(l.bottom-n.bottom)&&m.push((l.bottom+n.top)/2-g.top)}m.push(g.bottom-g.top)}b.hasHeights=!0}k=d;h=$d(b.map,c,k);d=h.node;g=h.start;l=h.end;c=h.collapse;var p;if(3==d.nodeType){for(m=
0;4>m;m++){for(;g&&cc(b.line.text.charAt(h.coverStart+g));)--g;for(;h.coverStart+l<h.coverEnd&&cc(b.line.text.charAt(h.coverStart+l));)++l;if(S&&9>ba&&0==g&&l==h.coverEnd-h.coverStart)p=d.parentNode.getBoundingClientRect();else if(S&&a.options.lineWrapping){var q=mb(d,g,l).getClientRects();p=q.length?q["right"==k?q.length-1:0]:od}else p=mb(d,g,l).getBoundingClientRect()||od;if(p.left||p.right||0==g)break;l=g;--g;c="right"}S&&11>ba&&((q=!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==
screen.deviceXDPI)||(null!=pd?q=pd:(m=wa(a.display.measure,I("span","x")),q=m.getBoundingClientRect(),m=mb(m,0,1).getBoundingClientRect(),q=pd=1<Math.abs(q.left-m.left)),q=!q),q||(q=screen.logicalXDPI/screen.deviceXDPI,m=screen.logicalYDPI/screen.deviceYDPI,p={left:p.left*q,right:p.right*q,top:p.top*m,bottom:p.bottom*m}))}else 0<g&&(c=k="right"),p=a.options.lineWrapping&&1<(q=d.getClientRects()).length?q["right"==k?q.length-1:0]:d.getBoundingClientRect();!(S&&9>ba)||g||p&&(p.left||p.right)||(p=(p=
d.parentNode.getClientRects()[0])?{left:p.left,right:p.left+Tb(a.display),top:p.top,bottom:p.bottom}:od);q=p.top-b.rect.top;d=p.bottom-b.rect.top;g=(q+d)/2;k=b.view.measure.heights;for(m=0;m<k.length-1&&!(g<k[m]);m++);c={left:("right"==c?p.right:p.left)-b.rect.left,right:("left"==c?p.left:p.right)-b.rect.left,top:m?k[m-1]:0,bottom:k[m]};p.left||p.right||(c.bogus=!0);a.options.singleCursorHeightPerLine||(c.rtop=q,c.rbottom=d);a=c;a.bogus||(b.cache[f]=a)}return{left:a.left,right:a.right,top:e?a.rtop:
a.top,bottom:e?a.rbottom:a.bottom}}function $d(a,b,c){for(var d,e,f,k,g=0;g<a.length;g+=3){var h=a[g],l=a[g+1];if(b<h)e=0,f=1,k="left";else if(b<l)e=b-h,f=e+1;else if(g==a.length-3||b==l&&a[g+3]>b)f=l-h,e=f-1,b>=l&&(k="right");if(null!=e){d=a[g+2];h==l&&c==(d.insertLeft?"left":"right")&&(k=c);if("left"==c&&0==e)for(;g&&a[g-2]==a[g-3]&&a[g-1].insertLeft;)d=a[(g-=3)+2],k="left";if("right"==c&&e==l-h)for(;g<a.length-3&&a[g+3]==a[g+4]&&!a[g+5].insertLeft;)d=a[(g+=3)+2],k="right";break}}return{node:d,
start:e,end:f,collapse:k,coverStart:h,coverEnd:l}}function oe(a){if(a.measure&&(a.measure.cache={},a.measure.heights=null,a.rest))for(var b=0;b<a.rest.length;b++)a.measure.caches[b]={}}function pe(a){a.display.externalMeasure=null;gb(a.display.lineMeasure);for(var b=0;b<a.display.view.length;b++)oe(a.display.view[b])}function Ub(a){pe(a);a.display.cachedCharWidth=a.display.cachedTextHeight=a.display.cachedPaddingH=null;a.options.lineWrapping||(a.display.maxLineChanged=!0);a.display.lineNumChars=null}
function qd(a,b,c,d){if(b.widgets)for(var e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=dc(b.widgets[e]);c.top+=f;c.bottom+=f}if("line"==d)return c;d||(d="local");b=La(b);b="local"==d?b+a.display.lineSpace.offsetTop:b-a.display.viewOffset;if("page"==d||"window"==d)a=a.display.lineSpace.getBoundingClientRect(),b+=a.top+("window"==d?0:window.pageYOffset||(document.documentElement||document.body).scrollTop),d=a.left+("window"==d?0:window.pageXOffset||(document.documentElement||document.body).scrollLeft),
c.left+=d,c.right+=d;c.top+=b;c.bottom+=b;return c}function qe(a,b,c){if("div"==c)return b;var d=b.left;b=b.top;"page"==c?(d-=window.pageXOffset||(document.documentElement||document.body).scrollLeft,b-=window.pageYOffset||(document.documentElement||document.body).scrollTop):"local"!=c&&c||(c=a.display.sizer.getBoundingClientRect(),d+=c.left,b+=c.top);a=a.display.lineSpace.getBoundingClientRect();return{left:d-a.left,top:b-a.top}}function Ac(a,b,c,d,e){d||(d=J(a.doc,b.line));var f=d;b=b.ch;d=Cc(a,
Bc(a,d),b,e);return qd(a,f,d,c)}function Ta(a,b,c,d,e,f){function k(b,U){var g=Cc(a,e,b,U?"right":"left",f);U?g.left=g.right:g.right=g.left;return qd(a,d,g,c)}function g(a,b){var c=h[b],d=c.level%2;a==rd(c)&&b&&c.level<h[b-1].level?(c=h[--b],a=sd(c)-(c.level%2?0:1),d=!0):a==sd(c)&&b<h.length-1&&c.level<h[b+1].level&&(c=h[++b],a=rd(c)-c.level%2,d=!1);return d&&a==c.to&&a>c.from?k(a-1):k(a,d)}d=d||J(a.doc,b.line);e||(e=Bc(a,d));var h=Ea(d);b=b.ch;if(!h)return k(b);var l=wc(h,b),l=g(b,l);null!=ec&&(l.other=
g(b,ec));return l}function re(a,b){var c=0;b=O(a.doc,b);a.options.lineWrapping||(c=Tb(a.display)*b.ch);var d=J(a.doc,b.line),e=La(d)+a.display.lineSpace.offsetTop;return{left:c,right:c,top:e,bottom:e+d.height}}function Dc(a,b,c,d){a=F(a,b);a.xRel=d;c&&(a.outside=!0);return a}function td(a,b,c){var d=a.doc;c+=a.display.viewOffset;if(0>c)return Dc(d.first,0,!0,-1);var e=ib(d,c),f=d.first+d.size-1;if(e>f)return Dc(d.first+d.size-1,J(d,f).text.length,!0,1);0>b&&(b=0);for(d=J(d,e);;)if(e=Ff(a,d,e,b,c),
f=(d=hb(d,!1))&&d.find(0,!0),d&&(e.ch>f.from.ch||e.ch==f.from.ch&&0<e.xRel))e=Y(d=f.to.line);else return e}function Ff(a,b,c,d,e){function f(d){d=Ta(a,F(c,d),"line",b,l);g=!0;if(k>d.bottom)return d.left-h;if(k<d.top)return d.left+h;g=!1;return d.left}var k=e-La(b),g=!1,h=2*a.display.wrapper.clientWidth,l=Bc(a,b);e=Ea(b);var m=b.text.length,n=Ec(b),p=Fc(b),q=f(n),r=g,u=f(p),t=g;if(d>u)return Dc(c,p,t,1);for(;;){if(e?p==n||p==ud(b,n,1):1>=p-n){m=d<q||d-q<=u-d?n:p;r=m==n?r:t;n=d-(m==n?q:u);t&&!e&&!/\s/.test(b.text.charAt(m))&&
0<n&&m<b.text.length&&1<l.view.measure.heights.length&&(e=Cc(a,l,m,"right"),k<=e.bottom&&k>=e.top&&Math.abs(d-e.right)<n&&(r=!1,m++,n=d-e.right));for(;cc(b.text.charAt(m));)++m;return Dc(c,m,r,-1>n?-1:1<n?1:0)}var w=Math.ceil(m/2),y=n+w;if(e)for(var y=n,v=0;v<w;++v)y=ud(b,y,1);v=f(y);if(v>d){p=y;u=v;if(t=g)u+=1E3;m=w}else n=y,q=v,r=g,m-=w}}function eb(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==nb){nb=I("pre");for(var b=0;49>b;++b)nb.appendChild(document.createTextNode("x")),
nb.appendChild(I("br"));nb.appendChild(document.createTextNode("x"))}wa(a.measure,nb);b=nb.offsetHeight/50;3<b&&(a.cachedTextHeight=b);gb(a.measure);return b||1}function Tb(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=I("span","xxxxxxxxxx"),c=I("pre",[b]);wa(a.measure,c);b=b.getBoundingClientRect();b=(b.right-b.left)/10;2<b&&(a.cachedCharWidth=b);return b||10}function wb(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,
cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Gf};Eb?Eb.ops.push(a.curOp):a.curOp.ownsGroup=Eb={ops:[a.curOp],delayedCallbacks:[]}}function yb(a){if(a=a.curOp.ownsGroup)try{var b=a.delayedCallbacks,c=0;do{for(;c<b.length;c++)b[c].call(null);for(var d=0;d<a.ops.length;d++){var e=a.ops[d];if(e.cursorActivityHandlers)for(;e.cursorActivityCalled<e.cursorActivityHandlers.length;)e.cursorActivityHandlers[e.cursorActivityCalled++].call(null,
e.cm)}}while(c<b.length)}finally{Eb=null;for(b=0;b<a.ops.length;b++)a.ops[b].cm.curOp=null;a=a.ops;for(b=0;b<a.length;b++){var e=a[b],c=e.cm,f=d=c.display;!f.scrollbarsClipped&&f.scroller.offsetWidth&&(f.nativeBarWidth=f.scroller.offsetWidth-f.scroller.clientWidth,f.heightForcer.style.height=Ka(c)+"px",f.sizer.style.marginBottom=-f.nativeBarWidth+"px",f.sizer.style.borderRightWidth=Ka(c)+"px",f.scrollbarsClipped=!0);e.updateMaxLine&&t(c);e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||
e.scrollToPos&&(e.scrollToPos.from.line<d.viewFrom||e.scrollToPos.to.line>=d.viewTo)||d.maxLineChanged&&c.options.lineWrapping;e.update=e.mustUpdate&&new H(c,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}for(b=0;b<a.length;b++)e=a[b],e.updatedDisplay=e.mustUpdate&&G(e.cm,e.update);for(b=0;b<a.length;b++)if(e=a[b],c=e.cm,d=c.display,e.updatedDisplay&&Q(c),e.barMeasure=v(c),d.maxLineChanged&&!c.options.lineWrapping&&(f=void 0,f=d.maxLine.text.length,f=Cc(c,Bc(c,d.maxLine),f,void 0),
e.adjustWidthTo=f.left+3,c.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(d.scroller.clientWidth,d.sizer.offsetLeft+e.adjustWidthTo+Ka(c)+c.display.barWidth),e.maxScrollLeft=Math.max(0,d.sizer.offsetLeft+e.adjustWidthTo-jb(c))),e.updatedDisplay||e.selectionChanged)e.preparedSelection=d.input.prepareSelection(e.focus);for(b=0;b<a.length;b++)e=a[b],c=e.cm,null!=e.adjustWidthTo&&(c.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<c.doc.scrollLeft&&zb(c,Math.min(c.display.scroller.scrollLeft,
e.maxScrollLeft),!0),c.display.maxLineChanged=!1),d=e.focus&&e.focus==Ma()&&(!document.hasFocus||document.hasFocus()),e.preparedSelection&&c.display.input.showSelection(e.preparedSelection,d),(e.updatedDisplay||e.startHeight!=c.doc.height)&&C(c,e.barMeasure),e.updatedDisplay&&W(c,e.barMeasure),e.selectionChanged&&md(c),c.state.focused&&e.updateInput&&c.display.input.reset(e.typing),d&&cb(e.cm);for(b=0;b<a.length;b++){e=a[b];c=e.cm;d=c.display;f=c.doc;e.updatedDisplay&&P(c,e.update);null==d.wheelStartX||
null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(d.wheelStartX=d.wheelStartY=null);null==e.scrollTop||d.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(f.scrollTop=Math.max(0,Math.min(d.scroller.scrollHeight-d.scroller.clientHeight,e.scrollTop)),d.scrollbars.setScrollTop(f.scrollTop),d.scroller.scrollTop=f.scrollTop);null==e.scrollLeft||d.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(f.scrollLeft=Math.max(0,Math.min(d.scroller.scrollWidth-d.scroller.clientWidth,e.scrollLeft)),d.scrollbars.setScrollLeft(f.scrollLeft),
d.scroller.scrollLeft=f.scrollLeft,B(c));if(e.scrollToPos){var k=void 0,g=O(f,e.scrollToPos.from),k=O(f,e.scrollToPos.to),h=e.scrollToPos.margin;null==h&&(h=0);for(var l=0;5>l;l++){var m=!1,n=Ta(c,g),p=k&&k!=g?Ta(c,k):n,p=Gc(c,Math.min(n.left,p.left),Math.min(n.top,p.top)-h,Math.max(n.left,p.left),Math.max(n.bottom,p.bottom)+h),q=c.doc.scrollTop,r=c.doc.scrollLeft;null!=p.scrollTop&&(Wb(c,p.scrollTop),1<Math.abs(c.doc.scrollTop-q)&&(m=!0));null!=p.scrollLeft&&(zb(c,p.scrollLeft),1<Math.abs(c.doc.scrollLeft-
r)&&(m=!0));if(!m)break}k=n;e.scrollToPos.isCursor&&c.state.focused&&(fa(c,"scrollCursorIntoView")||(h=c.display,l=h.sizer.getBoundingClientRect(),g=null,0>k.top+l.top?g=!0:k.bottom+l.top>(window.innerHeight||document.documentElement.clientHeight)&&(g=!1),null==g||Hf||(k=I("div","\u200b",null,"position: absolute; top: "+(k.top-h.viewOffset-c.display.lineSpace.offsetTop)+"px; height: "+(k.bottom-k.top+Ka(c)+h.barHeight)+"px; left: "+k.left+"px; width: 2px;"),c.display.lineSpace.appendChild(k),k.scrollIntoView(g),
c.display.lineSpace.removeChild(k))))}g=e.maybeHiddenMarkers;k=e.maybeUnhiddenMarkers;if(g)for(h=0;h<g.length;++h)g[h].lines.length||ea(g[h],"hide");if(k)for(h=0;h<k.length;++h)k[h].lines.length&&ea(k[h],"unhide");d.wrapper.offsetHeight&&(f.scrollTop=c.display.scroller.scrollTop);e.changeObjs&&ea(c,"changes",c,e.changeObjs);e.update&&e.update.finish()}}}function va(a,b){if(a.curOp)return b();wb(a);try{return b()}finally{yb(a)}}function da(a,b){return function(){if(a.curOp)return b.apply(a,arguments);
wb(a);try{return b.apply(a,arguments)}finally{yb(a)}}}function la(a){return function(){if(this.curOp)return a.apply(this,arguments);wb(this);try{return a.apply(this,arguments)}finally{yb(this)}}}function ma(a){return function(){var b=this.cm;if(!b||b.curOp)return a.apply(this,arguments);wb(b);try{return a.apply(this,arguments)}finally{yb(b)}}}function ne(a,b,c){for(var d=this.line=b,e;d=hb(d,!1);)d=d.find(1,!0).line,(e||(e=[])).push(d);this.size=(this.rest=e)?Y(V(this.rest))-c+1:1;this.node=this.text=
null;this.hidden=fb(a,b)}function uc(a,b,c){var d=[],e;for(e=b;e<c;)b=new ne(a.doc,J(a.doc,e),e),e+=b.size,d.push(b);return d}function pa(a,b,c,d){null==b&&(b=a.doc.first);null==c&&(c=a.doc.first+a.doc.size);d||(d=0);var e=a.display;d&&c<e.viewTo&&(null==e.updateLineNumbers||e.updateLineNumbers>b)&&(e.updateLineNumbers=b);a.curOp.viewChanged=!0;if(b>=e.viewTo)Za&&gd(a.doc,b)<e.viewTo&&Ya(a);else if(c<=e.viewFrom)Za&&Xd(a.doc,c+d)>e.viewFrom?Ya(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&
c>=e.viewTo)Ya(a);else if(b<=e.viewFrom){var f=Hc(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):Ya(a)}else if(c>=e.viewTo)(f=Hc(a,b,b,-1))?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):Ya(a);else{var f=Hc(a,b,b,-1),k=Hc(a,c,c+d,1);f&&k?(e.view=e.view.slice(0,f.index).concat(uc(a,f.lineN,k.lineN)).concat(e.view.slice(k.index)),e.viewTo+=d):Ya(a)}if(a=e.externalMeasured)c<a.lineN?a.lineN+=d:b<a.lineN+a.size&&(e.externalMeasured=null)}function Ua(a,b,c){a.curOp.viewChanged=
!0;var d=a.display,e=a.display.externalMeasured;e&&b>=e.lineN&&b<e.lineN+e.size&&(d.externalMeasured=null);b<d.viewFrom||b>=d.viewTo||(a=d.view[kb(a,b)],null!=a.node&&(a=a.changes||(a.changes=[]),-1==ka(a,c)&&a.push(c)))}function Ya(a){a.display.viewFrom=a.display.viewTo=a.doc.first;a.display.view=[];a.display.viewOffset=0}function kb(a,b){if(b>=a.display.viewTo)return null;b-=a.display.viewFrom;if(0>b)return null;for(var c=a.display.view,d=0;d<c.length;d++)if(b-=c[d].size,0>b)return d}function Hc(a,
b,c,d){var e=kb(a,b),f=a.display.view;if(!Za||c==a.doc.first+a.doc.size)return{index:e,lineN:c};for(var k=0,g=a.display.viewFrom;k<e;k++)g+=f[k].size;if(g!=b){if(0<d){if(e==f.length-1)return null;b=g+f[e].size-b;e++}else b=g-b;c+=b}for(;gd(a.doc,c)!=c;){if(e==(0>d?0:f.length-1))return null;c+=d*f[e-(0>d?1:0)].size;e+=d}return{index:e,lineN:c}}function Wd(a){a=a.display.view;for(var b=0,c=0;c<a.length;c++){var d=a[c];d.hidden||d.node&&!d.changes||++b}return b}function xf(a){function b(){d.activeTouch&&
(e=setTimeout(function(){d.activeTouch=null},1E3),f=d.activeTouch,f.end=+new Date)}function c(a,b){if(null==b.left)return!0;var d=b.left-a.left,e=b.top-a.top;return 400<d*d+e*e}var d=a.display;K(d.scroller,"mousedown",da(a,If));S&&11>ba?K(d.scroller,"dblclick",da(a,function(b){if(!fa(a,b)){var c=ob(a,b);!c||vd(a,b,"gutterClick",!0)||Va(a.display,b)||(na(b),b=a.findWordAt(c),xc(a.doc,b.anchor,b.head))}})):K(d.scroller,"dblclick",function(b){fa(a,b)||na(b)});wd||K(d.scroller,"contextmenu",function(b){se(a,
b)});var e,f={end:0};K(d.scroller,"touchstart",function(b){var c;if(c=!fa(a,b))1!=b.touches.length?c=!1:(c=b.touches[0],c=1>=c.radiusX&&1>=c.radiusY),c=!c;c&&(clearTimeout(e),c=+new Date,d.activeTouch={start:c,moved:!1,prev:300>=c-f.end?f:null},1==b.touches.length&&(d.activeTouch.left=b.touches[0].pageX,d.activeTouch.top=b.touches[0].pageY))});K(d.scroller,"touchmove",function(){d.activeTouch&&(d.activeTouch.moved=!0)});K(d.scroller,"touchend",function(e){var f=d.activeTouch;if(f&&!Va(d,e)&&null!=
f.left&&!f.moved&&300>new Date-f.start){var k=a.coordsChar(d.activeTouch,"page"),f=!f.prev||c(f,f.prev)?new Z(k,k):!f.prev.prev||c(f,f.prev.prev)?a.findWordAt(k):new Z(F(k.line,0),O(a.doc,F(k.line+1,0)));a.setSelection(f.anchor,f.head);a.focus();na(e)}b()});K(d.scroller,"touchcancel",b);K(d.scroller,"scroll",function(){d.scroller.clientHeight&&(Wb(a,d.scroller.scrollTop),zb(a,d.scroller.scrollLeft,!0),ea(a,"scroll",a))});K(d.scroller,"mousewheel",function(b){te(a,b)});K(d.scroller,"DOMMouseScroll",
function(b){te(a,b)});K(d.wrapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0});d.dragFunctions={enter:function(b){fa(a,b)||Ic(b)},over:function(b){if(!fa(a,b)){var c=ob(a,b);if(c){var d=document.createDocumentFragment();ke(a,c,d);a.display.dragCursor||(a.display.dragCursor=I("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),a.display.lineSpace.insertBefore(a.display.dragCursor,a.display.cursorDiv));wa(a.display.dragCursor,d)}Ic(b)}},start:function(b){if(S&&(!a.state.draggingText||
100>+new Date-ue))Ic(b);else if(!fa(a,b)&&!Va(a.display,b)&&(b.dataTransfer.setData("Text",a.getSelection()),b.dataTransfer.effectAllowed="copyMove",b.dataTransfer.setDragImage&&!ve)){var c=I("img",null,null,"position: fixed; left: 0; top: 0;");c.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";Ha&&(c.width=c.height=1,a.display.wrapper.appendChild(c),c._top=c.offsetTop);b.dataTransfer.setDragImage(c,0,0);Ha&&c.parentNode.removeChild(c)}},drop:da(a,Jf),leave:function(b){fa(a,
b)||we(a)}};var k=d.input.getField();K(k,"keyup",function(b){xe.call(a,b)});K(k,"keydown",da(a,ye));K(k,"keypress",da(a,ze));K(k,"focus",Qb(dd,a));K(k,"blur",Qb(Rb,a))}function Kf(a){var b=a.display;if(b.lastWrapHeight!=b.wrapper.clientHeight||b.lastWrapWidth!=b.wrapper.clientWidth)b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,b.scrollbarsClipped=!1,a.setSize()}function Va(a,b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(!c||1==c.nodeType&&"true"==c.getAttribute("cm-ignore-events")||
c.parentNode==a.sizer&&c!=a.mover)return!0}function ob(a,b,c,d){var e=a.display;if(!c&&"true"==(b.target||b.srcElement).getAttribute("cm-not-content"))return null;var f,k;c=e.lineSpace.getBoundingClientRect();try{f=b.clientX-c.left,k=b.clientY-c.top}catch(g){return null}b=td(a,f,k);var h;d&&1==b.xRel&&(h=J(a.doc,b.line).text).length==b.ch&&(d=Ga(h,h.length,a.options.tabSize)-h.length,b=F(b.line,Math.max(0,Math.round((f-le(a.display).left)/Tb(a.display))-d)));return b}function If(a){var b=this.display;
if(!(fa(this,a)||b.activeTouch&&b.input.supportsTouch()))if(b.shift=a.shiftKey,Va(b,a))ha||(b.scroller.draggable=!1,setTimeout(function(){b.scroller.draggable=!0},100));else if(!vd(this,a,"gutterClick",!0)){var c=ob(this,a);window.focus();switch(Ae(a)){case 1:this.state.selectingText?this.state.selectingText(a):c?Lf(this,a,c):(a.target||a.srcElement)==b.scroller&&na(a);break;case 2:ha&&(this.state.lastMiddleDown=+new Date);c&&xc(this.doc,c);setTimeout(function(){b.input.focus()},20);na(a);break;case 3:wd?
se(this,a):Mf(this)}}}function Lf(a,b,c){S?setTimeout(Qb(cb,a),0):a.curOp.focus=Ma();var d=+new Date,e;Jc&&Jc.time>d-400&&0==L(Jc.pos,c)?e="triple":Kc&&Kc.time>d-400&&0==L(Kc.pos,c)?(e="double",Jc={time:d,pos:c}):(e="single",Kc={time:d,pos:c});var d=a.doc.sel,f=Da?b.metaKey:b.ctrlKey,k;a.options.dragDrop&&Nf&&!a.isReadOnly()&&"single"==e&&-1<(k=d.contains(c))&&(0>L((k=d.ranges[k]).from(),c)||0<c.xRel)&&(0<L(k.to(),c)||0>c.xRel)?Of(a,b,c,f):Pf(a,b,c,e,f)}function Of(a,b,c,d){var e=a.display,f=+new Date,
k=da(a,function(g){ha&&(e.scroller.draggable=!1);a.state.draggingText=!1;Qa(document,"mouseup",k);Qa(e.scroller,"drop",k);10>Math.abs(b.clientX-g.clientX)+Math.abs(b.clientY-g.clientY)&&(na(g),!d&&+new Date-200<f&&xc(a.doc,c),ha||S&&9==ba?setTimeout(function(){document.body.focus();e.input.focus()},20):e.input.focus())});ha&&(e.scroller.draggable=!0);a.state.draggingText=k;k.copy=Da?b.altKey:b.ctrlKey;e.scroller.dragDrop&&e.scroller.dragDrop();K(document,"mouseup",k);K(e.scroller,"drop",k)}function Pf(a,
b,c,d,e){function f(b){if(0!=L(u,b))if(u=b,"rect"==d){for(var e=[],U=a.options.tabSize,k=Ga(J(l,c.line).text,c.ch,U),g=Ga(J(l,b.line).text,b.ch,U),h=Math.min(k,g),k=Math.max(k,g),g=Math.min(c.line,b.line),ga=Math.min(a.lastLine(),Math.max(c.line,b.line));g<=ga;g++){var q=J(l,g).text,r=Be(q,h,U);h==k?e.push(new Z(F(g,r),F(g,r))):q.length>r&&e.push(new Z(F(g,r),F(g,Be(q,k,U))))}e.length||e.push(new Z(c,c));ia(l,Fa(p.ranges.slice(0,n).concat(e),n),{origin:"*mouse",scroll:!1});a.scrollIntoView(b)}else e=
m,U=e.anchor,h=b,"single"!=d&&(b="double"==d?a.findWordAt(b):new Z(F(b.line,0),O(l,F(b.line+1,0))),0<L(b.anchor,U)?(h=b.head,U=Wa(e.from(),b.anchor)):(h=b.anchor,U=bb(e.to(),b.head))),e=p.ranges.slice(0),e[n]=new Z(O(l,U),h),ia(l,Fa(e,n),xd)}function k(b){var c=++w,e=ob(a,b,!0,"rect"==d);if(e)if(0!=L(e,u)){a.curOp.focus=Ma();f(e);var U=y(h,l);(e.line>=U.to||e.line<U.from)&&setTimeout(da(a,function(){w==c&&k(b)}),150)}else{var g=b.clientY<t.top?-20:b.clientY>t.bottom?20:0;g&&setTimeout(da(a,function(){w==
c&&(h.scroller.scrollTop+=g,k(b))}),50)}}function g(b){a.state.selectingText=!1;w=Infinity;na(b);h.input.focus();Qa(document,"mousemove",v);Qa(document,"mouseup",z);l.history.lastSelOrigin=null}var h=a.display,l=a.doc;na(b);var m,n,p=l.sel,q=p.ranges;e&&!b.shiftKey?(n=l.sel.contains(c),m=-1<n?q[n]:new Z(c,c)):(m=l.sel.primary(),n=l.sel.primIndex);if(Qf?b.shiftKey&&b.metaKey:b.altKey)d="rect",e||(m=new Z(c,c)),c=ob(a,b,!0,!0),n=-1;else if("double"==d){var r=a.findWordAt(c);m=a.display.shift||l.extend?
ac(l,m,r.anchor,r.head):r}else"triple"==d?(r=new Z(F(c.line,0),O(l,F(c.line+1,0))),m=a.display.shift||l.extend?ac(l,m,r.anchor,r.head):r):m=ac(l,m,c);e?-1==n?(n=q.length,ia(l,Fa(q.concat([m]),n),{scroll:!1,origin:"*mouse"})):1<q.length&&q[n].empty()&&"single"==d&&!b.shiftKey?(ia(l,Fa(q.slice(0,n).concat(q.slice(n+1)),0),{scroll:!1,origin:"*mouse"}),p=l.sel):kd(l,n,m,xd):(n=0,ia(l,new Ra([m],0),xd),p=l.sel);var u=c,t=h.wrapper.getBoundingClientRect(),w=0,v=da(a,function(a){Ae(a)?k(a):g(a)}),z=da(a,
g);a.state.selectingText=z;K(document,"mousemove",v);K(document,"mouseup",z)}function vd(a,b,c,d){try{var e=b.clientX,f=b.clientY}catch(k){return!1}if(e>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&na(b);d=a.display;var g=d.lineDiv.getBoundingClientRect();if(f>g.bottom||!Aa(a,c))return yd(b);f-=g.top-d.viewOffset;for(g=0;g<a.options.gutters.length;++g){var h=d.gutters.childNodes[g];if(h&&h.getBoundingClientRect().right>=e)return e=ib(a.doc,f),ea(a,c,a,e,a.options.gutters[g],
b),yd(b)}}function Jf(a){var b=this;we(b);if(!fa(b,a)&&!Va(b.display,a)){na(a);S&&(ue=+new Date);var c=ob(b,a,!0),d=a.dataTransfer.files;if(c&&!b.isReadOnly())if(d&&d.length&&window.FileReader&&window.File){var e=d.length,f=Array(e),k=0;a=function(a,d){if(!b.options.allowDropFileTypes||-1!=ka(b.options.allowDropFileTypes,a.type)){var oa=new FileReader;oa.onload=da(b,function(){var a=oa.result;/[\x00-\x08\x0e-\x1f]{2}/.test(a)&&(a="");f[d]=a;++k==e&&(c=O(b.doc,c),a={from:c,to:c,text:b.doc.splitLines(f.join(b.doc.lineSeparator())),
origin:"paste"},Ab(b.doc,a),ce(b.doc,Na(c,pb(a))))});oa.readAsText(a)}};for(var g=0;g<e;++g)a(d[g],g)}else if(b.state.draggingText&&-1<b.doc.sel.contains(c))b.state.draggingText(a),setTimeout(function(){b.display.input.focus()},20);else try{if(f=a.dataTransfer.getData("Text")){if(b.state.draggingText&&!b.state.draggingText.copy)var h=b.listSelections();yc(b.doc,Na(c,c));if(h)for(g=0;g<h.length;++g)Fb(b.doc,"",h[g].anchor,h[g].head,"drag");b.replaceSelection(f,"around","paste");b.display.input.focus()}}catch(l){}}}
function we(a){a.display.dragCursor&&(a.display.lineSpace.removeChild(a.display.dragCursor),a.display.dragCursor=null)}function Wb(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,Xa||R(a,{top:b}),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbars.setScrollTop(b),Xa&&R(a),Sb(a,100))}function zb(a,b,c){(c?b==a.doc.scrollLeft:2>Math.abs(a.doc.scrollLeft-b))||(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,B(a),
a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function te(a,b){var c=Ce(b),d=c.x,c=c.y,e=a.display,f=e.scroller,k=f.scrollWidth>f.clientWidth,g=f.scrollHeight>f.clientHeight;if(d&&k||c&&g){if(c&&Da&&ha){var k=b.target,h=e.view;a:for(;k!=f;k=k.parentNode)for(var l=0;l<h.length;l++)if(h[l].node==k){a.display.currentWheelTarget=k;break a}}!d||Xa||Ha||null==xa?(c&&null!=xa&&(g=c*xa,k=a.doc.scrollTop,h=k+e.wrapper.clientHeight,0>g?k=Math.max(0,
k+g-50):h=Math.min(a.doc.height,h+g+50),R(a,{top:k,bottom:h})),20>Lc&&(null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=d,e.wheelDY=c,setTimeout(function(){if(null!=e.wheelStartX){var a=f.scrollLeft-e.wheelStartX,b=f.scrollTop-e.wheelStartY,a=b&&e.wheelDY&&b/e.wheelDY||a&&e.wheelDX&&a/e.wheelDX;e.wheelStartX=e.wheelStartY=null;a&&(xa=(xa*Lc+a)/(Lc+1),++Lc)}},200)):(e.wheelDX+=d,e.wheelDY+=c))):(c&&g&&Wb(a,Math.max(0,Math.min(f.scrollTop+c*xa,f.scrollHeight-f.clientHeight))),
zb(a,Math.max(0,Math.min(f.scrollLeft+d*xa,f.scrollWidth-f.clientWidth))),(!c||c&&g)&&na(b),e.wheelStartX=null)}}function Mc(a,b,c){if("string"==typeof b&&(b=Nc[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=De}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function Rf(a,b,c){for(var d=0;d<a.state.keyMaps.length;d++){var e=fc(b,a.state.keyMaps[d],c,a);if(e)return e}return a.options.extraKeys&&
fc(b,a.options.extraKeys,c,a)||fc(b,a.options.keyMap,c,a)}function Oc(a,b,c,d){var e=a.state.keySeq;if(e){if(Sf(b))return"handled";Tf.set(50,function(){a.state.keySeq==e&&(a.state.keySeq=null,a.display.input.reset())});b=e+" "+b}d=Rf(a,b,d);"multi"==d&&(a.state.keySeq=b);"handled"==d&&ta(a,"keyHandled",a,b,c);if("handled"==d||"multi"==d)na(c),md(a);return e&&!d&&/\'$/.test(b)?(na(c),!0):!!d}function Ee(a,b){var c=Uf(b,!0);return c?b.shiftKey&&!a.state.keySeq?Oc(a,"Shift-"+c,b,function(b){return Mc(a,
b,!0)})||Oc(a,c,b,function(b){if("string"==typeof b?/^go[A-Z]/.test(b):b.motion)return Mc(a,b)}):Oc(a,c,b,function(b){return Mc(a,b)}):!1}function Vf(a,b,c){return Oc(a,"'"+c+"'",b,function(b){return Mc(a,b,!0)})}function ye(a){this.curOp.focus=Ma();if(!fa(this,a)){S&&11>ba&&27==a.keyCode&&(a.returnValue=!1);var b=a.keyCode;this.display.shift=16==b||a.shiftKey;var c=Ee(this,a);Ha&&(zd=c?b:null,!c&&88==b&&!Fe&&(Da?a.metaKey:a.ctrlKey)&&this.replaceSelection("",null,"cut"));18!=b||/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)||
Wf(this)}}function Wf(a){function b(a){18!=a.keyCode&&a.altKey||(Vb(c,"CodeMirror-crosshair"),Qa(document,"keyup",b),Qa(document,"mouseover",b))}var c=a.display.lineDiv;Xb(c,"CodeMirror-crosshair");K(document,"keyup",b);K(document,"mouseover",b)}function xe(a){16==a.keyCode&&(this.doc.sel.shift=!1);fa(this,a)}function ze(a){if(!(Va(this.display,a)||fa(this,a)||a.ctrlKey&&!a.altKey||Da&&a.metaKey)){var b=a.keyCode,c=a.charCode;if(Ha&&b==zd)zd=null,na(a);else if(!Ha||a.which&&!(10>a.which)||!Ee(this,
a))if(b=String.fromCharCode(null==c?b:c),!Vf(this,a,b))this.display.input.onKeyPress(a)}}function Mf(a){a.state.delayingBlurEvent=!0;setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,Rb(a))},100)}function dd(a){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1);"nocursor"!=a.options.readOnly&&(a.state.focused||(ea(a,"focus",a),a.state.focused=!0,Xb(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),
ha&&setTimeout(function(){a.display.input.reset(!0)},20)),a.display.input.receivedFocus()),md(a))}function Rb(a){a.state.delayingBlurEvent||(a.state.focused&&(ea(a,"blur",a),a.state.focused=!1,Vb(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function se(a,b){var c;(c=Va(a.display,b))||(c=Aa(a,"gutterContextMenu")?vd(a,b,"gutterContextMenu",!1):!1);if(!c&&!fa(a,b,"contextmenu"))a.display.input.onContextMenu(b)}
function Ge(a,b){if(0>L(a,b.from))return a;if(0>=L(a,b.to))return pb(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;a.line==b.to.line&&(d+=pb(b).ch-b.to.ch);return F(c,d)}function Ad(a,b){for(var c=[],d=0;d<a.sel.ranges.length;d++){var e=a.sel.ranges[d];c.push(new Z(Ge(e.anchor,b),Ge(e.head,b)))}return Fa(c,a.sel.primIndex)}function He(a,b,c){return a.line==b.line?F(c.line,a.ch-b.ch+c.ch):F(c.line+(a.line-b.line),a.ch)}function Ie(a,b,c){b={canceled:!1,from:b.from,to:b.to,text:b.text,
origin:b.origin,cancel:function(){this.canceled=!0}};c&&(b.update=function(b,c,d,e){b&&(this.from=O(a,b));c&&(this.to=O(a,c));d&&(this.text=d);void 0!==e&&(this.origin=e)});ea(a,"beforeChange",a,b);a.cm&&ea(a.cm,"beforeChange",a.cm,b);return b.canceled?null:{from:b.from,to:b.to,text:b.text,origin:b.origin}}function Ab(a,b,c){if(a.cm){if(!a.cm.curOp)return da(a.cm,Ab)(a,b,c);if(a.cm.state.suppressEdits)return}if(Aa(a,"beforeChange")||a.cm&&Aa(a.cm,"beforeChange"))if(b=Ie(a,b,!0),!b)return;if(c=Je&&
!c&&Xf(a,b.from,b.to))for(var d=c.length-1;0<=d;--d)Ke(a,{from:c[d].from,to:c[d].to,text:d?[""]:b.text});else Ke(a,b)}function Ke(a,b){if(1!=b.text.length||""!=b.text[0]||0!=L(b.from,b.to)){var c=Ad(a,b);Le(a,b,c,a.cm?a.cm.curOp.id:NaN);gc(a,b,c,Bd(a,b));var d=[];qb(a,function(a,c){c||-1!=ka(d,a.history)||(Me(a.history,b),d.push(a.history));gc(a,b,null,Bd(a,b))})}}function Pc(a,b,c){if(!a.cm||!a.cm.state.suppressEdits){for(var d=a.history,e,f=a.sel,k="undo"==b?d.done:d.undone,g="undo"==b?d.undone:
d.done,h=0;h<k.length&&(e=k[h],c?!e.ranges||e.equals(a.sel):e.ranges);h++);if(h!=k.length){for(d.lastOrigin=d.lastSelOrigin=null;;)if(e=k.pop(),e.ranges){zc(e,g);if(c&&!e.equals(a.sel)){ia(a,e,{clearRedo:!1});return}f=e}else break;c=[];zc(f,g);g.push({changes:c,generation:d.generation});d.generation=e.generation||++d.maxGeneration;d=Aa(a,"beforeChange")||a.cm&&Aa(a.cm,"beforeChange");for(h=e.changes.length-1;0<=h;--h){var l=e.changes[h];l.origin=b;if(d&&!Ie(a,l,!1)){k.length=0;break}c.push(Cd(a,l));
f=h?Ad(a,l):V(k);gc(a,l,f,Ne(a,l));!h&&a.cm&&a.cm.scrollIntoView({from:l.from,to:pb(l)});var m=[];qb(a,function(a,b){b||-1!=ka(m,a.history)||(Me(a.history,l),m.push(a.history));gc(a,l,null,Ne(a,l))})}}}}function Oe(a,b){if(0!=b&&(a.first+=b,a.sel=new Ra(vc(a.sel.ranges,function(a){return new Z(F(a.anchor.line+b,a.anchor.ch),F(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){pa(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;d<c.viewTo;d++)Ua(a.cm,d,"gutter")}}function gc(a,b,c,d){if(a.cm&&
!a.cm.curOp)return da(a.cm,gc)(a,b,c,d);if(b.to.line<a.first)Oe(a,b.text.length-1-(b.to.line-b.from.line));else if(!(b.from.line>a.lastLine())){if(b.from.line<a.first){var e=b.text.length-1-(a.first-b.from.line);Oe(a,e);b={from:F(a.first,0),to:F(b.to.line+e,b.to.ch),text:[V(b.text)],origin:b.origin}}e=a.lastLine();b.to.line>e&&(b={from:b.from,to:F(e,J(a,e).text.length),text:[b.text[0]],origin:b.origin});b.removed=lb(a,b.from,b.to);c||(c=Ad(a,b));a.cm?Yf(a.cm,b,d):Dd(a,b,d);yc(a,c,Oa)}}function Yf(a,
b,c){var d=a.doc,f=a.display,k=b.from,g=b.to,h=!1,l=k.line;a.options.lineWrapping||(l=Y(Pa(J(d,k.line))),d.iter(l,g.line+1,function(a){if(a==f.maxLine)return h=!0}));-1<d.sel.contains(b.from,b.to)&&ge(a);Dd(d,b,c,e(a));a.options.lineWrapping||(d.iter(l,k.line+b.text.length,function(a){var b=m(a);b>f.maxLineLength&&(f.maxLine=a,f.maxLineLength=b,f.maxLineChanged=!0,h=!1)}),h&&(a.curOp.updateMaxLine=!0));d.frontier=Math.min(d.frontier,k.line);Sb(a,400);c=b.text.length-(g.line-k.line)-1;b.full?pa(a):
k.line!=g.line||1!=b.text.length||Pe(a.doc,b)?pa(a,k.line,g.line+1,c):Ua(a,k.line,"text");c=Aa(a,"changes");if((d=Aa(a,"change"))||c)b={from:k,to:g,text:b.text,removed:b.removed,origin:b.origin},d&&ta(a,"change",a,b),c&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(b);a.display.selForContextMenu=null}function Fb(a,b,c,d,e){d||(d=c);if(0>L(d,c)){var f=d;d=c;c=f}"string"==typeof b&&(b=a.splitLines(b));Ab(a,{from:c,to:d,text:b,origin:e})}function Gc(a,b,c,d,e){var f=a.display,k=eb(a.display);0>
c&&(c=0);var g=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,h=hd(a),l={};e-c>h&&(e=c+h);var m=a.doc.height+fd(f),n=c<k,k=e>m-k;c<g?l.scrollTop=n?0:c:e>g+h&&(c=Math.min(c,(k?m:e)-h),c!=g&&(l.scrollTop=c));g=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft;a=jb(a)-(a.options.fixedGutter?f.gutters.offsetWidth:0);(f=d-b>a)&&(d=b+a);10>b?l.scrollLeft=0:b<g?l.scrollLeft=Math.max(0,b-(f?0:10)):d>a+g-3&&(l.scrollLeft=d+(f?0:10)-a);return l}function Qc(a,
b,c){null==b&&null==c||Rc(a);null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b);null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function Bb(a){Rc(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?F(b.line,b.ch-1):b,d=F(b.line,b.ch+1));a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function Rc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=re(a,b.from),
d=re(a,b.to),b=Gc(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(b.scrollLeft,b.scrollTop)}}function Zb(a,b,c,d){var e=a.doc,f;null==c&&(c="add");"smart"==c&&(e.mode.indent?f=bc(a,b):c="prev");var k=a.options.tabSize,g=J(e,b),h=Ga(g.text,null,k);g.stateAfter&&(g.stateAfter=null);var l=g.text.match(/^\s*/)[0],m;if(!d&&!/\S/.test(g.text))m=0,c="not";else if("smart"==c&&(m=e.mode.indent(f,g.text.slice(l.length),g.text),
m==De||150<m)){if(!d)return;c="prev"}"prev"==c?m=b>e.first?Ga(J(e,b-1).text,null,k):0:"add"==c?m=h+a.options.indentUnit:"subtract"==c?m=h-a.options.indentUnit:"number"==typeof c&&(m=h+c);m=Math.max(0,m);c="";d=0;if(a.options.indentWithTabs)for(a=Math.floor(m/k);a;--a)d+=k,c+="\t";d<m&&(c+=Ed(m-d));if(c!=l)return Fb(e,c,F(b,0),F(b,l.length),"+input"),g.stateAfter=null,!0;for(a=0;a<e.sel.ranges.length;a++)if(k=e.sel.ranges[a],k.head.line==b&&k.head.ch<l.length){d=F(b,l.length);kd(e,a,new Z(d,d));break}}
function Sc(a,b,c,d){var e=b,f=b;"number"==typeof b?f=J(a,Math.max(a.first,Math.min(b,a.first+a.size-1))):e=Y(b);if(null==e)return null;d(f,e)&&a.cm&&Ua(a.cm,e,c);return f}function Gb(a,b){for(var c=a.doc.sel.ranges,d=[],e=0;e<c.length;e++){for(var f=b(c[e]);d.length&&0>=L(f.from,V(d).to);){var k=d.pop();if(0>L(k.from,f.from)){f.from=k.from;break}}d.push(f)}va(a,function(){for(var b=d.length-1;0<=b;b--)Fb(a.doc,"",d[b].from,d[b].to,"+delete");Bb(a)})}function Fd(a,b,c,d,e){function f(b){var d=(e?
ud:Qe)(l,g,c,!0);if(null==d){if(b=!b)b=k+c,b<a.first||b>=a.first+a.size?b=!1:(k=b,b=l=J(a,b));if(b)g=e?(0>c?Fc:Ec)(l):0>c?l.text.length:0;else return!1}else g=d;return!0}var k=b.line,g=b.ch,h=c,l=J(a,k);if("char"==d)f();else if("column"==d)f(!0);else if("word"==d||"group"==d){var m=null;d="group"==d;for(var n=a.cm&&a.cm.getHelper(b,"wordChars"),p=!0;!(0>c)||f(!p);p=!1){var q=l.text.charAt(g)||"\n",q=Tc(q,n)?"w":d&&"\n"==q?"n":!d||/\s/.test(q)?null:"p";!d||p||q||(q="s");if(m&&m!=q){0>c&&(c=1,f());
break}q&&(m=q);if(0<c&&!f(!p))break}}h=ld(a,F(k,g),b,h,!0);L(b,h)||(h.hitSide=!0);return h}function Re(a,b,c,d){var e=a.doc,f=b.left,k;for("page"==d?k=b.top+c*(Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight)-(0>c?1.5:.5)*eb(a.display)):"line"==d&&(k=0<c?b.bottom+3:b.top-3);;){b=td(a,f,k);if(!b.outside)break;if(0>c?0>=k:k>=e.height){b.hitSide=!0;break}k+=5*c}return b}function M(a,b,c,e){d.defaults[a]=b;c&&(xb[a]=e?function(a,b,d){d!=Ud&&c(a,b,d)}:
c)}function Zf(a){var b=a.split(/-(?!$)/);a=b[b.length-1];for(var c,d,e,f,k=0;k<b.length-1;k++){var g=b[k];if(/^(cmd|meta|m)$/i.test(g))f=!0;else if(/^a(lt)?$/i.test(g))c=!0;else if(/^(c|ctrl|control)$/i.test(g))d=!0;else if(/^s(hift)$/i.test(g))e=!0;else throw Error("Unrecognized modifier name: "+g);}c&&(a="Alt-"+a);d&&(a="Ctrl-"+a);f&&(a="Cmd-"+a);e&&(a="Shift-"+a);return a}function Uc(a){return"string"==typeof a?ab[a]:a}function Hb(a,b,c,d,e){if(d&&d.shared)return $f(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return da(a.cm,
Hb)(a,b,c,d,e);var f=new rb(a,e);e=L(b,c);d&&Ca(d,f,!1);if(0<e||0==e&&!1!==f.clearWhenEmpty)return f;f.replacedWith&&(f.collapsed=!0,f.widgetNode=I("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||f.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(f.widgetNode.insertLeft=!0));if(f.collapsed){if(Se(a,b.line,b,c,f)||b.line!=c.line&&Se(a,c.line,b,c,f))throw Error("Inserting collapsed marker partially overlapping an existing one");Za=!0}f.addToHistory&&Le(a,{from:b,to:c,
origin:"markText"},a.sel,NaN);var k=b.line,g=a.cm,h;a.iter(k,c.line+1,function(a){g&&f.collapsed&&!g.options.lineWrapping&&Pa(a)==g.display.maxLine&&(h=!0);f.collapsed&&k!=b.line&&Ja(a,0);var d=new Vc(f,k==b.line?b.ch:null,k==c.line?c.ch:null);a.markedSpans=a.markedSpans?a.markedSpans.concat([d]):[d];d.marker.attachLine(a);++k});f.collapsed&&a.iter(b.line,c.line+1,function(b){fb(a,b)&&Ja(b,0)});f.clearOnEnter&&K(f,"beforeCursorEnter",function(){f.clear()});f.readOnly&&(Je=!0,(a.history.done.length||
a.history.undone.length)&&a.clearHistory());f.collapsed&&(f.id=++Gd,f.atomic=!0);if(g){h&&(g.curOp.updateMaxLine=!0);if(f.collapsed)pa(g,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle||f.css)for(d=b.line;d<=c.line;d++)Ua(g,d,"text");f.atomic&&he(g.doc);ta(g,"markerAdded",g,f)}return f}function $f(a,b,c,d,e){d=Ca(d);d.shared=!1;var f=[Hb(a,b,c,d,e)],k=f[0],g=d.widgetNode;qb(a,function(a){g&&(d.widgetNode=g.cloneNode(!0));f.push(Hb(a,O(a,b),O(a,c),d,e));for(var oa=0;oa<a.linked.length;++oa)if(a.linked[oa].isParent)return;
k=V(f)});return new Wc(f,k)}function Te(a){return a.findMarks(F(a.first,0),a.clipPos(F(a.lastLine())),function(a){return a.parent})}function ag(a){for(var b=0;b<a.length;b++){var c=a[b],d=[c.primary.doc];qb(c.primary.doc,function(a){d.push(a)});for(var e=0;e<c.markers.length;e++){var f=c.markers[e];-1==ka(d,f.doc)&&(f.parent=null,c.markers.splice(e--,1))}}}function Vc(a,b,c){this.marker=a;this.from=b;this.to=c}function hc(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function Bd(a,
b){if(b.full)return null;var c=$b(a,b.from.line)&&J(a,b.from.line).markedSpans,d=$b(a,b.to.line)&&J(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,f=b.to.ch,k=0==L(b.from,b.to);if(c)for(var g=0,h;g<c.length;++g){var l=c[g],m=l.marker;if(null==l.from||(m.inclusiveLeft?l.from<=e:l.from<e)||!(l.from!=e||"bookmark"!=m.type||k&&l.marker.insertLeft)){var n=null==l.to||(m.inclusiveRight?l.to>=e:l.to>e);(h||(h=[])).push(new Vc(m,l.from,n?null:l.to))}}c=h;if(d)for(var g=0,p;g<d.length;++g)if(h=
d[g],l=h.marker,null==h.to||(l.inclusiveRight?h.to>=f:h.to>f)||h.from==f&&"bookmark"==l.type&&(!k||h.marker.insertLeft))m=null==h.from||(l.inclusiveLeft?h.from<=f:h.from<f),(p||(p=[])).push(new Vc(l,m?null:h.from-f,null==h.to?null:h.to-f));d=p;k=1==b.text.length;p=V(b.text).length+(k?e:0);if(c)for(f=0;f<c.length;++f)if(g=c[f],null==g.to)(h=hc(d,g.marker),h)?k&&(g.to=null==h.to?null:h.to+p):g.to=e;if(d)for(f=0;f<d.length;++f)g=d[f],null!=g.to&&(g.to+=p),null==g.from?(h=hc(c,g.marker),h||(g.from=p,
k&&(c||(c=[])).push(g))):(g.from+=p,k&&(c||(c=[])).push(g));c&&(c=Ue(c));d&&d!=c&&(d=Ue(d));e=[c];if(!k){var k=b.text.length-2,q;if(0<k&&c)for(f=0;f<c.length;++f)null==c[f].to&&(q||(q=[])).push(new Vc(c[f].marker,null,null));for(f=0;f<k;++f)e.push(q);e.push(d)}return e}function Ue(a){for(var b=0;b<a.length;++b){var c=a[b];null!=c.from&&c.from==c.to&&!1!==c.marker.clearWhenEmpty&&a.splice(b--,1)}return a.length?a:null}function Ne(a,b){var c;if(c=b["spans_"+a.id]){for(var d=0,e=[];d<b.text.length;++d)e.push(bg(c[d]));
c=e}else c=null;d=Bd(a,b);if(!c)return d;if(!d)return c;for(e=0;e<c.length;++e){var f=c[e],k=d[e];if(f&&k){var g=0;a:for(;g<k.length;++g){for(var h=k[g],l=0;l<f.length;++l)if(f[l].marker==h.marker)continue a;f.push(h)}}else k&&(c[e]=k)}return c}function Xf(a,b,c){var d=null;a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=0;b<a.markedSpans.length;++b){var c=a.markedSpans[b].marker;!c.readOnly||d&&-1!=ka(d,c)||(d||(d=[])).push(c)}});if(!d)return null;a=[{from:b,to:c}];for(b=0;b<d.length;++b){c=
d[b];for(var e=c.find(0),f=0;f<a.length;++f){var k=a[f];if(!(0>L(k.to,e.from)||0<L(k.from,e.to))){var g=[f,1],h=L(k.from,e.from),l=L(k.to,e.to);(0>h||!c.inclusiveLeft&&!h)&&g.push({from:k.from,to:e.from});(0<l||!c.inclusiveRight&&!l)&&g.push({from:e.to,to:k.to});a.splice.apply(a,g);f+=g.length-1}}}return a}function Ve(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function We(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=
b}}function Xe(a,b){var c=a.lines.length-b.lines.length;if(0!=c)return c;var c=a.find(),d=b.find(),e=L(c.from,d.from)||(a.inclusiveLeft?-1:0)-(b.inclusiveLeft?-1:0);return e?-e:(c=L(c.to,d.to)||(a.inclusiveRight?1:0)-(b.inclusiveRight?1:0))?c:b.id-a.id}function hb(a,b){var c=Za&&a.markedSpans,d;if(c)for(var e,f=0;f<c.length;++f)e=c[f],e.marker.collapsed&&null==(b?e.from:e.to)&&(!d||0>Xe(d,e.marker))&&(d=e.marker);return d}function Se(a,b,c,d,e){a=J(a,b);if(a=Za&&a.markedSpans)for(b=0;b<a.length;++b){var f=
a[b];if(f.marker.collapsed){var k=f.marker.find(0),g=L(k.from,c)||(f.marker.inclusiveLeft?-1:0)-(e.inclusiveLeft?-1:0),h=L(k.to,d)||(f.marker.inclusiveRight?1:0)-(e.inclusiveRight?1:0);if(!(0<=g&&0>=h||0>=g&&0<=h)&&(0>=g&&(f.marker.inclusiveRight&&e.inclusiveLeft?0<=L(k.to,c):0<L(k.to,c))||0<=g&&(f.marker.inclusiveRight&&e.inclusiveLeft?0>=L(k.from,d):0>L(k.from,d))))return!0}}}function Pa(a){for(var b;b=hb(a,!0);)a=b.find(-1,!0).line;return a}function gd(a,b){var c=J(a,b),d=Pa(c);return c==d?b:Y(d)}
function Xd(a,b){if(b>a.lastLine())return b;var c=J(a,b),d;if(!fb(a,c))return b;for(;d=hb(c,!1);)c=d.find(1,!0).line;return Y(c)+1}function fb(a,b){var c=Za&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed&&(null==d.from||!d.marker.widgetNode&&0==d.from&&d.marker.inclusiveLeft&&Hd(a,b,d)))return!0}function Hd(a,b,c){if(null==c.to)return b=c.marker.find(1,!0),Hd(a,b.line,hc(b.line.markedSpans,c.marker));if(c.marker.inclusiveRight&&c.to==b.text.length)return!0;for(var d,
e=0;e<b.markedSpans.length;++e)if(d=b.markedSpans[e],d.marker.collapsed&&!d.marker.widgetNode&&d.from==c.to&&(null==d.to||d.to!=c.from)&&(d.marker.inclusiveLeft||c.marker.inclusiveRight)&&Hd(a,b,d))return!0}function dc(a){if(null!=a.height)return a.height;var b=a.doc.cm;if(!b)return 0;if(!jd(document.body,a.node)){var c="position: relative;";a.coverGutter&&(c+="margin-left: -"+b.display.gutters.offsetWidth+"px;");a.noHScroll&&(c+="width: "+b.display.wrapper.clientWidth+"px;");wa(b.display.measure,
I("div",[a.node],null,c))}return a.height=a.node.parentNode.offsetHeight}function cg(a,b,c,d){var e=new Xc(a,c,d),f=a.cm;f&&e.noHScroll&&(f.display.alignWidgets=!0);Sc(a,b,"widget",function(b){var c=b.widgets||(b.widgets=[]);null==e.insertAt?c.push(e):c.splice(Math.min(c.length-1,Math.max(0,e.insertAt)),0,e);e.line=b;f&&!fb(a,b)&&(c=La(b)<a.scrollTop,Ja(b,b.height+dc(e)),c&&Qc(f,null,e.height),f.curOp.forceUpdate=!0);return!0});return e}function Ye(a,b){if(a)for(;;){var c=a.match(/(?:^|\s+)line-(background-)?(\S+)/);
if(!c)break;a=a.slice(0,c.index)+a.slice(c.index+c[0].length);var d=c[1]?"bgClass":"textClass";null==b[d]?b[d]=c[2]:(new RegExp("(?:^|s)"+c[2]+"(?:$|s)")).test(b[d])||(b[d]+=" "+c[2])}return a}function Ze(a,b){if(a.blankLine)return a.blankLine(b);if(a.innerMode){var c=d.innerMode(a,b);if(c.mode.blankLine)return c.mode.blankLine(c.state)}}function Id(a,b,c,e){for(var f=0;10>f;f++){e&&(e[0]=d.innerMode(a,c).mode);var k=a.token(b,c);if(b.pos>b.start)return k}throw Error("Mode "+a.name+" failed to advance stream.");
}function $e(a,b,c,d){function e(a){return{start:m.start,end:m.pos,string:m.current(),type:g||null,state:a?$a(f.mode,l):l}}var f=a.doc,k=f.mode,g;b=O(f,b);var h=J(f,b.line),l=bc(a,b.line,c),m=new Yc(h.text,a.options.tabSize),n;for(d&&(n=[]);(d||m.pos<b.ch)&&!m.eol();)m.start=m.pos,g=Id(k,m,l),d&&n.push(e(!0));return d?n:e()}function af(a,b,c,d,e,f,k){var g=c.flattenSpans;null==g&&(g=a.options.flattenSpans);var h=0,l=null,m=new Yc(b,a.options.tabSize),n,p=a.options.addModeClass&&[null];for(""==b&&
Ye(Ze(c,d),f);!m.eol();){m.pos>a.options.maxHighlightLength?(g=!1,k&&nd(a,b,d,m.pos),m.pos=b.length,n=null):n=Ye(Id(c,m,d,p),f);if(p){var q=p[0].name;q&&(n="m-"+(n?q+" "+n:q))}if(!g||l!=n){for(;h<m.start;)h=Math.min(m.start,h+5E4),e(h,l);l=n}m.start=m.pos}for(;h<m.pos;)a=Math.min(m.pos,h+5E4),e(a,l),h=a}function me(a,b,c,d){var e=[a.state.modeGen],f={};af(a,b.text,a.doc.mode,c,function(a,b){e.push(a,b)},f,d);for(c=0;c<a.state.overlays.length;++c){var k=a.state.overlays[c],g=1,h=0;af(a,b.text,k.mode,
!0,function(a,b){for(var c=g;h<a;){var d=e[g];d>a&&e.splice(g,1,a,e[g+1],d);g+=2;h=Math.min(a,d)}if(b)if(k.opaque)e.splice(c,g-c,a,"cm-overlay "+b),g=c+2;else for(;c<g;c+=2)d=e[c+1],e[c+1]=(d?d+" ":"")+"cm-overlay "+b},f)}return{styles:e,classes:f.bgClass||f.textClass?f:null}}function bf(a,b,c){if(!b.styles||b.styles[0]!=a.state.modeGen){var d=bc(a,Y(b)),e=me(a,b,b.text.length>a.options.maxHighlightLength?$a(a.doc.mode,d):d);b.stateAfter=d;b.styles=e.styles;e.classes?b.styleClasses=e.classes:b.styleClasses&&
(b.styleClasses=null);c===a.doc.frontier&&a.doc.frontier++}return b.styles}function nd(a,b,c,d){var e=a.doc.mode;a=new Yc(b,a.options.tabSize);a.start=a.pos=d||0;for(""==b&&Ze(e,c);!a.eol();)Id(e,a,c),a.start=a.pos}function cf(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?dg:eg;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function Yd(a,b){var c=I("span",null,null,ha?"padding-right: .1px":null),c={pre:I("pre",[c],"CodeMirror-line"),content:c,col:0,pos:0,cm:a,splitSpaces:(S||ha)&&a.getOption("lineWrapping")};
b.measure={};for(var d=0;d<=(b.rest?b.rest.length:0);d++){var e=d?b.rest[d-1]:b.line,f;c.pos=0;c.addToken=fg;var k;if(null!=Jd)k=Jd;else{k=wa(a.display.measure,document.createTextNode("A\u062eA"));var g=mb(k,0,1).getBoundingClientRect();k=g&&g.left!=g.right?Jd=3>mb(k,1,2).getBoundingClientRect().right-g.right:!1}k&&(f=Ea(e))&&(c.addToken=gg(c.addToken,f));c.map=[];g=b!=a.display.externalMeasured&&Y(e);a:{k=c;var g=bf(a,e,g),h=e.markedSpans,l=e.text,m=0;if(h)for(var n=l.length,p=0,q=1,r="",u=void 0,
t=void 0,w=0,y=void 0,v=void 0,z=void 0,A=void 0,x=void 0;;){if(w==p){for(var y=v=z=A=t="",x=null,w=Infinity,C=[],B,D=0;D<h.length;++D){var E=h[D],G=E.marker;"bookmark"==G.type&&E.from==p&&G.widgetNode?C.push(G):E.from<=p&&(null==E.to||E.to>p||G.collapsed&&E.to==p&&E.from==p)?(null!=E.to&&E.to!=p&&w>E.to&&(w=E.to,v=""),G.className&&(y+=" "+G.className),G.css&&(t=(t?t+";":"")+G.css),G.startStyle&&E.from==p&&(z+=" "+G.startStyle),G.endStyle&&E.to==w&&(B||(B=[])).push(G.endStyle,E.to),G.title&&!A&&(A=
G.title),G.collapsed&&(!x||0>Xe(x.marker,G))&&(x=E)):E.from>p&&w>E.from&&(w=E.from)}if(B)for(D=0;D<B.length;D+=2)B[D+1]==w&&(v+=" "+B[D]);if(!x||x.from==p)for(D=0;D<C.length;++D)df(k,0,C[D]);if(x&&(x.from||0)==p){df(k,(null==x.to?n+1:x.to)-p,x.marker,null==x.from);if(null==x.to)break a;x.to==p&&(x=!1)}}if(p>=n)break;for(C=Math.min(n,w);;){if(r){D=p+r.length;x||(E=D>C?r.slice(0,C-p):r,k.addToken(k,E,u?u+y:y,z,p+E.length==w?v:"",A,t));if(D>=C){r=r.slice(C-p);p=C;break}p=D;z=""}r=l.slice(m,m=g[q++]);
u=cf(g[q++],k.cm.options)}}else for(var q=1;q<g.length;q+=2)k.addToken(k,l.slice(m,m=g[q]),cf(g[q+1],k.cm.options))}e.styleClasses&&(e.styleClasses.bgClass&&(c.bgClass=Kd(e.styleClasses.bgClass,c.bgClass||"")),e.styleClasses.textClass&&(c.textClass=Kd(e.styleClasses.textClass,c.textClass||"")));0==c.map.length&&c.map.push(0,0,c.content.appendChild(hg(a.display.measure)));0==d?(b.measure.map=c.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(c.map),(b.measure.caches||(b.measure.caches=
[])).push({}))}ha&&(f=c.content.lastChild,/\bcm-tab\b/.test(f.className)||f.querySelector&&f.querySelector(".cm-tab"))&&(c.content.className="cm-tab-wrap-hack");ea(a,"renderLine",a,b.line,c.pre);c.pre.className&&(c.textClass=Kd(c.pre.className,c.textClass||""));return c}function fg(a,b,c,d,e,f,k){if(b){var g=a.splitSpaces?b.replace(/ {3,}/g,ig):b,h=a.cm.state.specialChars,l=!1;if(h.test(b))for(var m=document.createDocumentFragment(),n=0;;){h.lastIndex=n;var p=h.exec(b),q=p?p.index-n:b.length-n;if(q){var r=
document.createTextNode(g.slice(n,n+q));S&&9>ba?m.appendChild(I("span",[r])):m.appendChild(r);a.map.push(a.pos,a.pos+q,r);a.col+=q;a.pos+=q}if(!p)break;n+=q+1;"\t"==p[0]?(r=a.cm.options.tabSize,p=r-a.col%r,r=m.appendChild(I("span",Ed(p),"cm-tab")),r.setAttribute("role","presentation"),r.setAttribute("cm-text","\t"),a.col+=p):("\r"==p[0]||"\n"==p[0]?(r=m.appendChild(I("span","\r"==p[0]?"\u240d":"\u2424","cm-invalidchar")),r.setAttribute("cm-text",p[0])):(r=a.cm.options.specialCharPlaceholder(p[0]),
r.setAttribute("cm-text",p[0]),S&&9>ba?m.appendChild(I("span",[r])):m.appendChild(r)),a.col+=1);a.map.push(a.pos,a.pos+1,r);a.pos++}else{a.col+=b.length;var m=document.createTextNode(g);a.map.push(a.pos,a.pos+b.length,m);S&&9>ba&&(l=!0);a.pos+=b.length}if(c||d||e||l||k)return b=c||"",d&&(b+=d),e&&(b+=e),d=I("span",[m],b,k),f&&(d.title=f),a.content.appendChild(d);a.content.appendChild(m)}}function ig(a){for(var b=" ",c=0;c<a.length-2;++c)b+=c%2?" ":"\u00a0";return b+" "}function gg(a,b){return function(c,
d,e,f,k,g,h){e=e?e+" cm-force-border":"cm-force-border";for(var l=c.pos,m=l+d.length;;){for(var n=0;n<b.length;n++){var p=b[n];if(p.to>l&&p.from<=l)break}if(p.to>=m)return a(c,d,e,f,k,g,h);a(c,d.slice(0,p.to-l),e,f,null,g,h);f=null;d=d.slice(p.to-l);l=p.to}}}function df(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+b,e);!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id));e&&(a.cm.display.input.setUneditable(e),
a.content.appendChild(e));a.pos+=b}function Pe(a,b){return 0==b.from.ch&&0==b.to.ch&&""==V(b.text)&&(!a.cm||a.cm.options.wholeLineUpdateBefore)}function Dd(a,b,c,d){function e(a,c,f){a.text=c;a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null);null!=a.order&&(a.order=null);Ve(a);We(a,f);c=d?d(a):1;c!=a.height&&Ja(a,c);ta(a,"change",a,b)}function f(a,b){for(var e=a,k=[];e<b;++e)k.push(new ic(h[e],c?c[e]:null,d));return k}var k=b.from,g=b.to,h=b.text,l=J(a,k.line),m=J(a,g.line),n=V(h),p=c?c[h.length-
1]:null,q=g.line-k.line;if(b.full)a.insert(0,f(0,h.length)),a.remove(h.length,a.size-h.length);else if(Pe(a,b)){var r=f(0,h.length-1);e(m,m.text,p);q&&a.remove(k.line,q);r.length&&a.insert(k.line,r)}else l==m?1==h.length?e(l,l.text.slice(0,k.ch)+n+l.text.slice(g.ch),p):(r=f(1,h.length-1),r.push(new ic(n+l.text.slice(g.ch),p,d)),e(l,l.text.slice(0,k.ch)+h[0],c?c[0]:null),a.insert(k.line+1,r)):1==h.length?(e(l,l.text.slice(0,k.ch)+h[0]+m.text.slice(g.ch),c?c[0]:null),a.remove(k.line+1,q)):(e(l,l.text.slice(0,
k.ch)+h[0],c?c[0]:null),e(m,n+m.text.slice(g.ch),p),r=f(1,h.length-1),1<q&&a.remove(k.line+1,q-1),a.insert(k.line+1,r));ta(a,"change",a,b)}function jc(a){this.lines=a;this.parent=null;for(var b=0,c=0;b<a.length;++b)a[b].parent=this,c+=a[b].height;this.height=c}function kc(a){this.children=a;for(var b=0,c=0,d=0;d<a.length;++d){var e=a[d],b=b+e.chunkSize(),c=c+e.height;e.parent=this}this.size=b;this.height=c;this.parent=null}function qb(a,b,c){function d(a,e,f){if(a.linked)for(var k=0;k<a.linked.length;++k){var g=
a.linked[k];if(g.doc!=e){var oa=f&&g.sharedHist;if(!c||oa)b(g.doc,oa),d(g.doc,a,oa)}}}d(a,null,!0)}function Td(b,c){if(c.cm)throw Error("This document is already in use.");b.doc=c;c.cm=b;f(b);a(b);b.options.lineWrapping||t(b);b.options.mode=c.modeOption;pa(b)}function J(a,b){b-=a.first;if(0>b||b>=a.size)throw Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(b<f){c=e;break}b-=f}return c.lines[b]}function lb(a,
b,c){var d=[],e=b.line;a.iter(b.line,c.line+1,function(a){a=a.text;e==c.line&&(a=a.slice(0,c.ch));e==b.line&&(a=a.slice(b.ch));d.push(a);++e});return d}function Ld(a,b,c){var d=[];a.iter(b,c,function(a){d.push(a.text)});return d}function Ja(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function Y(a){if(null==a.parent)return null;var b=a.parent;a=ka(b.lines,a);for(var c=b.parent;c;b=c,c=c.parent)for(var d=0;c.children[d]!=b;++d)a+=c.children[d].chunkSize();return a+b.first}function ib(a,
b){var c=a.first;a:do{for(var d=0;d<a.children.length;++d){var e=a.children[d],f=e.height;if(b<f){a=e;continue a}b-=f;c+=e.chunkSize()}return c}while(!a.lines);for(d=0;d<a.lines.length;++d){e=a.lines[d].height;if(b<e)break;b-=e}return c+d}function La(a){a=Pa(a);for(var b=0,c=a.parent,d=0;d<c.lines.length;++d){var e=c.lines[d];if(e==a)break;else b+=e.height}for(a=c.parent;a;c=a,a=c.parent)for(d=0;d<a.children.length&&(e=a.children[d],e!=c);++d)b+=e.height;return b}function Ea(a){var b=a.order;null==
b&&(b=a.order=jg(a.text));return b}function Zc(a){this.done=[];this.undone=[];this.undoDepth=Infinity;this.lastModTime=this.lastSelTime=0;this.lastOrigin=this.lastSelOrigin=this.lastOp=this.lastSelOp=null;this.generation=this.maxGeneration=a||1}function Cd(a,b){var c={from:Nb(b.from),to:pb(b),text:lb(a,b.from,b.to)};ef(a,c,b.from.line,b.to.line+1);qb(a,function(a){ef(a,c,b.from.line,b.to.line+1)},!0);return c}function de(a){for(;a.length;)if(V(a).ranges)a.pop();else break}function Le(a,b,c,d){var e=
a.history;e.undone.length=0;var f=+new Date,k,g;if(g=e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))e.lastOp==d?(de(e.done),k=V(e.done)):e.done.length&&!V(e.done).ranges?k=V(e.done):1<e.done.length&&!e.done[e.done.length-2].ranges?(e.done.pop(),k=V(e.done)):k=void 0,g=k;if(g){var h=V(k.changes);0==L(b.from,b.to)&&0==L(b.from,h.to)?h.to=pb(b):k.changes.push(Cd(a,b))}else for((k=V(e.done))&&k.ranges||
zc(a.sel,e.done),k={changes:[Cd(a,b)],generation:e.generation},e.done.push(k);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift();e.done.push(c);e.generation=++e.maxGeneration;e.lastModTime=e.lastSelTime=f;e.lastOp=e.lastSelOp=d;e.lastOrigin=e.lastSelOrigin=b.origin;h||ea(a,"historyAdded")}function zc(a,b){var c=V(b);c&&c.ranges&&c.equals(a)||b.push(a)}function ef(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&
((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans);++f})}function bg(a){if(!a)return null;for(var b=0,c;b<a.length;++b)a[b].marker.explicitlyCleared?c||(c=a.slice(0,b)):c&&c.push(a[b]);return c?c.length?c:null:a}function Ib(a,b,c){for(var d=0,e=[];d<a.length;++d){var f=a[d];if(f.ranges)e.push(c?Ra.prototype.deepCopy.call(f):f);else{var f=f.changes,k=[];e.push({changes:k});for(var g=0;g<f.length;++g){var h=f[g],l;k.push({from:h.from,to:h.to,text:h.text});if(b)for(var m in h)(l=m.match(/^spans_(\d+)$/))&&
-1<ka(b,Number(l[1]))&&(V(k)[m]=h[m],delete h[m])}}}return e}function ff(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function gf(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e],k=!0;if(f.ranges){f.copied||(f=a[e]=f.deepCopy(),f.copied=!0);for(var g=0;g<f.ranges.length;g++)ff(f.ranges[g].anchor,b,c,d),ff(f.ranges[g].head,b,c,d)}else{for(g=0;g<f.changes.length;++g){var h=f.changes[g];if(c<h.from.line)h.from=F(h.from.line+d,h.from.ch),h.to=F(h.to.line+d,h.to.ch);else if(b<=h.to.line){k=!1;
break}}k||(a.splice(0,e+1),e=0)}}}function Me(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;gf(a.done,c,d,e);gf(a.undone,c,d,e)}function yd(a){return null!=a.defaultPrevented?a.defaultPrevented:0==a.returnValue}function Ae(a){var b=a.which;null==b&&(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));Da&&a.ctrlKey&&1==b&&(b=3);return b}function $c(a,b,c){a=a._handlers&&a._handlers[b];return c?a&&0<a.length?a.slice():hf:a||hf}function ta(a,b){function c(a){return function(){a.apply(null,
e)}}var d=$c(a,b,!1);if(d.length){var e=Array.prototype.slice.call(arguments,2),f;Eb?f=Eb.delayedCallbacks:lc?f=lc:(f=lc=[],setTimeout(kg,0));for(var k=0;k<d.length;++k)f.push(c(d[k]))}}function kg(){var a=lc;lc=null;for(var b=0;b<a.length;++b)a[b]()}function fa(a,b,c){"string"==typeof b&&(b={type:b,preventDefault:function(){this.defaultPrevented=!0}});ea(a,c||b.type,a,b);return yd(b)||b.codemirrorIgnore}function ge(a){var b=a._handlers&&a._handlers.cursorActivity;if(b){a=a.curOp.cursorActivityHandlers||
(a.curOp.cursorActivityHandlers=[]);for(var c=0;c<b.length;++c)-1==ka(a,b[c])&&a.push(b[c])}}function Aa(a,b){return 0<$c(a,b).length}function Jb(a){a.prototype.on=function(a,b){K(this,a,b)};a.prototype.off=function(a,b){Qa(this,a,b)}}function db(){this.id=null}function Ed(a){for(;ad.length<=a;)ad.push(V(ad)+" ");return ad[a]}function V(a){return a[a.length-1]}function ka(a,b){for(var c=0;c<a.length;++c)if(a[c]==b)return c;return-1}function vc(a,b){for(var c=[],d=0;d<a.length;d++)c[d]=b(a[d],d);return c}
function mc(){}function jf(a,b){var c;Object.create?c=Object.create(a):(mc.prototype=a,c=new mc);b&&Ca(b,c);return c}function Ca(a,b,c){b||(b={});for(var d in a)!a.hasOwnProperty(d)||!1===c&&b.hasOwnProperty(d)||(b[d]=a[d]);return b}function Qb(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function Tc(a,b){return b?-1<b.source.indexOf("\\w")&&kf(a)?!0:b.test(a):kf(a)}function lf(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function cc(a){return 768<=
a.charCodeAt(0)&&lg.test(a)}function I(a,b,c,d){a=document.createElement(a);c&&(a.className=c);d&&(a.style.cssText=d);if("string"==typeof b)a.appendChild(document.createTextNode(b));else if(b)for(c=0;c<b.length;++c)a.appendChild(b[c]);return a}function gb(a){for(var b=a.childNodes.length;0<b;--b)a.removeChild(a.firstChild);return a}function wa(a,b){return gb(a).appendChild(b)}function Ma(){for(var a=document.activeElement;a&&a.root&&a.root.activeElement;)a=a.root.activeElement;return a}function nc(a){return new RegExp("(^|\\s)"+
a+"(?:$|\\s)\\s*")}function Kd(a,b){for(var c=a.split(" "),d=0;d<c.length;d++)c[d]&&!nc(c[d]).test(b)&&(b+=" "+c[d]);return b}function mf(a){if(document.body.getElementsByClassName)for(var b=document.body.getElementsByClassName("CodeMirror"),c=0;c<b.length;c++){var d=b[c].CodeMirror;d&&a(d)}}function yf(){var a;K(window,"resize",function(){null==a&&(a=setTimeout(function(){a=null;mf(Kf)},100))});K(window,"blur",function(){mf(Rb)})}function hg(a){if(null==Md){var b=I("span","\u200b");wa(a,I("span",
[b,document.createTextNode("x")]));0!=a.firstChild.offsetHeight&&(Md=1>=b.offsetWidth&&2<b.offsetHeight&&!(S&&8>ba))}a=Md?I("span","\u200b"):I("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px");a.setAttribute("cm-text","");return a}function Bf(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;f<a.length;++f){var k=a[f];if(k.from<c&&k.to>b||b==c&&k.to==b)d(Math.max(k.from,b),Math.min(k.to,c),1==k.level?"rtl":"ltr"),e=!0}e||d(b,c,"ltr")}function rd(a){return a.level%2?a.to:
a.from}function sd(a){return a.level%2?a.from:a.to}function Ec(a){return(a=Ea(a))?rd(a[0]):0}function Fc(a){var b=Ea(a);return b?sd(V(b)):a.text.length}function nf(a,b){var c=J(a.doc,b),d=Pa(c);d!=c&&(b=Y(d));d=(c=Ea(d))?c[0].level%2?Fc(d):Ec(d):0;return F(b,d)}function of(a,b){var c=nf(a,b.line),d=J(a.doc,c.line),e=Ea(d);return e&&0!=e[0].level?c:(d=Math.max(0,d.text.search(/\S/)),F(c.line,b.line==c.line&&b.ch<=d&&b.ch?0:d))}function wc(a,b){ec=null;for(var c=0,d;c<a.length;++c){var e=a[c];if(e.from<
b&&e.to>b)return c;if(e.from==b||e.to==b)if(null==d)d=c;else{var f;f=e.level;var k=a[d].level,g=a[0].level;f=f==g?!0:k==g?!1:f<k;if(f)return e.from!=e.to&&(ec=d),c;e.from!=e.to&&(ec=c);break}}return d}function Nd(a,b,c,d){if(!d)return b+c;do b+=c;while(0<b&&cc(a.text.charAt(b)));return b}function ud(a,b,c,d){var e=Ea(a);if(!e)return Qe(a,b,c,d);var f=wc(e,b),k=e[f];for(b=Nd(a,b,k.level%2?-c:c,d);;){if(b>k.from&&b<k.to)return b;if(b==k.from||b==k.to){if(wc(e,b)==f)return b;k=e[f+c];return 0<c==k.level%
2?k.to:k.from}k=e[f+=c];if(!k)return null;b=0<c==k.level%2?Nd(a,k.to,-1,d):Nd(a,k.from,1,d)}}function Qe(a,b,c,d){b+=c;if(d)for(;0<b&&cc(a.text.charAt(b));)b+=c;return 0>b||b>a.text.length?null:b}var ua=navigator.userAgent,pf=navigator.platform,Xa=/gecko\/\d/i.test(ua),qf=/MSIE \d/.test(ua),rf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ua),S=qf||rf,ba=S&&(qf?document.documentMode||6:rf[1]),ha=/WebKit\//.test(ua),mg=ha&&/Qt\/\d+\.\d+/.test(ua),ng=/Chrome\//.test(ua),Ha=/Opera\//.test(ua),ve=/Apple Computer/.test(navigator.vendor),
og=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ua),Hf=/PhantomJS/.test(ua),Cb=/AppleWebKit/.test(ua)&&/Mobile\/\w+/.test(ua),Pb=Cb||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ua),Da=Cb||/Mac/.test(pf),Qf=/\bCrOS\b/.test(ua),pg=/win/i.test(pf),sb=Ha&&ua.match(/Version\/(\d*\.\d*)/);sb&&(sb=Number(sb[1]));sb&&15<=sb&&(Ha=!1,ha=!0);var sf=Da&&(mg||Ha&&(null==sb||12.11>sb)),wd=Xa||S&&9<=ba,Je=!1,Za=!1;x.prototype=Ca({update:function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>
a.clientHeight+1,d=a.nativeBarWidth;c?(this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0",this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+(a.viewHeight-(b?d:0)))+"px"):(this.vert.style.display="",this.vert.firstChild.style.height="0");b?(this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px",this.horiz.firstChild.style.width=a.scrollWidth-a.clientWidth+(a.viewWidth-a.barLeft-(c?d:0))+"px"):(this.horiz.style.display=
"",this.horiz.firstChild.style.width="0");!this.checkedZeroWidth&&0<a.clientHeight&&(0==d&&this.zeroWidthHack(),this.checkedZeroWidth=!0);return{right:c?d:0,bottom:b?d:0}},setScrollLeft:function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a);this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a);this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){this.horiz.style.height=
this.vert.style.width=Da&&!og?"12px":"18px";this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new db;this.disableVert=new db},enableZeroWidthBar:function(a,b){function c(){var d=a.getBoundingClientRect();document.elementFromPoint(d.left+1,d.bottom-1)!=a?a.style.pointerEvents="none":b.set(1E3,c)}a.style.pointerEvents="auto";b.set(1E3,c)},clear:function(){var a=this.horiz.parentNode;a.removeChild(this.horiz);a.removeChild(this.vert)}},x.prototype);w.prototype=Ca({update:function(){return{bottom:0,
right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},w.prototype);d.scrollbarModel={"native":x,"null":w};H.prototype.signal=function(a,b){Aa(a,b)&&this.events.push(arguments)};H.prototype.finish=function(){for(var a=0;a<this.events.length;a++)ea.apply(null,this.events[a])};var F=d.Pos=function(a,b){if(!(this instanceof F))return new F(a,b);this.line=a;this.ch=b},L=d.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch},qa=null;bd.prototype=Ca({init:function(a){function b(a){if(!fa(d,
a)){if(d.somethingSelected())qa={lineWise:!1,text:d.getSelections()},c.inaccurateSelection&&(c.prevInput="",c.inaccurateSelection=!1,f.value=qa.text.join("\n"),Kb(f));else if(d.options.lineWiseCopyCut){var e=Od(d);qa={lineWise:!0,text:e.text};"cut"==a.type?d.setSelections(e.ranges,null,Oa):(c.prevInput="",f.value=e.text.join("\n"),Kb(f))}else return;"cut"==a.type&&(d.state.cutIncoming=!0)}}var c=this,d=this.cm,e=this.wrapper=Qd(),f=this.textarea=e.firstChild;a.wrapper.insertBefore(e,a.wrapper.firstChild);
Cb&&(f.style.width="0px");K(f,"input",function(){S&&9<=ba&&c.hasSelection&&(c.hasSelection=null);c.poll()});K(f,"paste",function(a){fa(d,a)||sc(a,d)||(d.state.pasteIncoming=!0,c.fastPoll())});K(f,"cut",b);K(f,"copy",b);K(a.scroller,"paste",function(b){Va(a,b)||fa(d,b)||(d.state.pasteIncoming=!0,c.focus())});K(a.lineSpace,"selectstart",function(b){Va(a,b)||na(b)});K(f,"compositionstart",function(){var a=d.getCursor("from");c.composing&&c.composing.range.clear();c.composing={start:a,range:d.markText(a,
d.getCursor("to"),{className:"CodeMirror-composing"})}});K(f,"compositionend",function(){c.composing&&(c.poll(),c.composing.range.clear(),c.composing=null)})},prepareSelection:function(){var a=this.cm,b=a.display,c=a.doc,d=je(a);if(a.options.moveInputWithCursor){var a=Ta(a,c.sel.primary().head,"div"),c=b.wrapper.getBoundingClientRect(),e=b.lineDiv.getBoundingClientRect();d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,a.top+e.top-c.top));d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,
a.left+e.left-c.left))}return d},showSelection:function(a){var b=this.cm.display;wa(b.cursorDiv,a.cursors);wa(b.selectionDiv,a.selection);null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")},reset:function(a){if(!this.contextMenuPending){var b,c,d=this.cm,e=d.doc;d.somethingSelected()?(this.prevInput="",b=e.sel.primary(),c=(b=Fe&&(100<b.to().line-b.from().line||1E3<(c=d.getSelection()).length))?"-":c||d.getSelection(),this.textarea.value=c,d.state.focused&&Kb(this.textarea),
S&&9<=ba&&(this.hasSelection=c)):a||(this.prevInput=this.textarea.value="",S&&9<=ba&&(this.hasSelection=null));this.inaccurateSelection=b}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Pb||Ma()!=this.textarea))try{this.textarea.focus()}catch(a){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var a=
this;a.pollingFast||a.polling.set(this.cm.options.pollInterval,function(){a.poll();a.cm.state.focused&&a.slowPoll()})},fastPoll:function(){function a(){c.poll()||b?(c.pollingFast=!1,c.slowPoll()):(b=!0,c.polling.set(60,a))}var b=!1,c=this;c.pollingFast=!0;c.polling.set(20,a)},poll:function(){var a=this.cm,b=this.textarea,c=this.prevInput;if(this.contextMenuPending||!a.state.focused||qg(b)&&!c&&!this.composing||a.isReadOnly()||a.options.disableInput||a.state.keySeq)return!1;var d=b.value;if(d==c&&
!a.somethingSelected())return!1;if(S&&9<=ba&&this.hasSelection===d||Da&&/[\uf700-\uf7ff]/.test(d))return a.display.input.reset(),!1;if(a.doc.sel==a.display.selForContextMenu){var e=d.charCodeAt(0);8203!=e||c||(c="\u200b");if(8666==e)return this.reset(),this.cm.execCommand("undo")}for(var f=0,e=Math.min(c.length,d.length);f<e&&c.charCodeAt(f)==d.charCodeAt(f);)++f;var k=this;va(a,function(){Ia(a,d.slice(f),c.length-f,null,k.composing?"*compose":null);1E3<d.length||-1<d.indexOf("\n")?b.value=k.prevInput=
"":k.prevInput=d;k.composing&&(k.composing.range.clear(),k.composing.range=a.markText(k.composing.start,a.getCursor("to"),{className:"CodeMirror-composing"}))});return!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){S&&9<=ba&&(this.hasSelection=null);this.fastPoll()},onContextMenu:function(a){function b(){if(null!=k.selectionStart){var a=e.somethingSelected(),c="\u200b"+(a?k.value:"");k.value="\u21da";k.value=c;d.prevInput=a?"":"\u200b";k.selectionStart=
1;k.selectionEnd=c.length;f.selForContextMenu=e.doc.sel}}function c(){d.contextMenuPending=!1;d.wrapper.style.cssText=m;k.style.cssText=l;S&&9>ba&&f.scrollbars.setScrollTop(f.scroller.scrollTop=h);if(null!=k.selectionStart){(!S||S&&9>ba)&&b();var a=0,g=function(){f.selForContextMenu==e.doc.sel&&0==k.selectionStart&&0<k.selectionEnd&&"\u200b"==d.prevInput?da(e,Nc.selectAll)(e):10>a++?f.detectingSelectAll=setTimeout(g,500):f.input.reset()};f.detectingSelectAll=setTimeout(g,200)}}var d=this,e=d.cm,f=
e.display,k=d.textarea,g=ob(e,a),h=f.scroller.scrollTop;if(g&&!Ha){e.options.resetSelectionOnContextMenu&&-1==e.doc.sel.contains(g)&&da(e,ia)(e.doc,Na(g),Oa);var l=k.style.cssText,m=d.wrapper.style.cssText;d.wrapper.style.cssText="position: absolute";g=d.wrapper.getBoundingClientRect();k.style.cssText="position: absolute; width: 30px; height: 30px; top: "+(a.clientY-g.top-5)+"px; left: "+(a.clientX-g.left-5)+"px; z-index: 1000; background: "+(S?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
if(ha)var n=window.scrollY;f.input.focus();ha&&window.scrollTo(null,n);f.input.reset();e.somethingSelected()||(k.value=d.prevInput=" ");d.contextMenuPending=!0;f.selForContextMenu=e.doc.sel;clearTimeout(f.detectingSelectAll);S&&9<=ba&&b();if(wd){Ic(a);var p=function(){Qa(window,"mouseup",p);setTimeout(c,20)};K(window,"mouseup",p)}else setTimeout(c,50)}},readOnlyChanged:function(a){a||this.reset()},setUneditable:mc,needsContentAttribute:!1},bd.prototype);cd.prototype=Ca({init:function(a){function b(a){if(!fa(d,
a)){if(d.somethingSelected())qa={lineWise:!1,text:d.getSelections()},"cut"==a.type&&d.replaceSelection("",null,"cut");else if(d.options.lineWiseCopyCut){var c=Od(d);qa={lineWise:!0,text:c.text};"cut"==a.type&&d.operation(function(){d.setSelections(c.ranges,0,Oa);d.replaceSelection("",null,"cut")})}else return;if(a.clipboardData&&!Cb)a.preventDefault(),a.clipboardData.clearData(),a.clipboardData.setData("text/plain",qa.text.join("\n"));else{var e=Qd();a=e.firstChild;d.display.lineSpace.insertBefore(e,
d.display.lineSpace.firstChild);a.value=qa.text.join("\n");var f=document.activeElement;Kb(a);setTimeout(function(){d.display.lineSpace.removeChild(e);f.focus()},50)}}}var c=this,d=c.cm;a=c.div=a.lineDiv;Pd(a);K(a,"paste",function(a){fa(d,a)||sc(a,d)});K(a,"compositionstart",function(a){a=a.data;c.composing={sel:d.doc.sel,data:a,startData:a};if(a){var b=d.doc.sel.primary(),e=d.getLine(b.head.line).indexOf(a,Math.max(0,b.head.ch-a.length));-1<e&&e<=b.head.ch&&(c.composing.sel=Na(F(b.head.line,e),F(b.head.line,
e+a.length)))}});K(a,"compositionupdate",function(a){c.composing.data=a.data});K(a,"compositionend",function(a){var b=c.composing;b&&(a.data==b.startData||/\u200b/.test(a.data)||(b.data=a.data),setTimeout(function(){b.handled||c.applyComposition(b);c.composing==b&&(c.composing=null)},50))});K(a,"touchstart",function(){c.forceCompositionEnd()});K(a,"input",function(){c.composing||!d.isReadOnly()&&c.pollContent()||va(c.cm,function(){pa(d)})});K(a,"copy",b);K(a,"cut",b)},prepareSelection:function(){var a=
je(this.cm,!1);a.focus=this.cm.state.focused;return a},showSelection:function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))},showPrimarySelection:function(){var a=window.getSelection(),b=this.cm.doc.sel.primary(),c=tc(this.cm,a.anchorNode,a.anchorOffset),d=tc(this.cm,a.focusNode,a.focusOffset);if(!c||c.bad||!d||d.bad||0!=L(Wa(c,d),b.from())||0!=L(bb(c,d),b.to()))if(c=Rd(this.cm,b.from()),d=Rd(this.cm,b.to()),c||d){var e=this.cm.display.view,
b=a.rangeCount&&a.getRangeAt(0);c?d||(d=e[e.length-1].measure,d=d.maps?d.maps[d.maps.length-1]:d.map,d={node:d[d.length-1],offset:d[d.length-2]-d[d.length-3]}):c={node:e[0].measure.map[2],offset:0};try{var f=mb(c.node,c.offset,d.offset,d.node)}catch(k){}f&&(!Xa&&this.cm.state.focused?(a.collapse(c.node,c.offset),f.collapsed||a.addRange(f)):(a.removeAllRanges(),a.addRange(f)),b&&null==a.anchorNode?a.addRange(b):Xa&&this.startGracePeriod());this.rememberSelection()}},startGracePeriod:function(){var a=
this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){a.gracePeriod=!1;a.selectionChanged()&&a.cm.operation(function(){a.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(a){wa(this.cm.display.cursorDiv,a.cursors);wa(this.cm.display.selectionDiv,a.selection)},rememberSelection:function(){var a=window.getSelection();this.lastAnchorNode=a.anchorNode;this.lastAnchorOffset=a.anchorOffset;this.lastFocusNode=a.focusNode;this.lastFocusOffset=a.focusOffset},selectionInEditor:function(){var a=
window.getSelection();if(!a.rangeCount)return!1;a=a.getRangeAt(0).commonAncestorContainer;return jd(this.div,a)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function a(){b.cm.state.focused&&(b.pollSelection(),b.polling.set(b.cm.options.pollInterval,a))}var b=this;this.selectionInEditor()?this.pollSelection():va(this.cm,function(){b.cm.curOp.selectionChanged=
!0});this.polling.set(this.cm.options.pollInterval,a)},selectionChanged:function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode||a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var a=window.getSelection(),b=this.cm;this.rememberSelection();var c=tc(b,a.anchorNode,a.anchorOffset),d=tc(b,a.focusNode,a.focusOffset);c&&d&&va(b,function(){ia(b.doc,
Na(c,d),Oa);if(c.bad||d.bad)b.curOp.selectionChanged=!0})}},pollContent:function(){var a=this.cm,b=a.display,c=a.doc.sel.primary(),d=c.from(),c=c.to();if(d.line<b.viewFrom||c.line>b.viewTo-1)return!1;var e;d.line==b.viewFrom||0==(e=kb(a,d.line))?(d=Y(b.view[0].line),e=b.view[0].node):(d=Y(b.view[e].line),e=b.view[e-1].node.nextSibling);var f=kb(a,c.line);f==b.view.length-1?(c=b.viewTo-1,b=b.lineDiv.lastChild):(c=Y(b.view[f+1].line)-1,b=b.view[f+1].node.previousSibling);b=a.doc.splitLines(vf(a,e,b,
d,c));for(e=lb(a.doc,F(d,0),F(c,J(a.doc,c).text.length));1<b.length&&1<e.length;)if(V(b)==V(e))b.pop(),e.pop(),c--;else if(b[0]==e[0])b.shift(),e.shift(),d++;else break;for(var k=0,f=0,g=b[0],h=e[0],l=Math.min(g.length,h.length);k<l&&g.charCodeAt(k)==h.charCodeAt(k);)++k;g=V(b);h=V(e);for(l=Math.min(g.length-(1==b.length?k:0),h.length-(1==e.length?k:0));f<l&&g.charCodeAt(g.length-f-1)==h.charCodeAt(h.length-f-1);)++f;b[b.length-1]=g.slice(0,g.length-f);b[0]=b[0].slice(k);d=F(d,k);c=F(c,e.length?V(e).length-
f:0);if(1<b.length||b[0]||L(d,c))return Fb(a.doc,b,d,c,"+input"),!0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(a){this.cm.isReadOnly()?da(this.cm,pa)(this.cm):a.data&&a.data!=a.startData&&da(this.cm,Ia)(this.cm,a.data,0,a.sel)},setUneditable:function(a){a.contentEditable=
"false"},onKeyPress:function(a){a.preventDefault();this.cm.isReadOnly()||da(this.cm,Ia)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0)},readOnlyChanged:function(a){this.div.contentEditable=String("nocursor"!=a)},onContextMenu:mc,resetPosition:mc,needsContentAttribute:!0},cd.prototype);d.inputStyles={textarea:bd,contenteditable:cd};Ra.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=
this.ranges.length)return!1;for(var b=0;b<this.ranges.length;b++){var c=this.ranges[b],d=a.ranges[b];if(0!=L(c.anchor,d.anchor)||0!=L(c.head,d.head))return!1}return!0},deepCopy:function(){for(var a=[],b=0;b<this.ranges.length;b++)a[b]=new Z(Nb(this.ranges[b].anchor),Nb(this.ranges[b].head));return new Ra(a,this.primIndex)},somethingSelected:function(){for(var a=0;a<this.ranges.length;a++)if(!this.ranges[a].empty())return!0;return!1},contains:function(a,b){b||(b=a);for(var c=0;c<this.ranges.length;c++){var d=
this.ranges[c];if(0<=L(b,d.from())&&0>=L(a,d.to()))return c}return-1}};Z.prototype={from:function(){return Wa(this.anchor,this.head)},to:function(){return bb(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var od={left:0,right:0,top:0,bottom:0},nb,Eb=null,Gf=0,Kc,Jc,ue=0,Lc=0,xa=null;S?xa=-.53:Xa?xa=15:ng?xa=-.7:ve&&(xa=-1/3);var Ce=function(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail);
null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==c&&(c=a.wheelDelta);return{x:b,y:c}};d.wheelEventPixels=function(a){a=Ce(a);a.x*=xa;a.y*=xa;return a};var Tf=new db,zd=null,pb=d.changeEnd=function(a){return a.text?F(a.from.line+a.text.length-1,V(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};d.prototype={constructor:d,focus:function(){window.focus();this.display.input.focus()},setOption:function(a,b){var c=this.options,d=c[a];if(c[a]!=b||"mode"==a)c[a]=b,xb.hasOwnProperty(a)&&da(this,
xb[a])(this,b,d)},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](Uc(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;c<b.length;++c)if(b[c]==a||b[c].name==a)return b.splice(c,1),!0},addOverlay:la(function(a,b){var c=a.token?a:d.getMode(this.options,a);if(c.startState)throw Error("Overlays may not be stateful.");this.state.overlays.push({mode:c,modeSpec:a,opaque:b&&b.opaque});this.state.modeGen++;
pa(this)}),removeOverlay:la(function(a){for(var b=this.state.overlays,c=0;c<b.length;++c){var d=b[c].modeSpec;if(d==a||"string"==typeof a&&d.name==a){b.splice(c,1);this.state.modeGen++;pa(this);break}}}),indentLine:la(function(a,b,c){"string"!=typeof b&&"number"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract");$b(this.doc,a)&&Zb(this,a,b,c)}),indentSelection:la(function(a){for(var b=this.doc.sel.ranges,c=-1,d=0;d<b.length;d++){var e=b[d];if(e.empty())e.head.line>c&&
(Zb(this,e.head.line,a,!0),c=e.head.line,d==this.doc.sel.primIndex&&Bb(this));else{for(var f=e.from(),e=e.to(),k=Math.max(c,f.line),c=Math.min(this.lastLine(),e.line-(e.ch?0:1))+1,e=k;e<c;++e)Zb(this,e,a);e=this.doc.sel.ranges;0==f.ch&&b.length==e.length&&0<e[d].from().ch&&kd(this.doc,d,new Z(f,e[d].to()),Oa)}}}),getTokenAt:function(a,b){return $e(this,a,b)},getLineTokens:function(a,b){return $e(this,F(a),b,!0)},getTokenTypeAt:function(a){a=O(this.doc,a);var b=bf(this,J(this.doc,a.line)),c=0,d=(b.length-
1)/2;a=a.ch;if(0==a)b=b[2];else for(;;){var e=c+d>>1;if((e?b[2*e-1]:0)>=a)d=e;else if(b[2*e+1]<a)c=e+1;else{b=b[2*e+2];break}}c=b?b.indexOf("cm-overlay "):-1;return 0>c?b:0==c?null:b.slice(0,c-1)},getModeAt:function(a){var b=this.doc.mode;return b.innerMode?d.innerMode(b,this.getTokenAt(a).state).mode:b},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!Lb.hasOwnProperty(b))return c;var d=Lb[b],e=this.getModeAt(a);if("string"==typeof e[b])d[e[b]]&&c.push(d[e[b]]);
else if(e[b])for(var f=0;f<e[b].length;f++){var k=d[e[b][f]];k&&c.push(k)}else e.helperType&&d[e.helperType]?c.push(d[e.helperType]):d[e.name]&&c.push(d[e.name]);for(f=0;f<d._global.length;f++)k=d._global[f],k.pred(e,this)&&-1==ka(c,k.val)&&c.push(k.val);return c},getStateAfter:function(a,b){var c=this.doc;a=Math.max(c.first,Math.min(null==a?c.first+c.size-1:a,c.first+c.size-1));return bc(this,a+1,b)},cursorCoords:function(a,b){var c;c=this.doc.sel.primary();c=null==a?c.head:"object"==typeof a?O(this.doc,
a):a?c.from():c.to();return Ta(this,c,b||"page")},charCoords:function(a,b){return Ac(this,O(this.doc,a),b||"page")},coordsChar:function(a,b){a=qe(this,a,b||"page");return td(this,a.left,a.top)},lineAtHeight:function(a,b){a=qe(this,{top:a,left:0},b||"page").top;return ib(this.doc,a+this.display.viewOffset)},heightAtLine:function(a,b){var c=!1,d;"number"==typeof a?(d=this.doc.first+this.doc.size-1,a<this.doc.first?a=this.doc.first:a>d&&(a=d,c=!0),d=J(this.doc,a)):d=a;return qd(this,d,{top:0,left:0},
b||"page").top+(c?this.doc.height-La(d):0)},defaultTextHeight:function(){return eb(this.display)},defaultCharWidth:function(){return Tb(this.display)},setGutterMarker:la(function(a,b,c){return Sc(this.doc,a,"gutter",function(a){var d=a.gutterMarkers||(a.gutterMarkers={});d[b]=c;!c&&lf(d)&&(a.gutterMarkers=null);return!0})}),clearGutter:la(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,Ua(b,d,"gutter"),lf(c.gutterMarkers)&&
(c.gutterMarkers=null));++d})}),lineInfo:function(a){if("number"==typeof a){if(!$b(this.doc,a))return null;var b=a;a=J(this.doc,a);if(!a)return null}else if(b=Y(a),null==b)return null;return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=Ta(this,O(this.doc,a));var k=a.bottom,
g=a.left;b.style.position="absolute";b.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(b);f.sizer.appendChild(b);if("over"==d)k=a.top;else if("above"==d||"near"==d){var h=Math.max(f.wrapper.clientHeight,this.doc.height),l=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>h)&&a.top>b.offsetHeight?k=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=h&&(k=a.bottom);g+b.offsetWidth>l&&(g=l-b.offsetWidth)}b.style.top=k+"px";b.style.left=b.style.right=
"";"right"==e?(g=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?g=0:"middle"==e&&(g=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=g+"px");c&&(a=Gc(this,g,k,g+b.offsetWidth,k+b.offsetHeight),null!=a.scrollTop&&Wb(this,a.scrollTop),null!=a.scrollLeft&&zb(this,a.scrollLeft))},triggerOnKeyDown:la(ye),triggerOnKeyPress:la(ze),triggerOnKeyUp:xe,execCommand:function(a){if(Nc.hasOwnProperty(a))return Nc[a].call(null,this)},triggerElectric:la(function(a){Ob(this,a)}),findPosH:function(a,
b,c,d){var e=1;0>b&&(e=-1,b=-b);var f=0;for(a=O(this.doc,a);f<b&&(a=Fd(this.doc,a,e,c,d),!a.hitSide);++f);return a},moveH:la(function(a,b){var c=this;c.extendSelectionsBy(function(d){return c.display.shift||c.doc.extend||d.empty()?Fd(c.doc,d.head,a,b,c.options.rtlMoveVisually):0>a?d.from():d.to()},oc)}),deleteH:la(function(a,b){var c=this.doc;this.doc.sel.somethingSelected()?c.replaceSelection("",null,"+delete"):Gb(this,function(d){var e=Fd(c,d.head,a,b,!1);return 0>a?{from:e,to:d.head}:{from:d.head,
to:e}})}),findPosV:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);var f=0;for(a=O(this.doc,a);f<b&&(a=Ta(this,a,"div"),null==d?d=a.left:a.left=d,a=Re(this,a,e,c),!a.hitSide);++f);return a},moveV:la(function(a,b){var c=this,d=this.doc,e=[],f=!c.display.shift&&!d.extend&&d.sel.somethingSelected();d.extendSelectionsBy(function(k){if(f)return 0>a?k.from():k.to();var g=Ta(c,k.head,"div");null!=k.goalColumn&&(g.left=k.goalColumn);e.push(g.left);var h=Re(c,g,a,b);"page"==b&&k==d.sel.primary()&&Qc(c,null,Ac(c,
h,"div").top-g.top);return h},oc);if(e.length)for(var k=0;k<d.sel.ranges.length;k++)d.sel.ranges[k].goalColumn=e[k]}),findWordAt:function(a){var b=J(this.doc,a.line).text,c=a.ch,d=a.ch;if(b){var e=this.getHelper(a,"wordChars");(0>a.xRel||d==b.length)&&c?--c:++d;for(var f=b.charAt(c),f=Tc(f,e)?function(a){return Tc(a,e)}:/\s/.test(f)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!Tc(a)};0<c&&f(b.charAt(c-1));)--c;for(;d<b.length&&f(b.charAt(d));)++d}return new Z(F(a.line,c),F(a.line,
d))},toggleOverwrite:function(a){if(null==a||a!=this.state.overwrite)(this.state.overwrite=!this.state.overwrite)?Xb(this.display.cursorDiv,"CodeMirror-overwrite"):Vb(this.display.cursorDiv,"CodeMirror-overwrite"),ea(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==Ma()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:la(function(a,b){null==a&&null==b||Rc(this);null!=a&&(this.curOp.scrollLeft=a);null!=
b&&(this.curOp.scrollTop=b)}),getScrollInfo:function(){var a=this.display.scroller;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-Ka(this)-this.display.barHeight,width:a.scrollWidth-Ka(this)-this.display.barWidth,clientHeight:hd(this),clientWidth:jb(this)}},scrollIntoView:la(function(a,b){null==a?(a={from:this.doc.sel.primary().head,to:null},null==b&&(b=this.options.cursorScrollMargin)):"number"==typeof a?a={from:F(a,0),to:null}:null==a.from&&(a={from:a,to:null});a.to||(a.to=a.from);
a.margin=b||0;if(null!=a.from.line)Rc(this),this.curOp.scrollToPos=a;else{var c=Gc(this,Math.min(a.from.left,a.to.left),Math.min(a.from.top,a.to.top)-a.margin,Math.max(a.from.right,a.to.right),Math.max(a.from.bottom,a.to.bottom)+a.margin);this.scrollTo(c.scrollLeft,c.scrollTop)}}),setSize:la(function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a}var d=this;null!=a&&(d.display.wrapper.style.width=c(a));null!=b&&(d.display.wrapper.style.height=c(b));d.options.lineWrapping&&
pe(this);var e=d.display.viewFrom;d.doc.iter(e,d.display.viewTo,function(a){if(a.widgets)for(var b=0;b<a.widgets.length;b++)if(a.widgets[b].noHScroll){Ua(d,e,"widget");break}++e});d.curOp.forceUpdate=!0;ea(d,"refresh",this)}),operation:function(a){return va(this,a)},refresh:la(function(){var a=this.display.cachedTextHeight;pa(this);this.curOp.forceUpdate=!0;Ub(this);this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop);p(this);(null==a||.5<Math.abs(a-eb(this.display)))&&f(this);ea(this,"refresh",
this)}),swapDoc:la(function(a){var b=this.doc;b.cm=null;Td(this,a);Ub(this);this.display.input.reset();this.scrollTo(a.scrollLeft,a.scrollTop);this.curOp.forceScroll=!0;ta(this,"swapDoc",this,b);return b}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};Jb(d);var wf=d.defaults={},xb=d.optionHandlers={},Ud=d.Init=
{toString:function(){return"CodeMirror.Init"}};M("value","",function(a,b){a.setValue(b)},!0);M("mode",null,function(b,c){b.doc.modeOption=c;a(b)},!0);M("indentUnit",2,a,!0);M("indentWithTabs",!1);M("smartIndent",!0);M("tabSize",4,function(a){b(a);Ub(a);pa(a)},!0);M("lineSeparator",null,function(a,b){if(a.doc.lineSep=b){var c=[],d=a.doc.first;a.doc.iter(function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(-1==f)break;e=f+b.length;c.push(F(d,f))}d++});for(var e=c.length-1;0<=e;e--)Fb(a.doc,b,c[e],
F(c[e].line,c[e].ch+b.length))}});M("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b,c){a.state.specialChars=new RegExp(b.source+(b.test("\t")?"":"|\t"),"g");c!=d.Init&&a.refresh()});M("specialCharPlaceholder",function(a){var b=I("span","\u2022","cm-invalidchar");b.title="\\u"+a.charCodeAt(0).toString(16);b.setAttribute("aria-label",b.title);return b},function(a){a.refresh()},!0);M("electricChars",!0);M("inputStyle",Pb?"contenteditable":"textarea",function(){throw Error("inputStyle can not (yet) be changed in a running editor");
},!0);M("rtlMoveVisually",!pg);M("wholeLineUpdateBefore",!0);M("theme","default",function(a){h(a);n(a)},!0);M("keyMap","default",function(a,b,c){b=Uc(b);(c=c!=d.Init&&Uc(c))&&c.detach&&c.detach(a,b);b.attach&&b.attach(a,c||null)});M("extraKeys",null);M("lineWrapping",!1,function(a){a.options.lineWrapping?(Xb(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(Vb(a.display.wrapper,"CodeMirror-wrap"),t(a));f(a);pa(a);Ub(a);setTimeout(function(){C(a)},100)},
!0);M("gutters",[],function(a){q(a.options);n(a)},!0);M("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?E(a.display)+"px":"0";a.refresh()},!0);M("coverGutterNextToScrollbar",!1,function(a){C(a)},!0);M("scrollbarStyle","native",function(a){z(a);C(a);a.display.scrollbars.setScrollTop(a.doc.scrollTop);a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0);M("lineNumbers",!1,function(a){q(a.options);n(a)},!0);M("firstLineNumber",1,n,!0);M("lineNumberFormatter",function(a){return a},n,
!0);M("showCursorWhenSelecting",!1,Yb,!0);M("resetSelectionOnContextMenu",!0);M("lineWiseCopyCut",!0);M("readOnly",!1,function(a,b){"nocursor"==b?(Rb(a),a.display.input.blur(),a.display.disabled=!0):a.display.disabled=!1;a.display.input.readOnlyChanged(b)});M("disableInput",!1,function(a,b){b||a.display.input.reset()},!0);M("dragDrop",!0,function(a,b,c){!b!=!(c&&c!=d.Init)&&(c=a.display.dragFunctions,b=b?K:Qa,b(a.display.scroller,"dragstart",c.start),b(a.display.scroller,"dragenter",c.enter),b(a.display.scroller,
"dragover",c.over),b(a.display.scroller,"dragleave",c.leave),b(a.display.scroller,"drop",c.drop))});M("allowDropFileTypes",null);M("cursorBlinkRate",530);M("cursorScrollMargin",0);M("cursorHeight",1,Yb,!0);M("singleCursorHeightPerLine",!0,Yb,!0);M("workTime",100);M("workDelay",100);M("flattenSpans",!0,b,!0);M("addModeClass",!1,b,!0);M("pollInterval",100);M("undoDepth",200,function(a,b){a.doc.history.undoDepth=b});M("historyEventDelay",1250);M("viewportMargin",10,function(a){a.refresh()},!0);M("maxHighlightLength",
1E4,b,!0);M("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()});M("tabindex",null,function(a,b){a.display.input.getField().tabIndex=b||""});M("autofocus",null);var tf=d.modes={},pc=d.mimeModes={};d.defineMode=function(a,b){d.defaults.mode||"null"==a||(d.defaults.mode=a);2<arguments.length&&(b.dependencies=Array.prototype.slice.call(arguments,2));tf[a]=b};d.defineMIME=function(a,b){pc[a]=b};d.resolveMode=function(a){if("string"==typeof a&&pc.hasOwnProperty(a))a=pc[a];else if(a&&
"string"==typeof a.name&&pc.hasOwnProperty(a.name)){var b=pc[a.name];"string"==typeof b&&(b={name:b});a=jf(b,a);a.name=b.name}else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return d.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}};d.getMode=function(a,b){b=d.resolveMode(b);var c=tf[b.name];if(!c)return d.getMode(a,"text/plain");c=c(a,b);if(qc.hasOwnProperty(b.name)){var e=qc[b.name],f;for(f in e)e.hasOwnProperty(f)&&(c.hasOwnProperty(f)&&(c["_"+f]=
c[f]),c[f]=e[f])}c.name=b.name;b.helperType&&(c.helperType=b.helperType);if(b.modeProps)for(f in b.modeProps)c[f]=b.modeProps[f];return c};d.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}});d.defineMIME("text/plain","null");var qc=d.modeExtensions={};d.extendMode=function(a,b){var c=qc.hasOwnProperty(a)?qc[a]:qc[a]={};Ca(b,c)};d.defineExtension=function(a,b){d.prototype[a]=b};d.defineDocExtension=function(a,b){ra.prototype[a]=b};d.defineOption=M;var ed=[];d.defineInitHook=function(a){ed.push(a)};
var Lb=d.helpers={};d.registerHelper=function(a,b,c){Lb.hasOwnProperty(a)||(Lb[a]=d[a]={_global:[]});Lb[a][b]=c};d.registerGlobalHelper=function(a,b,c,e){d.registerHelper(a,b,e);Lb[a]._global.push({pred:c,val:e})};var $a=d.copyState=function(a,b){if(!0===b)return b;if(a.copyState)return a.copyState(b);var c={},d;for(d in b){var e=b[d];e instanceof Array&&(e=e.concat([]));c[d]=e}return c},Ef=d.startState=function(a,b,c){return a.startState?a.startState(b,c):!0};d.innerMode=function(a,b){for(;a.innerMode;){var c=
a.innerMode(b);if(!c||c.mode==a)break;b=c.state;a=c.mode}return c||{mode:a,state:b}};var Nc=d.commands={selectAll:function(a){a.setSelection(F(a.firstLine(),0),F(a.lastLine()),Oa)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),Oa)},killLine:function(a){Gb(a,function(b){if(b.empty()){var c=J(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line<a.lastLine()?{from:b.head,to:F(b.head.line+1,0)}:{from:b.head,to:F(b.head.line,c)}}return{from:b.from(),to:b.to()}})},
deleteLine:function(a){Gb(a,function(b){return{from:F(b.from().line,0),to:O(a.doc,F(b.to().line+1,0))}})},delLineLeft:function(a){Gb(a,function(a){return{from:F(a.from().line,0),to:a.from()}})},delWrappedLineLeft:function(a){Gb(a,function(b){var c=a.charCoords(b.head,"div").top+5;return{from:a.coordsChar({left:0,top:c},"div"),to:b.from()}})},delWrappedLineRight:function(a){Gb(a,function(b){var c=a.charCoords(b.head,"div").top+5,c=a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:c},"div");
return{from:b.from(),to:c}})},undo:function(a){a.undo()},redo:function(a){a.redo()},undoSelection:function(a){a.undoSelection()},redoSelection:function(a){a.redoSelection()},goDocStart:function(a){a.extendSelection(F(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(F(a.lastLine()))},goLineStart:function(a){a.extendSelectionsBy(function(b){return nf(a,b.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(a){a.extendSelectionsBy(function(b){return of(a,b.head)},{origin:"+move",
bias:1})},goLineEnd:function(a){a.extendSelectionsBy(function(b){b=b.head.line;for(var c,d=J(a.doc,b);c=hb(d,!1);)d=c.find(1,!0).line,b=null;c=(c=Ea(d))?c[0].level%2?Ec(d):Fc(d):d.text.length;return F(null==b?Y(d):b,c)},{origin:"+move",bias:-1})},goLineRight:function(a){a.extendSelectionsBy(function(b){b=a.charCoords(b.head,"div").top+5;return a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:b},"div")},oc)},goLineLeft:function(a){a.extendSelectionsBy(function(b){b=a.charCoords(b.head,"div").top+
5;return a.coordsChar({left:0,top:b},"div")},oc)},goLineLeftSmart:function(a){a.extendSelectionsBy(function(b){var c=a.charCoords(b.head,"div").top+5,c=a.coordsChar({left:0,top:c},"div");return c.ch<a.getLine(c.line).search(/\S/)?of(a,b.head):c},oc)},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},
goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goGroupRight:function(a){a.moveH(1,"group")},goGroupLeft:function(a){a.moveH(-1,"group")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,"word")},delGroupBefore:function(a){a.deleteH(-1,"group")},
delGroupAfter:function(a){a.deleteH(1,"group")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection("\t")},insertSoftTab:function(a){for(var b=[],c=a.listSelections(),d=a.options.tabSize,e=0;e<c.length;e++){var f=c[e].from(),f=Ga(a.getLine(f.line),f.ch,d);b.push(Ed(d-f%d))}a.replaceSelections(b)},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):
a.execCommand("insertTab")},transposeChars:function(a){va(a,function(){for(var b=a.listSelections(),c=[],d=0;d<b.length;d++){var e=b[d].head,f=J(a.doc,e.line).text;if(f)if(e.ch==f.length&&(e=new F(e.line,e.ch-1)),0<e.ch)e=new F(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),F(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var k=J(a.doc,e.line-1).text;k&&a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+k.charAt(k.length-1),F(e.line-1,k.length-1),F(e.line,1),"+transpose")}c.push(new Z(e,
e))}a.setSelections(c)})},newlineAndIndent:function(a){va(a,function(){for(var b=a.listSelections().length,c=0;c<b;c++){var d=a.listSelections()[c];a.replaceRange(a.doc.lineSeparator(),d.anchor,d.head,"+input");a.indentLine(d.from().line+1,null,!0)}Bb(a)})},openLine:function(a){a.replaceSelection("\n","start")},toggleOverwrite:function(a){a.toggleOverwrite()}},ab=d.keyMap={};ab.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",
PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};ab.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart",
"Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};ab.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft",
"Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"};ab.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight",
"Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic",
"emacsy"]};ab["default"]=Da?ab.macDefault:ab.pcDefault;d.normalizeKeyMap=function(a){var b={},c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];if(!/^(name|fallthrough|(de|at)tach)$/.test(c)){if("..."!=d)for(var e=vc(c.split(" "),Zf),f=0;f<e.length;f++){var k,g;f==e.length-1?(g=e.join(" "),k=d):(g=e.slice(0,f+1).join(" "),k="...");var h=b[g];if(!h)b[g]=k;else if(h!=k)throw Error("Inconsistent bindings for "+g);}delete a[c]}}for(var l in b)a[l]=b[l];return a};var fc=d.lookupKey=function(a,b,c,d){b=Uc(b);
var e=b.call?b.call(a,d):b[a];if(!1===e)return"nothing";if("..."===e)return"multi";if(null!=e&&c(e))return"handled";if(b.fallthrough){if("[object Array]"!=Object.prototype.toString.call(b.fallthrough))return fc(a,b.fallthrough,c,d);for(e=0;e<b.fallthrough.length;e++){var f=fc(a,b.fallthrough[e],c,d);if(f)return f}}},Sf=d.isModifierKey=function(a){a="string"==typeof a?a:tb[a.keyCode];return"Ctrl"==a||"Alt"==a||"Shift"==a||"Mod"==a},Uf=d.keyName=function(a,b){if(Ha&&34==a.keyCode&&a["char"])return!1;
var c=tb[a.keyCode],d=c;if(null==d||a.altGraphKey)return!1;a.altKey&&"Alt"!=c&&(d="Alt-"+d);(sf?a.metaKey:a.ctrlKey)&&"Ctrl"!=c&&(d="Ctrl-"+d);(sf?a.ctrlKey:a.metaKey)&&"Cmd"!=c&&(d="Cmd-"+d);!b&&a.shiftKey&&"Shift"!=c&&(d="Shift-"+d);return d};d.fromTextArea=function(a,b){function c(){a.value=m.getValue()}b=b?Ca(b):{};b.value=a.value;!b.tabindex&&a.tabIndex&&(b.tabindex=a.tabIndex);!b.placeholder&&a.placeholder&&(b.placeholder=a.placeholder);if(null==b.autofocus){var e=Ma();b.autofocus=e==a||null!=
a.getAttribute("autofocus")&&e==document.body}if(a.form&&(K(a.form,"submit",c),!b.leaveSubmitMethodAlone)){var f=a.form,k=f.submit;try{var h=f.submit=function(){c();f.submit=k;f.submit();f.submit=h}}catch(l){}}b.finishInit=function(b){b.save=c;b.getTextArea=function(){return a};b.toTextArea=function(){b.toTextArea=isNaN;c();a.parentNode.removeChild(b.getWrapperElement());a.style.display="";a.form&&(Qa(a.form,"submit",c),"function"==typeof a.form.submit&&(a.form.submit=k))}};a.style.display="none";
var m=d(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);return m};var Yc=d.StringStream=function(a,b){this.pos=this.start=0;this.string=a;this.tabSize=b||8;this.lineStart=this.lastColumnPos=this.lastColumnValue=0};Yc.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(a){var b=
this.string.charAt(this.pos);if("string"==typeof a?b==a:b&&(a.test?a.test(b):a(b)))return++this.pos,b},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){a=this.string.indexOf(a,this.pos);if(-1<a)return this.pos=a,!0},backUp:function(a){this.pos-=a},column:function(){this.lastColumnPos<this.start&&
(this.lastColumnValue=Ga(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start);return this.lastColumnValue-(this.lineStart?Ga(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Ga(this.string,null,this.tabSize)-(this.lineStart?Ga(this.string,this.lineStart,this.tabSize):0)},match:function(a,b,c){if("string"==typeof a){var d=function(a){return c?a.toLowerCase():a},e=this.string.substr(this.pos,a.length);if(d(e)==d(a))return!1!==
b&&(this.pos+=a.length),!0}else{if((a=this.string.slice(this.pos).match(a))&&0<a.index)return null;a&&!1!==b&&(this.pos+=a[0].length);return a}},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}}};var Gd=0,rb=d.TextMarker=function(a,b){this.lines=[];this.type=b;this.doc=a;this.id=++Gd};Jb(rb);rb.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&wb(a);if(Aa(this,
"clear")){var c=this.find();c&&ta(this,"clear",c.from,c.to)}for(var d=c=null,e=0;e<this.lines.length;++e){var f=this.lines[e],k=hc(f.markedSpans,this);a&&!this.collapsed?Ua(a,Y(f),"text"):a&&(null!=k.to&&(d=Y(f)),null!=k.from&&(c=Y(f)));for(var g=f,h=f.markedSpans,l=k,n=void 0,p=0;p<h.length;++p)h[p]!=l&&(n||(n=[])).push(h[p]);g.markedSpans=n;null==k.from&&this.collapsed&&!fb(this.doc,f)&&a&&Ja(f,eb(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(e=0;e<this.lines.length;++e)f=Pa(this.lines[e]),
k=m(f),k>a.display.maxLineLength&&(a.display.maxLine=f,a.display.maxLineLength=k,a.display.maxLineChanged=!0);null!=c&&a&&this.collapsed&&pa(a,c,d+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&he(a.doc));a&&ta(a,"markerCleared",a,this);b&&yb(a);this.parent&&this.parent.clear()}};rb.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;e<this.lines.length;++e){var f=this.lines[e],k=hc(f.markedSpans,this);if(null!=
k.from&&(c=F(b?f:Y(f),k.from),-1==a))return c;if(null!=k.to&&(d=F(b?f:Y(f),k.to),1==a))return d}return c&&{from:c,to:d}};rb.prototype.changed=function(){var a=this.find(-1,!0),b=this,c=this.doc.cm;a&&c&&va(c,function(){var d=a.line,e=Y(a.line);if(e=id(c,e))oe(e),c.curOp.selectionChanged=c.curOp.forceUpdate=!0;c.curOp.updateMaxLine=!0;fb(b.doc,d)||null==b.height||(e=b.height,b.height=null,(e=dc(b)-e)&&Ja(d,d.height+e))})};rb.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=
this.doc.cm.curOp;b.maybeHiddenMarkers&&-1!=ka(b.maybeHiddenMarkers,this)||(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)};rb.prototype.detachLine=function(a){this.lines.splice(ka(this.lines,a),1);!this.lines.length&&this.doc.cm&&(a=this.doc.cm.curOp,(a.maybeHiddenMarkers||(a.maybeHiddenMarkers=[])).push(this))};var Gd=0,Wc=d.SharedTextMarker=function(a,b){this.markers=a;this.primary=b;for(var c=0;c<a.length;++c)a[c].parent=this};Jb(Wc);Wc.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=
!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();ta(this,"clear")}};Wc.prototype.find=function(a,b){return this.primary.find(a,b)};var Xc=d.LineWidget=function(a,b,c){if(c)for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.doc=a;this.node=b};Jb(Xc);Xc.prototype.clear=function(){var a=this.doc.cm,b=this.line.widgets,c=this.line,d=Y(c);if(null!=d&&b){for(var e=0;e<b.length;++e)b[e]==this&&b.splice(e--,1);b.length||(c.widgets=null);var f=dc(this);Ja(c,Math.max(0,c.height-f));a&&
va(a,function(){var b=-f;La(c)<(a.curOp&&a.curOp.scrollTop||a.doc.scrollTop)&&Qc(a,null,b);Ua(a,d,"widget")})}};Xc.prototype.changed=function(){var a=this.height,b=this.doc.cm,c=this.line;this.height=null;var d=dc(this)-a;d&&(Ja(c,c.height+d),b&&va(b,function(){b.curOp.forceUpdate=!0;La(c)<(b.curOp&&b.curOp.scrollTop||b.doc.scrollTop)&&Qc(b,null,d)}))};var ic=d.Line=function(a,b,c){this.text=a;We(this,b);this.height=c?c(this):1};Jb(ic);ic.prototype.lineNo=function(){return Y(this)};var eg={},dg={};
jc.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=a,d=a+b;c<d;++c){var e=this.lines[c];this.height-=e.height;var f=e;f.parent=null;Ve(f);ta(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height+=c;this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(a=0;a<b.length;++a)b[a].parent=this},iterN:function(a,b,c){for(b=a+b;a<b;++a)if(c(this.lines[a]))return!0}};kc.prototype=
{chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(a<e){var f=Math.min(b,e-a),k=d.height;d.removeInner(a,f);this.height-=k-d.height;e==f&&(this.children.splice(c--,1),d.parent=null);if(0==(b-=f))break;a=0}else a-=e}25>this.size-b&&(1<this.children.length||!(this.children[0]instanceof jc))&&(c=[],this.collapse(c),this.children=[new jc(c)],this.children[0].parent=this)},collapse:function(a){for(var b=
0;b<this.children.length;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=b.length;this.height+=c;for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(a<=f){e.insertInner(a,b,c);if(e.lines&&50<e.lines.length){for(b=a=e.lines.length%25+25;b<e.lines.length;)c=new jc(e.lines.slice(b,b+=25)),e.height-=c.height,this.children.splice(++d,0,c),c.parent=this;e.lines=e.lines.slice(0,a);this.maybeSpill()}break}a-=f}},maybeSpill:function(){if(!(10>=this.children.length)){var a=
this;do{var b=a.children.splice(a.children.length-5,5),b=new kc(b);if(a.parent){a.size-=b.size;a.height-=b.height;var c=ka(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else c=new kc(a.children),c.parent=a,a.children=[c,b],a=c;b.parent=a.parent}while(10<a.children.length);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(a<f){f=Math.min(b,f-a);if(e.iterN(a,f,c))return!0;if(0==(b-=f))break;a=0}else a-=f}}};var rg=
0,ra=d.Doc=function(a,b,c,d){if(!(this instanceof ra))return new ra(a,b,c,d);null==c&&(c=0);kc.call(this,[new jc([new ic("",null)])]);this.first=c;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.frontier=c;c=F(c,0);this.sel=Na(c);this.history=new Zc(null);this.id=++rg;this.modeOption=b;this.lineSep=d;this.extend=!1;"string"==typeof a&&(a=this.splitLines(a));Dd(this,{from:c,to:c,text:a});ia(this,Na(c),Oa)};ra.prototype=jf(kc.prototype,{constructor:ra,iter:function(a,b,
c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0;d<b.length;++d)c+=b[d].height;this.insertInner(a-this.first,b,c)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=Ld(this,this.first,this.first+this.size);return!1===a?b:b.join(a||this.lineSeparator())},setValue:ma(function(a){var b=F(this.first,0),c=this.first+this.size-1;Ab(this,{from:b,to:F(c,J(this,c).text.length),text:this.splitLines(a),origin:"setValue",
full:!0},!0);ia(this,Na(b))}),replaceRange:function(a,b,c,d){b=O(this,b);c=c?O(this,c):b;Fb(this,a,b,c,d)},getRange:function(a,b,c){a=lb(this,O(this,a),O(this,b));return!1===c?a:a.join(c||this.lineSeparator())},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},getLineHandle:function(a){if($b(this,a))return J(this,a)},getLineNumber:function(a){return Y(a)},getLineHandleVisualStart:function(a){"number"==typeof a&&(a=J(this,a));return Pa(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},
lastLine:function(){return this.first+this.size-1},clipPos:function(a){return O(this,a)},getCursor:function(a){var b=this.sel.primary();return null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||"to"==a||!1===a?b.to():b.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:ma(function(a,b,c){a=O(this,"number"==typeof a?F(a,b||0):a);ia(this,Na(a,null),c)}),setSelection:ma(function(a,b,c){var d=O(this,a);a=O(this,b||
a);ia(this,Na(d,a),c)}),extendSelection:ma(function(a,b,c){xc(this,O(this,a),b&&O(this,b),c)}),extendSelections:ma(function(a,b){be(this,ae(this,a),b)}),extendSelectionsBy:ma(function(a,b){var c=vc(this.sel.ranges,a);be(this,ae(this,c),b)}),setSelections:ma(function(a,b,c){if(a.length){for(var d=0,e=[];d<a.length;d++)e[d]=new Z(O(this,a[d].anchor),O(this,a[d].head));null==b&&(b=Math.min(a.length-1,this.sel.primIndex));ia(this,Fa(e,b),c)}}),addSelection:ma(function(a,b,c){var d=this.sel.ranges.slice(0);
d.push(new Z(O(this,a),O(this,b||a)));ia(this,Fa(d,d.length-1),c)}),getSelection:function(a){for(var b=this.sel.ranges,c,d=0;d<b.length;d++){var e=lb(this,b[d].from(),b[d].to());c=c?c.concat(e):e}return!1===a?c:c.join(a||this.lineSeparator())},getSelections:function(a){for(var b=[],c=this.sel.ranges,d=0;d<c.length;d++){var e=lb(this,c[d].from(),c[d].to());!1!==a&&(e=e.join(a||this.lineSeparator()));b[d]=e}return b},replaceSelection:function(a,b,c){for(var d=[],e=0;e<this.sel.ranges.length;e++)d[e]=
a;this.replaceSelections(d,b,c||"+input")},replaceSelections:ma(function(a,b,c){for(var d=[],e=this.sel,f=0;f<e.ranges.length;f++){var k=e.ranges[f];d[f]={from:k.from(),to:k.to(),text:this.splitLines(a[f]),origin:c}}if(f=b&&"end"!=b){f=[];c=a=F(this.first,0);for(e=0;e<d.length;e++){var g=d[e],k=He(g.from,a,c),h=He(pb(g),a,c);a=g.to;c=h;"around"==b?(g=this.sel.ranges[e],g=0>L(g.head,g.anchor),f[e]=new Z(g?h:k,g?k:h)):f[e]=new Z(k,k)}f=new Ra(f,this.sel.primIndex)}b=f;for(f=d.length-1;0<=f;f--)Ab(this,
d[f]);b?ce(this,b):this.cm&&Bb(this.cm)}),undo:ma(function(){Pc(this,"undo")}),redo:ma(function(){Pc(this,"redo")}),undoSelection:ma(function(){Pc(this,"undo",!0)}),redoSelection:ma(function(){Pc(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d<a.done.length;d++)a.done[d].ranges||++b;for(d=0;d<a.undone.length;d++)a.undone[d].ranges||++c;return{undo:b,redo:c}},clearHistory:function(){this.history=
new Zc(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(a){a&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null);return this.history.generation},isClean:function(a){return this.history.generation==(a||this.cleanGeneration)},getHistory:function(){return{done:Ib(this.history.done),undone:Ib(this.history.undone)}},setHistory:function(a){var b=this.history=new Zc(this.history.maxGeneration);b.done=Ib(a.done.slice(0),
null,!0);b.undone=Ib(a.undone.slice(0),null,!0)},addLineClass:ma(function(a,b,c){return Sc(this,a,"gutter"==b?"gutter":"class",function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass";if(a[d]){if(nc(c).test(a[d]))return!1;a[d]+=" "+c}else a[d]=c;return!0})}),removeLineClass:ma(function(a,b,c){return Sc(this,a,"gutter"==b?"gutter":"class",function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass",e=a[d];if(e)if(null==
c)a[d]=null;else{var f=e.match(nc(c));if(!f)return!1;var k=f.index+f[0].length;a[d]=e.slice(0,f.index)+(f.index&&k!=e.length?" ":"")+e.slice(k)||null}else return!1;return!0})}),addLineWidget:ma(function(a,b,c){return cg(this,a,b,c)}),removeLineWidget:function(a){a.clear()},markText:function(a,b,c){return Hb(this,O(this,a),O(this,b),c,c&&c.type||"range")},setBookmark:function(a,b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft,clearWhenEmpty:!1,shared:b&&b.shared,handleMouseEvents:b&&
b.handleMouseEvents};a=O(this,a);return Hb(this,a,a,c,"bookmark")},findMarksAt:function(a){a=O(this,a);var b=[],c=J(this,a.line).markedSpans;if(c)for(var d=0;d<c.length;++d){var e=c[d];(null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=O(this,a);b=O(this,b);var d=[],e=a.line;this.iter(a.line,b.line+1,function(f){if(f=f.markedSpans)for(var k=0;k<f.length;k++){var g=f[k];null!=g.to&&e==a.line&&a.ch>=g.to||null==g.from&&e!=
a.line||null!=g.from&&e==b.line&&g.from>=b.ch||c&&!c(g.marker)||d.push(g.marker.parent||g.marker)}++e});return d},getAllMarks:function(){var a=[];this.iter(function(b){if(b=b.markedSpans)for(var c=0;c<b.length;++c)null!=b[c].from&&a.push(b[c].marker)});return a},posFromIndex:function(a){var b,c=this.first,d=this.lineSeparator().length;this.iter(function(e){e=e.text.length+d;if(e>a)return b=a,!0;a-=e;++c});return O(this,F(c,b))},indexFromPos:function(a){a=O(this,a);var b=a.ch;if(a.line<this.first||
0>a.ch)return 0;var c=this.lineSeparator().length;this.iter(this.first,a.line,function(a){b+=a.text.length+c});return b},copy:function(a){var b=new ra(Ld(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);b.scrollTop=this.scrollTop;b.scrollLeft=this.scrollLeft;b.sel=this.sel;b.extend=!1;a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory()));return b},linkedDoc:function(a){a||(a={});var b=this.first,c=this.first+this.size;null!=a.from&&a.from>b&&
(b=a.from);null!=a.to&&a.to<c&&(c=a.to);b=new ra(Ld(this,b,c),a.mode||this.modeOption,b,this.lineSep);a.sharedHist&&(b.history=this.history);(this.linked||(this.linked=[])).push({doc:b,sharedHist:a.sharedHist});b.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}];a=Te(this);for(c=0;c<a.length;c++){var d=a[c],e=d.find(),f=b.clipPos(e.from),e=b.clipPos(e.to);L(f,e)&&(f=Hb(b,f,e,d.primary,d.primary.type),d.markers.push(f),f.parent=d)}return b},unlinkDoc:function(a){a instanceof d&&(a=a.doc);if(this.linked)for(var b=
0;b<this.linked.length;++b)if(this.linked[b].doc==a){this.linked.splice(b,1);a.unlinkDoc(this);ag(Te(this));break}if(a.history==this.history){var c=[a.id];qb(a,function(a){c.push(a.id)},!0);a.history=new Zc(null);a.history.done=Ib(this.history.done,c);a.history.undone=Ib(this.history.undone,c)}},iterLinkedDocs:function(a){qb(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(a){return this.lineSep?a.split(this.lineSep):sg(a)},lineSeparator:function(){return this.lineSep||
"\n"}});ra.prototype.eachLine=ra.prototype.iter;var tg="iter insert remove copy getEditor constructor".split(" "),rc;for(rc in ra.prototype)ra.prototype.hasOwnProperty(rc)&&0>ka(tg,rc)&&(d.prototype[rc]=function(a){return function(){return a.apply(this.doc,arguments)}}(ra.prototype[rc]));Jb(ra);var na=d.e_preventDefault=function(a){a.preventDefault?a.preventDefault():a.returnValue=!1},ug=d.e_stopPropagation=function(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0},Ic=d.e_stop=function(a){na(a);
ug(a)},K=d.on=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):(a=a._handlers||(a._handlers={}),(a[b]||(a[b]=[])).push(c))},hf=[],Qa=d.off=function(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else for(a=$c(a,b,!1),b=0;b<a.length;++b)if(a[b]==c){a.splice(b,1);break}},ea=d.signal=function(a,b){var c=$c(a,b,!0);if(c.length)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,
d)},lc=null,Vd=30,De=d.Pass={toString:function(){return"CodeMirror.Pass"}},Oa={scroll:!1},xd={origin:"*mouse"},oc={origin:"+move"};db.prototype.set=function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)};var Ga=d.countColumn=function(a,b,c,d,e){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));d=d||0;for(e=e||0;;){var f=a.indexOf("\t",d);if(0>f||f>=b)return e+(b-d);e+=f-d;e+=c-e%c;d=f+1}},Be=d.findColumn=function(a,b,c){for(var d=0,e=0;;){var f=a.indexOf("\t",d);-1==f&&(f=a.length);var k=
f-d;if(f==a.length||e+k>=b)return d+Math.min(k,b-e);e+=f-d;e+=c-e%c;d=f+1;if(e>=b)return d}},ad=[""],Kb=function(a){a.select()};Cb?Kb=function(a){a.selectionStart=0;a.selectionEnd=a.value.length}:S&&(Kb=function(a){try{a.select()}catch(b){}});var vg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,kf=d.isWordChar=function(a){return/\w/.test(a)||"\u0080"<a&&(a.toUpperCase()!=a.toLowerCase()||vg.test(a))},lg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,
mb;mb=document.createRange?function(a,b,c,d){var e=document.createRange();e.setEnd(d||a,c);e.setStart(a,b);return e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}d.collapse(!0);d.moveEnd("character",c);d.moveStart("character",b);return d};var jd=d.contains=function(a,b){3==b.nodeType&&(b=b.parentNode);if(a.contains)return a.contains(b);do if(11==b.nodeType&&(b=b.host),b==a)return!0;while(b=b.parentNode)};S&&11>ba&&(Ma=function(){try{return document.activeElement}catch(a){return document.body}});
var Vb=d.rmClass=function(a,b){var c=a.className,d=nc(b).exec(c);if(d){var e=c.slice(d.index+d[0].length);a.className=c.slice(0,d.index)+(e?d[1]+e:"")}},Xb=d.addClass=function(a,b){var c=a.className;nc(b).test(c)||(a.className+=(c?" ":"")+b)},Sd=!1,Nf=function(){if(S&&9>ba)return!1;var a=I("div");return"draggable"in a||"dragDrop"in a}(),Md,Jd,sg=d.splitLines=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;b<=d;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==
a.charAt(e-1)?e-1:e),k=f.indexOf("\r");-1!=k?(c.push(f.slice(0,k)),b+=k+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},qg=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},Fe=function(){var a=I("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),
pd=null,tb=d.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",
63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};(function(){for(var a=0;10>a;a++)tb[a+48]=tb[a+96]=String(a);for(a=65;90>=a;a++)tb[a]=String.fromCharCode(a);for(a=1;12>=a;a++)tb[a+111]=tb[a+63235]="F"+a})();var ec,jg=function(){function a(b){return 247>=b?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(b):
1424<=b&&1524>=b?"R":1536<=b&&1773>=b?"rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm".charAt(b-1536):1774<=b&&2220>=b?"r":8192<=b&&8203>=b?"w":8204==b?"b":"L"}function b(a,c,d){this.level=a;this.from=c;this.to=d}var c=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,d=/[stwN]/,e=/[LRr]/,f=/[Lb1n]/,k=/[1n]/;return function(g){if(!c.test(g))return!1;
for(var h=g.length,l=[],m=0,n;m<h;++m)l.push(a(g.charCodeAt(m)));for(var m=0,p="L";m<h;++m)n=l[m],"m"==n?l[m]=p:p=n;m=0;for(p="L";m<h;++m)n=l[m],"1"==n&&"r"==p?l[m]="n":e.test(n)&&(p=n,"r"==n&&(l[m]="R"));m=1;for(p=l[0];m<h-1;++m)n=l[m],"+"==n&&"1"==p&&"1"==l[m+1]?l[m]="1":","!=n||p!=l[m+1]||"1"!=p&&"n"!=p||(l[m]=p),p=n;for(m=0;m<h;++m)if(n=l[m],","==n)l[m]="N";else if("%"==n){for(p=m+1;p<h&&"%"==l[p];++p);var q=m&&"!"==l[m-1]||p<h&&"1"==l[p]?"1":"N";for(n=m;n<p;++n)l[n]=q;m=p-1}m=0;for(p="L";m<h;++m)n=
l[m],"L"==p&&"1"==n?l[m]="L":e.test(n)&&(p=n);for(m=0;m<h;++m)if(d.test(l[m])){for(p=m+1;p<h&&d.test(l[p]);++p);n="L"==(p<h?l[p]:"L");q="L"==(m?l[m-1]:"L")||n?"L":"R";for(n=m;n<p;++n)l[n]=q;m=p-1}for(var p=[],r,m=0;m<h;)if(f.test(l[m])){n=m;for(++m;m<h&&f.test(l[m]);++m);p.push(new b(0,n,m))}else{var u=m,q=p.length;for(++m;m<h&&"L"!=l[m];++m);for(n=u;n<m;)if(k.test(l[n])){u<n&&p.splice(q,0,new b(1,u,n));u=n;for(++n;n<m&&k.test(l[n]);++n);p.splice(q,0,new b(2,u,n));u=n}else++n;u<m&&p.splice(q,0,new b(1,
u,m))}1==p[0].level&&(r=g.match(/^\s+/))&&(p[0].from=r[0].length,p.unshift(new b(0,0,r[0].length)));1==V(p).level&&(r=g.match(/\s+$/))&&(V(p).to-=r[0].length,p.push(new b(0,h-r[0].length,h)));2==p[0].level&&p.unshift(new b(1,p[0].to,p[0].to));p[0].level!=V(p).level&&p.push(new b(p[0].level,h,h));return p}}();d.version="5.16.0";return d})},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==
typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(){return new r.TrackableValue(0>=arguments.length||void 0===arguments[0]?"void main() {\n  emitGrayscale(toNormalized(getDataValue()));\n}\n":arguments[0],n.verifyString)}
var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),e=function m(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),null===a?void 0:m(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},l=f(64),r=
f(65),n=f(8);d.FRAGMENT_MAIN_START="//NEUROGLANCER_IMAGE_RENDERLAYER_FRAGMENT_MAIN_START";var k=f(105);d.getTrackableFragmentMain=a;h=function(f){function h(b,c){var d=2>=arguments.length||void 0===arguments[2]?l.trackableAlphaValue(.5):arguments[2],e=3>=arguments.length||void 0===arguments[3]?a():arguments[3];if(!(this instanceof h))throw new TypeError("Cannot call a class as a function");var f=g(this,Object.getPrototypeOf(h).call(this,b,c));f.opacity=d;f.fragmentMain=e;f.registerSignalBinding(d.changed.add(function(){f.redrawNeeded.dispatch()}));
f.registerSignalBinding(e.changed.add(function(){f.shaderUpdated=!0;f.redrawNeeded.dispatch()}));return f}c(h,f);b(h,[{key:"getShaderKey",value:function(){return"sliceview.ImageRenderLayer:"+JSON.stringify(this.fragmentMain.value)}},{key:"defineShader",value:function(a){e(Object.getPrototypeOf(h.prototype),"defineShader",this).call(this,a);a.addUniform("highp float","uOpacity");a.addFragmentCode("\nvoid emitRGBA(vec4 rgba) {\n  emit(vec4(rgba.rgb, rgba.a * uOpacity));\n}\nvoid emitRGB(vec3 rgb) {\n  emit(vec4(rgb, uOpacity));\n}\nvoid emitGrayscale(float value) {\n  emit(vec4(value, value, value, uOpacity));\n}\nvoid emitTransparent() {\n  emit(vec4(0.0, 0.0, 0.0, 0.0));\n}\n");
a.addFragmentCode(k);a.setFragmentMainFunction(d.FRAGMENT_MAIN_START+"\n"+this.fragmentMain.value)}},{key:"beginSlice",value:function(a){a=e(Object.getPrototypeOf(h.prototype),"beginSlice",this).call(this,a);this.gl.uniform1f(a.uniform("uOpacity"),this.opacity.value);return a}}]);return h}(l.RenderLayer);d.ImageRenderLayer=h},function(h,d){h.exports='/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nvec3 colormapJet(float x) {\n  vec3 result;\n  result.r = x < 0.89 ? ((x - 0.35) / 0.31) : (1.0 - (x - 0.89) / 0.11 * 0.5);\n  result.g = x < 0.64 ? ((x - 0.125) * 4.0) : (1.0 - (x - 0.64) / 0.27);\n  result.b = x < 0.34 ? (0.5 + x * 0.5 / 0.11) : (1.0 - (x - 0.34) / 0.31);\n  return clamp(result, 0.0, 1.0);\n}\n'},
function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=
function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var b=f(7);f(107);f=function(d){function f(a){var b=1>=arguments.length||void 0===arguments[1]?{}:arguments[1],c=b.min,c=void 0===c?0:c,d=b.max,d=void 0===d?1:d,b=b.step,b=void 0===b?.01:b;if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");
var e=g(this,Object.getPrototypeOf(f).call(this));e.value=a;e.element=document.createElement("label");e.promptElement=document.createElement("span");e.inputElement=document.createElement("input");var h=e.element,q=e.promptElement,v=e.inputElement;h.className="range-slider";q.className="range-prompt";v.type="range";v.min=""+c;v.max=""+d;v.step=""+b;v.valueAsNumber=e.value.value;h.appendChild(q);h.appendChild(v);var x=function(){e.value.value=e.inputElement.valueAsNumber};e.registerEventListener(v,
"change",x);e.registerEventListener(v,"input",x);e.registerEventListener(v,"wheel",function(a){a=a.deltaY;0<a?(e.inputElement.stepUp(),x()):0>a&&(e.inputElement.stepDown(),x())});a.changed.add(function(){e.inputElement.valueAsNumber=e.value.value});return e}c(f,d);a(f,[{key:"disposed",value:function(){b.removeFromParent(this.element)}}]);return f}(h.RefCounted);d.RangeWidget=f},function(h,d){},function(h,d){},function(h,d){},function(h,d){},function(h,d){},function(h,d){},function(h,d){h.exports=
function(d){function g(a){var c={};a=a.split(" ");for(var d=0;d<a.length;++d)c[a[d]]=!0;return c}d.defineMode("glsl",function(b,d){function f(a,b){var c=a.next();if(z[c]){var d=z[c](a,b);if(!1!==d)return d}if('"'==c||"'"==c)return b.tokenize=h(c),b.tokenize(a,b);if(/[\[\]{}\(\),;\:\.]/.test(c))return y=c,"bracket";if(/\d/.test(c))return a.eatWhile(/[\w\.]/),"number";if("/"==c){if(a.eat("*"))return b.tokenize=n,n(a,b);if(a.eat("/"))return a.skipToEnd(),"comment"}if("#"==c)return a.eatWhile(/[\S]+/),
a.eatWhile(/[\s]+/),a.eatWhile(/[\S]+/),a.eatWhile(/[\s]+/),"comment";if(u.test(c))return a.eatWhile(u),"operator";a.eatWhile(/[\w\$_]/);c=a.current();return q.propertyIsEnumerable(c)?(x.propertyIsEnumerable(c)&&(y="newstatement"),"keyword"):v.propertyIsEnumerable(c)?"builtin":w.propertyIsEnumerable(c)?"atom":"word"}function h(a){return function(b,c){for(var d=!1,e,k=!1;null!=(e=b.next());){if(e==a&&!d){k=!0;break}d=!d&&"\\"==e}if(k||!d&&!C)c.tokenize=f;return"string"}}function n(a,b){for(var c=!1,
d;d=a.next();){if("/"==d&&c){b.tokenize=f;break}c="*"==d}return"comment"}function k(a,b,c,d,e){this.indented=a;this.column=b;this.type=c;this.align=d;this.prev=e}function p(a,b,c){return a.context=new k(a.indented,b,c,null,a.context)}function m(a){var b=a.context.type;if(")"==b||"]"==b||"}"==b)a.indented=a.context.indented;return a.context=a.context.prev}var t=b.indentUnit,q=d.keywords||g(c),v=d.builtins||g(a),x=d.blockKeywords||g("case do else for if switch while struct"),w=d.atoms||g("null"),z=
d.hooks||{},C=d.multiLineStrings,u=/[+\-*&%=<>!?|\/]/,y;return{startState:function(a){return{tokenize:null,context:new k((a||0)-t,0,"top",!1),indented:0,startOfLine:!0}},token:function(a,b){var c=b.context;a.sol()&&(null==c.align&&(c.align=!1),b.indented=a.indentation(),b.startOfLine=!0);if(a.eatSpace())return null;y=null;var d=(b.tokenize||f)(a,b);if("comment"==d||"meta"==d)return d;null==c.align&&(c.align=!0);if(";"!=y&&":"!=y||"statement"!=c.type)if("{"==y)p(b,a.column(),"}");else if("["==y)p(b,
a.column(),"]");else if("("==y)p(b,a.column(),")");else if("}"==y){for(;"statement"==c.type;)c=m(b);for("}"==c.type&&(c=m(b));"statement"==c.type;)c=m(b)}else y==c.type?m(b):("}"==c.type||"top"==c.type||"statement"==c.type&&"newstatement"==y)&&p(b,a.column(),"statement");else m(b);b.startOfLine=!1;return d},indent:function(a,b){if(a.tokenize!=f&&null!=a.tokenize)return 0;var c=b&&b.charAt(0),d=a.context,e=c==d.type;return"statement"==d.type?d.indented+("{"==c?0:t):d.align?d.column+(e?0:1):d.indented+
(e?0:t)},electricChars:"{}"}});var c="attribute const uniform varying break continue do for while if else in out inout float int void bool true false lowp mediump highp precision invariant discard return mat2 mat3 mat4 vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 sampler2D samplerCube struct gl_FragCoord gl_FragColor",a="radians degrees sin cos tan asin acos atan pow exp log exp2 log2 sqrt inversesqrt abs sign floor ceil fract mod min max clamp mix step smoothstep length distance dot cross normalize faceforward reflect refract matrixCompMult lessThan lessThanEqual greaterThan greaterThanEqual equal notEqual any all not dFdx dFdy fwidth texture2D texture2DProj texture2DLod texture2DProjLod textureCube textureCubeLod require export";
d.defineMIME("text/x-glsl",{name:"glsl",keywords:g(c),builtins:g(a),blockKeywords:g("case do else for if switch while struct"),atoms:g("null"),hooks:{"#":function(a,c){if(!c.startOfLine)return!1;a.skipToEnd();return"meta"}}})}},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:
b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}
return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),e=function A(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),null===a?void 0:A(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},l=f(17);h=f(30);var r=f(100),n=f(19),k=f(115),p=f(120),m=f(121),t=f(64),q=f(125),v=f(126),x=f(8),w=f(51),z=f(106),C=f(127),u=f(129);f(131);f=function(d){function f(a,b){g(this,f);var d=c(this,
Object.getPrototypeOf(f).call(this,[]));d.manager=a;d.segmentColorHash=k.SegmentColorHash.getDefault();d.segmentSelectionState=new p.SegmentSelectionState;d.selectedAlpha=t.trackableAlphaValue(.5);d.notSelectedAlpha=t.trackableAlphaValue(0);d.wasDisposed=!1;d.visibleSegments=v.Uint64Set.makeWithCounterpart(a.worker);d.visibleSegments.changed.add(function(){d.specificationChanged.dispatch()});d.segmentSelectionState.bindTo(a.layerSelectedValues,d);d.selectedAlpha.changed.add(function(){d.specificationChanged.dispatch()});
d.notSelectedAlpha.changed.add(function(){d.specificationChanged.dispatch()});d.selectedAlpha.restoreState(b.selectedAlpha);d.notSelectedAlpha.restoreState(b.notSelectedAlpha);var e=d.volumePath=x.verifyOptionalString(b.source),h=d.meshPath=x.verifyOptionalString(b.mesh),n=d.skeletonsPath=x.verifyOptionalString(b.skeletons);void 0!==e&&(e=r.getVolumeWithStatusMessage(e),e.then(function(a){d.wasDisposed||d.meshLayer||(a=a.getMeshSource(d.manager.chunkManager),null!=a&&d.addMesh(a))}),d.addRenderLayer(new q.SegmentationRenderLayer(a.chunkManager,
e,d,d.selectedAlpha,d.notSelectedAlpha)));void 0!==h&&(e=b.meshLod,"number"!==typeof e&&(e=void 0),d.meshLod=e,d.addMesh(l.getMeshSource(a.chunkManager,h,e)));void 0!==n&&(h=new m.SkeletonLayer(a.chunkManager,l.getSkeletonSource(a.chunkManager,n),a.voxelSize,d),d.addRenderLayer(new m.PerspectiveViewSkeletonLayer(h)),d.addRenderLayer(new m.SliceViewPanelSkeletonLayer(h)));x.verifyObjectProperty(b,"segments",function(a){void 0!==a&&function(){var b=d.visibleSegments;x.parseArray(a,function(a){a=w.Uint64.parseString(String(a),
10);b.add(a)})}()});return d}a(f,d);b(f,[{key:"disposed",value:function(){e(Object.getPrototypeOf(f.prototype),"disposed",this).call(this);this.wasDisposed=!0}},{key:"addMesh",value:function(a){this.meshLayer=new n.MeshLayer(this.manager.chunkManager,a,this);this.addRenderLayer(this.meshLayer)}},{key:"toJSON",value:function(){var a={type:"segmentation"};a.source=this.volumePath;a.mesh=this.meshPath;a.meshLod=this.meshLod;a.skeletons=this.skeletonsPath;a.selectedAlpha=this.selectedAlpha.toJSON();a.notSelectedAlpha=
this.notSelectedAlpha.toJSON();var b=this.visibleSegments;if(0<b.size)for(var c=a.segments=[],b=$jscomp.makeIterator(b),d=b.next();!d.done;d=b.next())c.push(d.value.toString());return a}},{key:"makeDropdown",value:function(a){return new y(a,this)}},{key:"handleAction",value:function(a){switch(a){case "recolor":this.segmentColorHash.randomize();break;case "clear-segments":this.visibleSegments.clear();break;case "select":if(a=this.segmentSelectionState,a.hasSelectedSegment){a=a.selectedSegment;var b=
this.visibleSegments;b.has(a)?b.delete(a):b.add(a)}}}}]);return f}(h.UserLayer);d.SegmentationUserLayer=f;var y=function(b){function d(a,b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this));e.element=a;e.layer=b;e.visibleSegmentWidget=e.registerDisposer(new C.SegmentSetWidget(e.layer));e.addSegmentWidget=e.registerDisposer(new u.Uint64EntryWidget);e.selectedAlphaWidget=e.registerDisposer(new z.RangeWidget(e.layer.selectedAlpha));e.notSelectedAlphaWidget=e.registerDisposer(new z.RangeWidget(e.layer.notSelectedAlpha));
a.classList.add("segmentation-dropdown");var f=e.notSelectedAlphaWidget;e.selectedAlphaWidget.promptElement.textContent="Opacity (on)";f.promptElement.textContent="Opacity (off)";a.appendChild(e.selectedAlphaWidget.element);a.appendChild(e.notSelectedAlphaWidget.element);e.addSegmentWidget.element.classList.add("add-segment");e.addSegmentWidget.element.title="Add segment ID";a.appendChild(e.registerDisposer(e.addSegmentWidget).element);e.registerSignalBinding(e.addSegmentWidget.valueEntered.add(function(a){e.layer.visibleSegments.add(a)}));
a.appendChild(e.registerDisposer(e.visibleSegmentWidget).element);return e}a(d,b);return d}(h.UserLayerDropdown)},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a){return a-Math.floor(a)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),
b=f(116),e=f(117),l=f(119),r=f(70),n=f(23);h=function(){function c(a){g(this,c);this.prefix=a;this.aName=this.prefix+"_a";this.bName=this.prefix+"_b"}a(c,[{key:"defineShader",value:function(a){var c=this.aName,d=this.bName;a.addUniform("highp vec4",c,4);a.addUniform("highp float",d,4);a.addFragmentCode(r.glsl_uint64);a.addFragmentCode(e.glsl_hashFunction);a.addFragmentCode(r.glsl_hsvToRgb);for(var f="\nvec3 "+this.prefix+"(uint64_t x) {\n  vec2 v;\n  float primeModulus = float("+b.PRIME_MODULUS+");\n",
k=0;2>k;++k)var g=2*k,h=2*k,f=f+("\n  v["+k+"] = computeHash(x, "+c+"["+h+"], "+c+"["+(h+1)+"], "+d+"["+g+"], "+d+"["+(g+1)+"], primeModulus, 1.0 / 256.0);\n");a.addFragmentCode(f+"\n  vec3 hsv = vec3(v.x, 0.5 + v.y * 0.5, 1.0);\n  return hsvToRgb(hsv);\n}\n")}},{key:"enable",value:function(a,b,c){a.uniform4fv(b.uniform(this.aName),c.a_);a.uniform1fv(b.uniform(this.bName),c.b_)}}]);return c}();d.SegmentColorShaderManager=h;var k=new Float32Array(2),p=new Float32Array(3);h=function(){function d(a){g(this,
d);this.a_=new Float32Array(16);this.b_=new Float32Array(4);this.changed=new n.Signal;null==a?(this.hashFunctions=Array(2),this.randomize_()):this.hashFunctions=a;this.computeGPUCoefficients_()}a(d,[{key:"compute",value:function(a,b){for(var d=b.low,e=b.high,f=this.hashFunctions,g=0;2>g;++g)k[g]=c(f[g].compute(d,e)/256);l.hsvToRgb(a,k[0],.5+.5*k[1],1);return a}},{key:"computeCssColor",value:function(a){this.compute(p,a);return"rgb("+100*p[0]+"%,"+100*p[1]+"%,"+100*p[2]+"%)"}},{key:"debugCompute",
value:function(a,d){for(var e=d.low,f=d.high,k=this.b_,g=b.PRIME_MODULUS,h=0;2>h;++h){for(var l=2*h,m=2*h,n=new Float32Array(2),p=0;4>p;++p)n[0]+=this.a_[4*m+p]*(e>>8*p&255),n[1]+=this.a_[4*(m+1)+p]*(f>>8*p&255);var m=(n[0]+n[1])%g,p=m*m%g,r=p*k[l+1]%g,E=(k[l]+m+r)%g;console.log("b = "+k[l]+", sums="+n[0]+" "+n[1]+", dotResult="+m+", prod = "+m*m+" dotResult2="+p+", y="+r+", modResult="+E);a[h]=c(1/256*E)}return a}},{key:"randomize_",value:function(){for(var a=0;2>a;++a)this.hashFunctions[a]=b.HashFunction.generate()}},
{key:"randomize",value:function(){this.randomize_();this.computeGPUCoefficients_();this.changed.dispatch()}},{key:"toString",value:function(){return"new SegmentColorHash(["+this.hashFunctions+"])"}},{key:"computeGPUCoefficients_",value:function(){for(var a=this.hashFunctions,b=this.a_,c=this.b_,d=0;2>d;++d){var e=a[d],f=2*d,k=8*d;c[f]=1*e.b;c[f+1]=1*e.c;for(f=0;4>f;++f)b[k+f]=1*e.a0[f],b[k+4+f]=1*e.a1[f]}}}],[{key:"getDefault",value:function(){return new d([new b.HashFunction(Float32Array.of(609,
2364,3749,2289),Float32Array.of(2840,1186,3660,1833),1718,1109),new b.HashFunction(Float32Array.of(3466,3835,3345,2040),Float32Array.of(3382,901,18,3444),1534,1432)])}}]);return d}();d.SegmentColorHash=h},function(h,d){var f=function(){function c(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(a,b,d){b&&c(a.prototype,b);d&&c(a,d);return a}}();d.PRIME_MODULUS=4093;var g=function(){function c(a,
b,d,f){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");this.a0=a;this.a1=b;this.b=d;this.c=f}f(c,[{key:"computeDotProduct",value:function(a,b){var c=this.a0,d=this.a1;return c[0]*(a&255)+c[1]*(a>>8&255)+c[2]*(a>>16&255)+c[3]*(a>>24&255)+(d[0]*(b&255)+d[1]*(b>>8&255)+d[2]*(b>>16&255)+d[3]*(b>>24&255))}},{key:"compute",value:function(a,b){var c=this.b,f=this.c,g=this.computeDotProduct(a,b);return(g+g*g%d.PRIME_MODULUS*f+c)%d.PRIME_MODULUS}},{key:"toString",value:function(){return"new HashFunction(Float32Array.of("+
this.a0+"), Float32Array.of("+this.a1+"), "+this.b+", "+this.c+")"}}],[{key:"generate",value:function(){function a(){return Math.floor(Math.random()*d.PRIME_MODULUS)}return new c(Float32Array.of(a(),a(),a(),a()),Float32Array.of(a(),a(),a(),a()),a(),a())}}]);return c}();d.HashFunction=g},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),b=f(116),e=f(118);h=f(12);var l=f(70),r=f(67);d.glsl_hashFunction=
[l.glsl_uint64,l.glsl_exactDot,l.glsl_imod,"\nfloat computeHash(uint64_t x, vec4 a0, vec4 a1, float b, float c, float modulus, float scalar) {\n  x.low *= 255.0;\n  x.high *= 255.0;\n  float dotResult = imod(exactDot(a0, x.low) + exactDot(a1, x.high), modulus);\n  float dotResult2 = imod(dotResult * dotResult, modulus);\n  float y = imod(dotResult2 * c, modulus);\n  float modResult = imod(dotResult + y + b, modulus);\n  return fract(modResult * scalar);\n}\n"];f=function(d){function e(a,b){g(this,
e);var c;c=Object.getPrototypeOf(e).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");c=!c||"object"!==typeof c&&"function"!==typeof c?this:c;c.gl=a;c.hashTable=b;c.hashFunctions=null;c.generation=-1;c.textures=[];var d=b.hashFunctions.length;c.a=new Float32Array(16*d);c.b=new Float32Array(4*d+5);for(var f=c.textures,h=0;h<d;++h)f[h]=a.createTexture();return c}c(e,d);a(e,[{key:"computeCoefficients",value:function(){var a=this.hashTable,c=a.hashFunctions;
if(this.hashFunctions!==c){this.hashFunctions=c;for(var d=this.a,e=this.b,f=c.length,k=a.width,a=[1/k,1/a.height],g=0;2>g;++g)e[4*f+g]=b.PRIME_MODULUS,e[4*f+3+g]=a[g];e[4*f+2]=1/(2*k);for(k=0;k<f;++k)for(a=c[k],g=0;2>g;++g){var h=a[g],l=4*k+2*g,n=4*(4*k+2*g);e[l]=h.b+(0===g?.25:.5);e[l+1]=h.c;for(l=0;4>l;++l)d[n+l]=h.a0[l],d[n+4+l]=h.a1[l]}}}},{key:"copyToGPU",value:function(){this.computeCoefficients();var a=this.hashTable,b=a.generation;if(this.generation!==b){this.generation=b;var b=a.width,c=
a.height,a=a.tables,d=this.gl,e=this.textures,f=e.length;d.activeTexture(d.TEXTURE0+d.tempTextureUnit);for(var k=0;k<f;++k){d.bindTexture(d.TEXTURE_2D,e[k]);d.pixelStorei(d.UNPACK_ALIGNMENT,1);r.setRawTextureParameters(d);var g=d.RGBA;d.texImage2D(d.TEXTURE_2D,0,g,2*b,c,0,g,d.UNSIGNED_BYTE,new Uint8Array(a[k].buffer))}d.bindTexture(d.TEXTURE_2D,null)}}},{key:"disposed",value:function(){var a=this.gl;this.textures.forEach(function(b){a.deleteTexture(b)});this.hashTable=this.gl=this.textures=void 0;
this.hashFunctions=null}}],[{key:"get",value:function(a,b){return a.memoize.get(b,function(){return new e(a,b)})}}]);return e}(h.RefCounted);d.GPUHashTable=f;f=function(){function b(a){var c=1>=arguments.length||void 0===arguments[1]?e.NUM_ALTERNATIVES:arguments[1];g(this,b);this.prefix=a;this.numAlternatives=c;$jscomp.initSymbol();this.textureUnitSymbol=Symbol("gpuhashtable:"+this.prefix);this.aName=this.prefix+"_a";this.bName=this.prefix+"_b";this.samplerName=this.prefix+"_sampler"}a(b,[{key:"defineShader",
value:function(a){var b=this.aName,c=this.bName,e=this.samplerName,f=this.numAlternatives;a.addUniform("highp vec4",b,4*f);a.addUniform("highp float",c,4*f+5);a.addTextureSampler2D(e,this.textureUnitSymbol,f);a.addFragmentCode(d.glsl_hashFunction);for(var g="",h=0;h<f;++h){for(var l=0;2>l;++l)var n=4*h+2*l,r=4*h+2*l,g=g+("\nfloat "+this.prefix+"_computeHash_"+h+"_"+l+"(uint64_t x) {\n  float primeModulus = "+c+"["+(4*f+l)+"];\n  float scalar = "+c+"["+(4*f+3+l)+"];\n  return computeHash(x, "+b+"["+
r+"], "+b+"["+(r+1)+"], "+c+"["+n+"], "+c+"["+(n+1)+"], primeModulus, scalar);\n}\n");g+="\nvec2 "+this.prefix+"_computeHash_"+h+"(uint64_t x) {\n  vec2 v;\n  v[0] = "+this.prefix+"_computeHash_"+h+"_0(x);\n  v[1] = "+this.prefix+"_computeHash_"+h+"_1(x);\n  return v;\n}\n"}g+="\nbool "+this.hasFunctionName+"(uint64_t x) {\n  float highOffset = "+c+"["+(4*f+2)+"];\n";for(b=0;b<f;++b)g+="\n  {\n    vec2 v = "+this.prefix+"_computeHash_"+b+"(x);\n    vec4 lowResult = texture2D("+e+"["+b+"], v);\n    vec4 highResult = texture2D("+
e+"["+b+"], vec2(v.x + highOffset, v.y));\n    if (lowResult == x.low && highResult == x.high) {\n      return true;\n    }\n  }\n";a.addFragmentCode(g+"\n  return false;\n}\n")}},{key:"enable",value:function(a,b,c){var d=this.numAlternatives,e=c.textures;c.copyToGPU();for(var f=b.textureUnit(this.textureUnitSymbol),g=0;g<d;++g)a.activeTexture(a.TEXTURE0+(g+f)),a.bindTexture(a.TEXTURE_2D,e[g]);a.uniform4fv(b.uniform(this.aName),c.a);a.uniform1fv(b.uniform(this.bName),c.b)}},{key:"disable",value:function(a,
b){for(var c=this.numAlternatives,d=b.textureUnit(this.textureUnitSymbol),e=0;e<c;++e)a.activeTexture(a.TEXTURE0+(e+d)),a.bindTexture(a.TEXTURE_2D,null)}},{key:"hasFunctionName",get:function(){return this.prefix+"_has"}}]);return b}();d.HashTableShaderManager=f},function(h,d,f){var g=function(){function a(a,c){for(var d=0;d<c.length;d++){var f=c[d];f.enumerable=f.enumerable||!1;f.configurable=!0;"value"in f&&(f.writable=!0);Object.defineProperty(a,f.key,f)}}return function(b,c,d){c&&a(b.prototype,
c);d&&a(b,d);return b}}(),c=f(116);d.NUM_ALTERNATIVES=3;h=function(){function a(){var b=0>=arguments.length||void 0===arguments[0]?a.generateHashFunctions(d.NUM_ALTERNATIVES):arguments[0];if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.loadFactor=.9;this.size=0;this.growFactor=1.2;this.maxWidth=4096;this.maxHeight=8192;this.emptyHigh=this.emptyLow=4294967295;this.maxAttempts=this.maxRehashAttempts=5;this.generation=0;this.hashFunctions=b;this.allocate(4,1)}$jscomp.initSymbol();
$jscomp.initSymbolIterator();g(a,[{key:"updateHashFunctions",value:function(b){this.hashFunctions=a.generateHashFunctions(b)}},{key:"getHash",value:function(a,c,d){a=this.hashFunctions[a];var f=this.width,g=this.height,f=a[0].compute(c,d)%f;return 2*(a[1].compute(c,d)%g*this.width+f)}},{key:Symbol.iterator,value:function(){function a(b,u){for(;;)switch(c){case 0:x=w.width*w.height,v=w.emptyLow,q=w.emptyHigh,t=[0,0],m=$jscomp.makeIterator(w.tables),h=m.next();case 1:if(h.done){c=3;break}k=h.value;
g=0;case 4:if(!(g<x)){c=6;break}f=k[2*g];d=k[2*g+1];if(f===v&&d===q){c=7;break}t[0]=f;t[1]=d;c=8;return{value:t,done:!1};case 8:if(void 0===u){c=9;break}c=-1;throw u;case 9:case 7:case 5:++g;c=4;break;case 6:case 2:h=m.next();c=1;break;case 3:c=-1;default:return{value:void 0,done:!0}}}var c=0,d,f,g,k,h,m,t,q,v,x,w=this,z={next:function(c){return a(c,void 0)},throw:function(c){return a(void 0,c)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();z[Symbol.iterator]=
function(){return this};return z}},{key:"hasWithTableIndex",value:function(a,c){for(var d=this.tables.length,f=0;f<d;++f){var g=this.getHash(f,a,c),k=this.tables[f];if(k[g]===a&&k[g+1]===c)return f}return null}},{key:"has",value:function(a,c){for(var d=this.tables.length,f=0;f<d;++f){var g=this.getHash(f,a,c),k=this.tables[f];if(k[g]===a&&k[g+1]===c)return!0}return!1}},{key:"delete",value:function(a,c){for(var d=this.tables.length,f=0;f<d;++f){var g=this.getHash(f,a,c),k=this.tables[f];if(k[g]===
a&&k[g+1]===c)return k[g]=this.emptyLow,k[g+1]=this.emptyHigh,++this.generation,this.size--,!0}return!1}},{key:"clear",value:function(){if(0===this.size)return!1;this.size=0;++this.generation;for(var a=this.tables,c=this.emptyLow,d=this.emptyHigh,f=a.length,g=0;g<f;++g)for(var k=a[g],h=k.length,m=0;m<h;m+=2)k[m]=c,k[m+1]=d;return!0}},{key:"tryToInsert",value:function(a,c){for(var d=0,f=this.emptyLow,g=this.emptyHigh,k=this.maxAttempts,h=this.tables,m=h.length,t=Math.floor(Math.random()*m);;){var q=
this.getHash(t,a,c),v=h[t],x=v[q],w=v[q+1];v[q]=a;v[q+1]=c;if(x===f&&w===g)return null;a=x;c=w;if(++d===k)break;t=(t+Math.floor(Math.random()*(m-1)))%m}return[a,c]}},{key:"allocate",value:function(a,c){var d=a*c;this.width=a;this.height=c;for(var f=this.hashFunctions.length,g=this.tables=Array(f),k=0;k<f;++k)g[k]=new Uint32Array(2*d);this.maxAttempts=d;for(var f=this.emptyLow,k=this.emptyHigh,g=$jscomp.makeIterator(g),h=g.next();!h.done;h=g.next())for(var h=h.value,m=0;m<d;++m)h[2*m]=f,h[2*m+1]=k;
this.capacity=d*this.tables.length*this.loadFactor}},{key:"rehash",value:function(a,c,d){this.allocate(c,d);this.updateHashFunctions(a.length);a=$jscomp.makeIterator(a);for(c=a.next();!c.done;c=a.next()){c=c.value;d=c.length/2;for(var f=0;f<d;++f){var g=2*f,k=c[g],g=c[g+1];if((0!==k||0!==g)&&null!==this.tryToInsert(k,g))return!1}}return!0}},{key:"grow",value:function(a){for(var c=this.tables,d=this.width,f=this.height,g=this.maxWidth,k=this.maxHeight;;){var h=d*f,d=Math.min(g,Math.ceil(a/this.height));
d*f<a&&(f=Math.min(k,Math.ceil(a/this.width)));var m=d*f;if(m<a&&m===h)throw Error("Maximum table size exceeded");for(h=0;h<this.maxRehashAttempts;++h)if(this.rehash(c,d,f))return;a=Math.ceil(this.growFactor*a)}}},{key:"add",value:function(a,c){if(this.has(a,c))return!1;++this.generation;for(++this.size>this.capacity&&this.grow(Math.ceil(this.growFactor*this.width*this.height));;){var d=this.tryToInsert(a,c);if(null==d)return!0;a=d[0];c=d[1];this.grow(this.width*this.height)}}}],[{key:"generateHashFunctions",
value:function(){for(var a=0>=arguments.length||void 0===arguments[0]?d.NUM_ALTERNATIVES:arguments[0],e=[],f=0;f<a;++f){var g=[c.HashFunction.generate(),c.HashFunction.generate()];e.push(g)}return e}}]);return a}();d.HashTable=h},function(h,d){d.hsvToRgb=function(d,g,c,a){g*=6;var b=Math.floor(g),e=g-b;g=a*(1-c);var h=a*(1-c*e);c=a*(1-c*(1-e));switch(b%6){case 0:d[0]=a;d[1]=c;d[2]=g;break;case 1:d[0]=h;d[1]=a;d[2]=g;break;case 2:d[0]=g;d[1]=a;d[2]=c;break;case 3:d[0]=g;d[1]=h;d[2]=a;break;case 4:d[0]=
c;d[1]=g;d[2]=a;break;case 5:d[0]=a,d[1]=g,d[2]=h}return d}},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var c=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=
!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var a=f(51),b=f(23);f=function(d){function f(){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");for(var c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];var g,c=(g=Object.getPrototypeOf(f)).call.apply(g,[].concat([this],$jscomp.arrayFromIterable(d)));if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
g=!c||"object"!==typeof c&&"function"!==typeof c?this:c;g.selectedSegment=new a.Uint64;g.hasSelectedSegment=!1;g.changed=new b.Signal;return g}g(f,d);c(f,[{key:"set",value:function(a){if(null==a)this.hasSelectedSegment&&(this.hasSelectedSegment=!1,this.changed.dispatch());else{var b=this.selectedSegment;this.hasSelectedSegment&&a.low===b.low&&a.high===b.high||(b.low=a.low,b.high=a.high,this.hasSelectedSegment=!0,this.changed.dispatch())}}},{key:"isSelected",value:function(b){return this.hasSelectedSegment&&
a.Uint64.equal(b,this.selectedSegment)}},{key:"bindTo",value:function(b,c){var d=this,e=new a.Uint64;this.registerSignalBinding(b.changed.add(function(){var a=b.get(c);"number"===typeof a&&(e.low=a,e.high=0,a=e);d.set(a)}))}}]);return f}(h.RefCounted);d.SegmentSelectionState=f},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&
null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}var b=function u(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),
null===a?void 0:u(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),l=f(20);h=f(21);var r=f(24),n=f(122),k=f(12),p=f(39),m=f(26),t=f(29),q=f(70),v=f(11),x=f(23),w=function(){function b(){a(this,b);this.tempMat=p.mat4.create();
this.tempPickID=new Float32Array(4)}e(b,[{key:"defineShader",value:function(a){a.addAttribute("highp vec3","aVertexPosition");a.addUniform("highp vec3","uColor");a.addUniform("highp mat4","uProjection");a.addUniform("highp vec4","uPickID");a.setVertexMain("gl_Position = uProjection * vec4(aVertexPosition, 1.0);");a.setFragmentMain("emit(vec4(uColor, 1.0), uPickID);")}},{key:"beginLayer",value:function(a,b,c,d){c=p.mat4.multiply(this.tempMat,c.dataToDevice,d);a.uniformMatrix4fv(b.uniform("uProjection"),
!1,c)}},{key:"getShader",value:function(a,b,c){var d=this;return a.memoize.get(b,function(){var b=new t.ShaderBuilder(a);b.require(c);d.defineShader(b);return b.build()})}},{key:"drawSkeleton",value:function(a,b,c,d,e,f){f||a.uniform3fv(b.uniform("uColor"),d);a.uniform4fv(b.uniform("uPickID"),q.setVec4FromUint32(this.tempPickID,e));c.vertexBuffer.bindToVertexAttrib(b.attribute("aVertexPosition"),3);c.indexBuffer.bind();a.drawElements(a.LINES,c.numIndices,a.UNSIGNED_INT,0)}},{key:"endLayer",value:function(a,
b){a.disableVertexAttribArray(b.attribute("aVertexPosition"))}}]);return b}();f=function(b){function d(b){a(this,d);var c=g(this,Object.getPrototypeOf(d).call(this));c.base=b;c.shader=c.base.skeletonShaderManager.getShader(c.gl,"skeleton/SkeletonShaderManager:PerspectivePanel",r.perspectivePanelEmit);c.registerDisposer(b);c.registerSignalBinding(b.redrawNeeded.add(function(){c.redrawNeeded.dispatch()}));c.setReady(!0);return c}c(d,b);e(d,[{key:"draw",value:function(a){this.base.draw(a,this,this.shader,
1>=arguments.length||void 0===arguments[1]?!1:arguments[1])}},{key:"drawPicking",value:function(a){this.base.draw(a,this,this.shader,!0)}},{key:"gl",get:function(){return this.base.gl}}]);return d}(r.PerspectiveViewRenderLayer);d.PerspectiveViewSkeletonLayer=f;f=function(b){function d(b){a(this,d);var c=g(this,Object.getPrototypeOf(d).call(this));c.base=b;c.shader=c.base.skeletonShaderManager.getShader(c.gl,"skeleton/SkeletonShaderManager:SliceViewPanel",n.sliceViewPanelEmit);c.registerDisposer(b);
c.registerSignalBinding(b.redrawNeeded.add(function(){c.redrawNeeded.dispatch()}));c.setReady(!0);return c}c(d,b);e(d,[{key:"draw",value:function(a){console.log("drawing on sliceview");this.base.draw(a,this,this.shader,!1,10)}},{key:"gl",get:function(){return this.base.gl}}]);return d}(n.SliceViewPanelRenderLayer);d.SliceViewPanelSkeletonLayer=f;k=function(b){function d(b,c,e,f){a(this,d);var k=g(this,Object.getPrototypeOf(d).call(this));k.chunkManager=b;k.source=c;k.voxelSizeObject=e;k.displayState=
f;k.tempMat=p.mat4.create();k.skeletonShaderManager=new w;k.redrawNeeded=new x.Signal;e=function(){k.redrawNeeded.dispatch()};k.registerSignalBinding(f.segmentColorHash.changed.add(e));k.registerSignalBinding(f.visibleSegments.changed.add(e));k.registerSignalBinding(f.segmentSelectionState.changed.add(e));k.registerDisposer(new v.SharedObject).initializeCounterpart(b.rpc,{type:"skeleton/SkeletonLayer",chunkManager:b.rpcId,source:c.addCounterpartRef(),visibleSegmentSet:f.visibleSegments.rpcId});return k}
c(d,b);e(d,[{key:"draw",value:function(a,b,c){var d=3>=arguments.length||void 0===arguments[3]?!1:arguments[3],e=arguments[4];void 0===e&&(e=d?5:1);var f=this.gl,g=this.skeletonShaderManager;c.bind();var k=this.tempMat;p.mat4.identity(k);p.mat4.scale(k,k,this.voxelSizeObject.size);g.beginLayer(f,c,a,k);var k=this.source.chunks,h=a.pickIDs,m=p.vec3.create(),n=this.displayState,q=n.segmentColorHash,u=n.segmentSelectionState;f.lineWidth(e);e=$jscomp.makeIterator(n.visibleSegments);for(n=e.next();!n.done;n=
e.next()){var n=n.value,r=k.get(n.low+":"+n.high);if(void 0!==r&&r.state===l.ChunkState.GPU_MEMORY){if(!d&&(q.compute(m,n),u.isSelected(n)))for(var w=0;3>w;++w)m[w]=.5*m[w]+.5;g.drawSkeleton(f,c,r,m,h.register(b,n),d)}}g.endLayer(f,c)}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}}]);return d}(k.RefCounted);d.SkeletonLayer=k;var z=function(d){function f(b,c){a(this,f);var d=g(this,Object.getPrototypeOf(f).call(this,b));d.data=c.data;return d}c(f,d);e(f,[{key:"copyToGPU",
value:function(a){b(Object.getPrototypeOf(f.prototype),"copyToGPU",this).call(this,a);var c=this.data,d=(new DataView(c.buffer)).getInt32(0,!0),e=new Float32Array(c.buffer,4,3*d),c=new Uint32Array(c.buffer,12*d+4);this.vertexBuffer=m.Buffer.fromData(a,e,a.ARRAY_BUFFER,a.STATIC_DRAW);this.indexBuffer=m.Buffer.fromData(a,c,a.ELEMENT_ARRAY_BUFFER,a.STATIC_DRAW);this.numIndices=c.length}},{key:"freeGPUMemory",value:function(a){b(Object.getPrototypeOf(f.prototype),"freeGPUMemory",this).call(this,a);this.vertexBuffer.dispose();
this.indexBuffer.dispose()}}]);return f}(h.Chunk);d.SkeletonChunk=z;h=function(b){function d(){a(this,d);return g(this,Object.getPrototypeOf(d).apply(this,arguments))}c(d,b);e(d,[{key:"getChunk",value:function(a){return new z(this,a)}}]);return d}(h.ChunkSource);d.SkeletonSource=h},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function b(a){a.addFragmentExtension("GL_EXT_draw_buffers");a.addFragmentCode("\nvoid emit(vec4 color, vec4 pickId) {\n  gl_FragData["+
z.COLOR+"] = color;\n  gl_FragData["+z.PICK+"] = pickId;\n}\n")}var e=function y(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d)return a=Object.getPrototypeOf(a),null===a?void 0:y(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},l=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,
c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),r=f(25),n=f(30),k=f(52);h=f(53);var p=f(58),m=f(68),t=f(39),q=f(69),v=f(66),x=f(123),w=f(23);(function(a){a[a.COLOR=0]="COLOR";a[a.PICK=1]="PICK";a[a.NUM_TEXTURES=2]="NUM_TEXTURES"})(d.OffscreenTextures||(d.OffscreenTextures={}));var z=d.OffscreenTextures;d.sliceViewPanelEmit=b;var C=function(b){function d(){g(this,d);for(var a=arguments.length,b=Array(a),e=0;e<a;e++)b[e]=arguments[e];var f,a=c(this,(f=Object.getPrototypeOf(d)).call.apply(f,[].concat([this],
$jscomp.arrayFromIterable(b))));a.redrawNeeded=new w.Signal;return a}a(d,b);l(d,[{key:"draw",value:function(a){}}]);return d}(n.RenderLayer);d.SliceViewPanelRenderLayer=C;f=function(d){function f(a,d,e,h){g(this,f);var l=c(this,Object.getPrototypeOf(f).call(this,a,d,h));l.sliceView=e;l.axesLineHelper=r.AxesLineHelper.get(l.gl);l.sliceViewRenderHelper=p.SliceViewRenderHelper.get(l.gl,"SliceViewRenderHelper",b);l.colorFactor=t.vec4.fromValues(1,1,1,1);l.backgroundColor=t.vec4.fromValues(.5,.5,.5,1);
l.pickIDs=new k.PickIDManager;l.visibleLayerTracker=l.registerDisposer(new n.VisibleRenderLayerTracker(l.viewer.layerManager,C,function(a){a.redrawNeeded.add(l.scheduleRedraw,l);l.scheduleRedraw()},function(a){a.redrawNeeded.remove(l.scheduleRedraw,l);l.scheduleRedraw()}));l.offscreenFramebuffer=new v.OffscreenFramebuffer(l.gl,{numDataBuffers:z.NUM_TEXTURES});l.offscreenCopyHelper=v.OffscreenCopyHelper.get(l.gl);l.scaleBarWidget=l.registerDisposer(new x.ScaleBarWidget);l.registerDisposer(e);l.registerSignalBinding(e.viewChanged.add(a.scheduleRedraw,
a));l.registerSignalBinding(h.showAxisLines.changed.add(function(){l.scheduleRedraw()}));a=l.scaleBarWidget.element;l.registerDisposer(new m.ElementVisibilityFromTrackableBoolean(h.showScaleBar,a));l.element.appendChild(a);return l}a(f,d);l(f,[{key:"draw",value:function(){var a=this.sliceView;if(a.hasValidViewport){a.updateRendering();var b=this.gl,c=a.width,d=a.height,e=a.dataToDevice;this.offscreenFramebuffer.bind(c,d);b.disable(b.SCISSOR_TEST);this.gl.clearColor(0,0,0,0);b.clear(b.COLOR_BUFFER_BIT);
var f=t.mat4.create();this.sliceViewRenderHelper.draw(a.offscreenFramebuffer.dataTextures[0],t.identityMat4,this.colorFactor,this.backgroundColor,0,0,1,1);var g=this.visibleLayerTracker.getVisibleLayers(),k=this.pickIDs;k.clear();for(var k={dataToDevice:a.dataToDevice,pickIDs:k},g=$jscomp.makeIterator(g),h=g.next();!h.done;h=g.next())h.value.draw(k);if(this.viewer.showAxisLines.value){t.mat4.copy(f,e);for(e=0;3>e;++e)f[12+e]=0;for(e=0;4>e;++e)f[2+4*e]=0;d=Math.min(c,d)/4*1.5;e=a.pixelSize;for(k=0;12>
k;++k)f[k]=f[k]*d*e;b.WEBGL_draw_buffers.drawBuffersWEBGL([b.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL]);this.axesLineHelper.draw(f)}this.offscreenFramebuffer.unbind();this.setGLViewport();this.offscreenCopyHelper.draw(this.offscreenFramebuffer.dataTextures[z.COLOR]);b=this.scaleBarWidget;f=b.dimensions;f.targetLengthInPixels=Math.min(c/4,100);f.nanometersPerPixel=a.pixelSize;b.update()}}},{key:"onResize",value:function(){this.sliceView.setViewportSize(this.element.clientWidth,this.element.clientHeight)}},
{key:"updateMouseState",value:function(a){a.pickedRenderLayer=null;var b=this.sliceView;if(!b.hasValidViewport)return!1;var c=b.width,d=b.height,e=this.offscreenFramebuffer;if(!e.hasSize(c,d))return!1;var f=a.position,g=this.mouseX,k=this.mouseY;t.vec3.set(f,g-c/2,k-d/2,0);t.vec3.transformMat4(f,f,b.viewportToData);this.pickIDs.setMouseState(a,e.readPixelAsUint32(z.PICK,g,d-k));return!0}},{key:"onMousedown",value:function(a){var b=this;event.target===this.element&&(e(Object.getPrototypeOf(f.prototype),
"onMousedown",this).call(this,a),this.sliceView.hasValidViewport&&0===a.button&&this.viewer.mouseState.updateUnconditionally()&&function(){var c=t.vec3.clone(b.viewer.mouseState.position);q.startRelativeMouseDrag(a,function(a,d,e){var f=b.viewer.navigationState.position;a.shiftKey?(f=b.sliceView.viewportAxes,b.viewer.navigationState.pose.rotateAbsolute(f[1],d/4*Math.PI/180,c),b.viewer.navigationState.pose.rotateAbsolute(f[0],e/4*Math.PI/180,c)):(a=f.spatialCoordinates,t.vec3.set(a,d,e,0),t.vec3.transformMat4(a,
a,b.sliceView.viewportToData),f.changed.dispatch())})}())}},{key:"zoomByMouse",value:function(a){var b=this.navigationState;if(b.valid){var c=this.sliceView,d=c.height,e=this.mouseX,f=this.mouseY,e=e-c.width/2,f=f-d/2,d=this.navigationState.zoomFactor.value;b.zoomBy(a);a=b.zoomFactor.value;var g=b.position.spatialCoordinates;t.vec3.scaleAndAdd(g,g,c.viewportAxes[0],e*(d-a));t.vec3.scaleAndAdd(g,g,c.viewportAxes[1],f*(d-a));b.position.changed.dispatch()}}},{key:"navigationState",get:function(){return this.sliceView.navigationState}}]);
return f}(h.RenderedDataPanel);d.SliceViewPanel=f},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}var a=function(){function a(b,
c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var b=f(7);f(124);var e=[1.5,2,3,5,7.5,10],l=[{unit:"km",lengthInNanometers:1E12},{unit:"m",lengthInNanometers:1E9},{unit:"mm",lengthInNanometers:1E6},{unit:"\u00b5m",lengthInNanometers:1E3},{unit:"nm",lengthInNanometers:1},{unit:"pm",lengthInNanometers:.001}],r=function(){function b(){c(this,
b);this.allowedSignificands=e;this.prevTargetLengthInPixels=this.prevNanometersPerPixel=0}a(b,[{key:"update",value:function(){var a=this.nanometersPerPixel,b=this.targetLengthInPixels;if(this.prevNanometersPerPixel===a&&this.prevTargetLengthInPixels===b)return!1;this.prevNanometersPerPixel=a;this.prevTargetLengthInPixels=b;for(var c=b*a,b=Math.pow(10,Math.floor(Math.log(c)/Math.LN10)),c=c/b,d=1,e=$jscomp.makeIterator(this.allowedSignificands),f=e.next();!f.done;f=e.next())if(f=f.value,Math.abs(f-
c)<Math.abs(d-c))d=f;else break;b*=d;c=l.length;d=l[c-1];for(e=0;e<c;++e)if(f=l[e],b>=f.lengthInNanometers){d=f;break}this.lengthInPixels=Math.round(b/a);this.physicalUnit=d.unit;this.physicalLength=b/d.lengthInNanometers;return!0}}]);return b}();d.ScaleBarDimensions=r;f=function(d){function e(){var a=0>=arguments.length||void 0===arguments[0]?new r:arguments[0];c(this,e);var b;b=Object.getPrototypeOf(e).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
b=!b||"object"!==typeof b&&"function"!==typeof b?this:b;b.dimensions=a;b.element=document.createElement("div");b.textNode=document.createTextNode("");b.barElement=document.createElement("div");var a=b.element,d=b.textNode,f=b.barElement;a.className="scale-bar-container";a.appendChild(d);a.appendChild(f);f.className="scale-bar";return b}g(e,d);a(e,[{key:"update",value:function(){var a=this.dimensions;a.update()&&(this.textNode.textContent=a.physicalLength+" "+a.physicalUnit,this.barElement.style.width=
a.lengthInPixels+"px")}},{key:"disposed",value:function(){b.removeFromParent(this.element)}}]);return e}(h.RefCounted);d.ScaleBarWidget=f},function(h,d){},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&
b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),b=function k(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===
d)return a=Object.getPrototypeOf(a),null===a?void 0:k(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},e=f(117),l=f(115),r=f(64);h=function(d){function f(a,b,c){var d=3>=arguments.length||void 0===arguments[3]?r.trackableAlphaValue(.5):arguments[3],k=4>=arguments.length||void 0===arguments[4]?r.trackableAlphaValue(0):arguments[4];if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var h=g(this,Object.getPrototypeOf(f).call(this,a,b));h.displayState=
c;h.selectedAlpha=d;h.notSelectedAlpha=k;h.selectedSegmentForShader=new Float32Array(8);h.segmentColorShaderManager=new l.SegmentColorShaderManager("segmentColorHash");h.hashTableManager=new e.HashTableShaderManager("visibleSegments");h.gpuHashTable=e.GPUHashTable.get(h.gl,h.displayState.visibleSegments.hashTable);h.registerSignalBinding(c.segmentSelectionState.changed.add(h.redrawNeeded.dispatch,h));h.registerSignalBinding(c.segmentColorHash.changed.add(h.redrawNeeded.dispatch,h));h.registerSignalBinding(c.visibleSegments.changed.add(h.redrawNeeded.dispatch,
h));h.registerSignalBinding(d.changed.add(function(){h.redrawNeeded.dispatch()}));h.registerSignalBinding(k.changed.add(function(){h.redrawNeeded.dispatch()}));return h}c(f,d);a(f,[{key:"getShaderKey",value:function(){return"sliceview.SegmentationRenderLayer"}},{key:"defineShader",value:function(a){b(Object.getPrototypeOf(f.prototype),"defineShader",this).call(this,a);this.hashTableManager.defineShader(a);this.segmentColorShaderManager.defineShader(a);a.addUniform("highp vec4","uSelectedSegment",
2);a.addUniform("highp float","uShowAllSegments");a.addUniform("highp float","uSelectedAlpha");a.addUniform("highp float","uNotSelectedAlpha");a.setFragmentMain("\n  uint64_t value = toUint64(getDataValue());\n  float alpha = uSelectedAlpha;\n  float saturation = 1.0;\n  if (value.low == vec4(0,0,0,0) && value.high == vec4(0,0,0,0)) {\n    emit(vec4(vec4(0, 0, 0, 0)));\n    return;\n  }\n  bool has = uShowAllSegments > 0.0 ? true : "+this.hashTableManager.hasFunctionName+"(value);\n  if (uSelectedSegment[0] == value.low && uSelectedSegment[1] == value.high) {\n    saturation = has ? 0.5 : 0.75;\n  } else if (!has) {\n    alpha = uNotSelectedAlpha;\n  }\n  vec3 rgb = segmentColorHash(value);\n  emit(vec4(mix(vec3(1.0,1.0,1.0), rgb, saturation), alpha));\n")}},
{key:"beginSlice",value:function(a){a=b(Object.getPrototypeOf(f.prototype),"beginSlice",this).call(this,a);var c=this.gl,d=this.selectedSegmentForShader,e=this.displayState,g=this.displayState,k=g.segmentSelectionState,g=g.visibleSegments;if(k.hasSelectedSegment)for(var h=k.selectedSegment,k=h.low,h=h.high,l=0;4>l;++l)d[l]=(k>>8*l&255)/255,d[4+l]=(h>>8*l&255)/255;else d.fill(0);c.uniform1f(a.uniform("uSelectedAlpha"),this.selectedAlpha.value);c.uniform1f(a.uniform("uNotSelectedAlpha"),this.notSelectedAlpha.value);
c.uniform4fv(a.uniform("uSelectedSegment"),d);c.uniform1f(a.uniform("uShowAllSegments"),g.hashTable.size?0:1);this.hashTableManager.enable(c,a,this.gpuHashTable);this.segmentColorShaderManager.enable(c,a,e.segmentColorHash);return a}},{key:"endSlice",value:function(a){this.hashTableManager.disable(this.gl,a);b(Object.getPrototypeOf(f.prototype),"endSlice",this).call(this,a)}}]);return f}(r.RenderLayer);d.SegmentationRenderLayer=h},function(h,d,f){function g(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var c=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),a=function n(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,
b);if(void 0===d)return a=Object.getPrototypeOf(a),null===a?void 0:n(a,b,c);if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)},b=f(118),e=f(51);h=f(11);var l=f(23);f=function(d){function f(){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");for(var a=arguments.length,c=Array(a),d=0;d<a;d++)c[d]=arguments[d];var e,a=(e=Object.getPrototypeOf(f)).call.apply(e,[].concat([this],$jscomp.arrayFromIterable(c)));if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
e=!a||"object"!==typeof a&&"function"!==typeof a?this:a;e.hashTable=new b.HashTable;e.changed=new l.Signal;return e}g(f,d);$jscomp.initSymbol();$jscomp.initSymbolIterator();c(f,[{key:"initializeCounterpart",value:function(b){var c=1>=arguments.length||void 0===arguments[1]?{}:arguments[1];c.type="Uint64Set";a(Object.getPrototypeOf(f.prototype),"initializeCounterpart",this).call(this,b,c)}},{key:"disposed",value:function(){a(Object.getPrototypeOf(f.prototype),"disposed",this).call(this);this.changed=
this.hashTable=void 0}},{key:"add_",value:function(a){return this.hashTable.add(a.low,a.high)}},{key:"add",value:function(a){if(this.add_(a)){var b=this.rpc;b&&b.invoke("Uint64Set.add",{id:this.rpcId,value:a});this.changed.dispatch(a,!0)}}},{key:"has",value:function(a){return this.hashTable.has(a.low,a.high)}},{key:Symbol.iterator,value:function(){function a(h,l){for(;;)switch(b){case 0:g=new e.Uint64,$jscomp.initSymbol(),$jscomp.initSymbolIterator(),f=$jscomp.makeIterator(k.hashTable[Symbol.iterator]()),
d=f.next();case 1:if(d.done){b=3;break}c=d.value;g.low=c[0];g.high=c[1];b=4;return{value:g,done:!1};case 4:if(void 0===l){b=5;break}b=-1;throw l;case 5:case 2:d=f.next();b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,c,d,f,g,k=this,h={next:function(b){return a(b,void 0)},throw:function(b){return a(void 0,b)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();h[Symbol.iterator]=function(){return this};return h}},{key:"delete_",value:function(a){return this.hashTable.delete(a.low,
a.high)}},{key:"delete",value:function(a){if(this.delete_(a)){var b=this.rpc;b&&b.invoke("Uint64Set.delete",{id:this.rpcId,value:a});this.changed.dispatch(a,!1)}}},{key:"clear",value:function(){if(this.hashTable.clear()){var a=this.rpc;a&&a.invoke("Uint64Set.clear",{id:this.rpcId});this.changed.dispatch(null,!1)}}},{key:"size",get:function(){return this.hashTable.size}}],[{key:"makeWithCounterpart",value:function(a){var b=new f;b.initializeCounterpart(a);return b}}]);return f}(h.SharedObjectCounterpart);
d.Uint64Set=f;h.registerRPC("Uint64Set.add",function(a){var b=this.get(a.id);b.add_(a.value)&&b.changed.dispatch()});h.registerRPC("Uint64Set.delete",function(a){var b=this.get(a.id);b.delete_(a.value)&&b.changed.dispatch()});h.registerRPC("Uint64Set.clear",function(a){a=this.get(a.id);a.hashTable.clear()&&a.changed.dispatch()});h.registerSharedObject("Uint64Set",f)},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||
"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=
!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var b=f(51);f(71);f(128);var e=new b.Uint64;f=function(b){function d(a){if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");var b=g(this,Object.getPrototypeOf(d).call(this));b.displayState=a;b.element=document.createElement("div");b.clearButton=document.createElement("button");b.itemContainer=document.createElement("span");b.items=new Map;var c=b.element,e=b.clearButton,
f=b.itemContainer;c.className="segment-set-widget noselect";e.className="clear-button";e.title="Remove all segment IDs";b.registerEventListener(e,"click",function(){b.visibleSegments.clear()});f.className="item-container";c.appendChild(f);f.appendChild(e);b.registerSignalBinding(a.visibleSegments.changed.add(b.handleSetChanged,b));b.registerSignalBinding(a.segmentColorHash.changed.add(b.handleColorChanged,b));a=$jscomp.makeIterator(a.visibleSegments);for(c=a.next();!c.done;c=a.next())b.addElement(c.value.toString());
b.updateClearButtonVisibility();return b}c(d,b);a(d,[{key:"updateClearButtonVisibility",value:function(){this.clearButton.style.display=0<this.displayState.visibleSegments.size?"":"none"}},{key:"handleSetChanged",value:function(a,b){this.updateClearButtonVisibility();var c=this.items;if(null===a){for(var d=this.itemContainer,e=this.clearButton;;){var f=d.lastElementChild;if(f===e)break;d.removeChild(f)}c.clear()}else b?this.addElement(a.toString()):(d=a.toString(),e=c.get(d),e.parentElement.removeChild(e),
c.delete(d))}},{key:"addElement",value:function(a){var b=document.createElement("button");b.className="segment-button";b.textContent=a;b.title="Remove segment ID "+a;var c=this;b.addEventListener("click",function(){e.parseString(this.textContent);c.visibleSegments.delete(e)});b.addEventListener("mouseenter",function(){e.parseString(this.textContent);c.segmentSelectionState.set(e)});b.addEventListener("mouseleave",function(){e.parseString(this.textContent);c.segmentSelectionState.set(null)});this.setItemColor(b);
this.itemContainer.appendChild(b);this.items.set(a,b)}},{key:"setItemColor",value:function(a){e.parseString(a.textContent);a.style.backgroundColor=this.segmentColorHash.computeCssColor(e)}},{key:"handleColorChanged",value:function(){var a=this;this.items.forEach(function(b){a.setItemColor(b)})}},{key:"disposed",value:function(){var a=this.element,b=a.parentElement;b&&b.removeChild(a)}},{key:"visibleSegments",get:function(){return this.displayState.visibleSegments}},{key:"segmentColorHash",get:function(){return this.displayState.segmentColorHash}},
{key:"segmentSelectionState",get:function(){return this.displayState.segmentSelectionState}}]);return d}(h.RefCounted);d.SegmentSetWidget=f},function(h,d){},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&
b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var b=f(7),e=f(51),l=f(23);f(71);f(130);f=function(d){function f(){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");
var a=g(this,Object.getPrototypeOf(f).call(this));a.element=document.createElement("form");a.label=document.createElement("label");a.input=document.createElement("input");a.value=new e.Uint64;a.valueEntered=new l.Signal;var b=a.element,c=a.label,d=a.input;b.className="uint64-entry noselect";b.appendChild(c);c.appendChild(d);a.registerEventListener(b,"submit",function(b){b.preventDefault();a.validateInput()&&(a.input.value="",a.input.classList.remove("valid-input","invalid-input"),a.valueEntered.dispatch(a.value))});
a.registerEventListener(b,"input",function(){""===a.input.value?a.input.classList.remove("valid-input","invalid-input"):a.validateInput()?a.input.classList.remove("invalid-input"):a.input.classList.add("invalid-input")});return a}c(f,d);a(f,[{key:"validateInput",value:function(){return this.value.parseString(this.input.value)}},{key:"disposed",value:function(){b.removeFromParent(this.element)}}]);return f}(h.RefCounted);d.Uint64EntryWidget=f},function(h,d){},function(h,d){},function(h,d){var f=0;
d.associateLabelWithElement=function(d,c){""===c.id&&(c.id="unique-id-for-association-"+f++);d.setAttribute("for",c.id)}},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,
enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){var b=document.createElement("div");b.textContent=a.value;return b}var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),e=f(32);h=f(12);var l=f(7),r=f(134),n=f(96),k=f(135),p=f(9),
m=f(136),t=f(132),q=f(23);f(137);$jscomp.initSymbol();var v=Symbol("autocompleteIndex");d.makeDefaultCompletionElement=a;d.makeCompletionElementWithDescription=function(a){var b=document.createElement("div");b.className="autocomplete-completion-with-description";b.textContent=a.value;var c=document.createElement("div");c.className="autocomplete-completion-description";c.textContent=a.description||"";b.appendChild(c);return b};var x=new n.KeySequenceMap({arrowdown:"cycle-next-active-completion",arrowup:"cycle-prev-active-completion",
tab:"choose-active-completion-or-prefix",enter:"choose-active-completion"}),w=new Map([["cycle-next-active-completion",function(){this.cycleActiveCompletion(1);return!0}],["cycle-prev-active-completion",function(){this.cycleActiveCompletion(-1);return!0}],["choose-active-completion-or-prefix",function(){return this.selectActiveCompletion(!0)}],["choose-active-completion",function(){return this.selectActiveCompletion(!1)}]]);f=function(d){function f(a){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");
var b=g(this,Object.getPrototypeOf(f).call(this));b.inputChanged=new q.Signal;b.prevInputValue="";b.completionsVisible=!1;b.activeCompletionPromise=null;b.hasFocus=!1;b.completionResult=null;b.dropdownContentsStale=!0;b.updateHintScrollPositionTimer=null;b.completionElements=null;b.hasResultForDropdown=!1;b.commonPrefix="";b.activeIndex=-1;b.dropdownStyleStale=!0;b.completer=a.completer;a=a.delay;var c=b.scheduleUpdateCompletions=e(function(){var a=b.activeCompletionPromise=b.completer(b.value);null!==
a&&a.then(function(c){b.activeCompletionPromise===a&&(b.setCompletions(c),b.activeCompletionPromise=null)})},void 0===a?200:a);b.registerDisposer(function(){c.cancel()});a=b.element=document.createElement("div");a.className="autocomplete";var d=document.createElement("div");d.className="autocomplete-dropdown-wrapper";var h=b.dropdownElement=document.createElement("div");h.className="autocomplete-dropdown";var k=b.promptElement=document.createElement("label");k.className="autocomplete-prompt";var l=
b.inputWrapperElement=document.createElement("div");l.className="autocomplete-input-wrapper";a.appendChild(k);var m=b.inputElement=document.createElement("input");m.type="text";m.autocomplete="off";m.spellcheck=!1;m.className="autocomplete-input";t.associateLabelWithElement(k,m);k=b.hintElement=document.createElement("input");k.type="text";k.spellcheck=!1;k.className="autocomplete-hint";k.disabled=!0;l.appendChild(k);l.appendChild(m);d.appendChild(l);d.appendChild(h);a.appendChild(d);b.registerInputHandler();
b.handleInputChanged("");b.registerEventListener(b.inputElement,"focus",function(){b.hasFocus||(b.hasFocus=!0,b.dropdownStyleStale=!0,b.updateDropdown())});b.registerEventListener(b.inputElement,"blur",function(){b.hasFocus&&(b.hasFocus=!1,b.updateDropdown())});b.registerEventListener(a.ownerDocument.defaultView,"resize",function(){b.dropdownStyleStale=!0});b.registerEventListener(a.ownerDocument.defaultView,"scroll",function(){b.dropdownStyleStale=!0});b.registerEventListener(b.dropdownElement,"mousedown",
b.handleDropdownMousedown.bind(b));b.registerEventListener(b.inputElement,"keydown",function(){b.hintScrollPositionMayBeStale()});b.registerEventListener(b.inputElement,"mousemove",function(a){0!==a.buttons&&b.hintScrollPositionMayBeStale()});(b.keyboardHandler=b.registerDisposer(new n.KeyboardShortcutHandler(m,x,b.handleKeyCommand.bind(b)))).allShortcutsAreGlobal=!0;return b}c(f,d);b(f,[{key:"hintScrollPositionMayBeStale",value:function(){""!==this.hintElement.value&&this.scheduleUpdateHintScrollPosition()}},
{key:"handleDropdownMousedown",value:function(a){this.inputElement.focus();for(var b=this.dropdownElement,c=a.target;c instanceof HTMLElement;c=c.parentElement){var d=c[v];if(void 0!==d){this.selectCompletion(d);break}if(c===b)break}a.preventDefault()}},{key:"cycleActiveCompletion",value:function(a){if(null!==this.completionResult){var b=this.activeIndex,c=this.completionResult.completions.length;this.setActiveIndex(-1===b?0<a?0:c-1:(b+a+c)%c)}}},{key:"handleKeyCommand",value:function(a){return w.get(a).call(this)}},
{key:"registerInputHandler",value:function(){for(var a=this,b=function(b){b=a.inputElement.value;b!==a.prevInputValue&&(a.prevInputValue=b,a.handleInputChanged(b))},c=$jscomp.makeIterator(["input"]),d=c.next();!d.done;d=c.next())this.registerEventListener(this.inputElement,d.value,b,!1)}},{key:"shouldShowDropdown",value:function(){return null!==this.completionResult&&this.hasFocus?this.hasResultForDropdown:!1}},{key:"updateDropdownStyle",value:function(){r.positionDropdown(this.dropdownElement,this.inputElement,
{horizontal:!1});this.dropdownStyleStale=!1}},{key:"updateDropdown",value:function(){var b=this;this.shouldShowDropdown()?function(){var c=b.dropdownElement,d=b.activeIndex;b.dropdownContentsStale&&function(){var e=b.completionResult,f=e.makeElement,g=void 0===f?a:f;b.completionElements=e.completions.map(function(a,b){var f=g.call(e,a);f[v]=b;f.classList.add("autocomplete-completion");d===b&&f.classList.add("autocomplete-completion-active");c.appendChild(f);return f});b.dropdownContentsStale=!1}();
b.dropdownStyleStale&&b.updateDropdownStyle();b.completionsVisible||(c.style.display="block",b.completionsVisible=!0);-1!==d&&m.scrollIntoViewIfNeeded(b.completionElements[d])}():this.completionsVisible&&(this.dropdownElement.style.display="none",this.completionsVisible=!1)}},{key:"setCompletions",value:function(a){this.clearCompletions();var b=a.completions;0!==b.length&&(this.completionResult=a,1===b.length?(b=b[0],a.showSingleResult?this.hasResultForDropdown=!0:b.value.startsWith(this.prevInputValue)?
this.hasResultForDropdown=!1:this.hasResultForDropdown=!0,this.setActiveIndex(0)):(this.hasResultForDropdown=!0,b=k.longestCommonPrefix(function(){function b(g,k){for(;;)switch(c){case 0:f=$jscomp.makeIterator(a.completions),e=f.next();case 1:if(e.done){c=3;break}d=e.value;c=4;return{value:d.value,done:!1};case 4:if(void 0===k){c=5;break}c=-1;throw k;case 5:case 2:e=f.next();c=1;break;case 3:c=-1;default:return{value:void 0,done:!0}}}var c=0,d,e,f,g={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,
a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();g[Symbol.iterator]=function(){return this};return g}()),b=this.getCompletedValue(b),b.startsWith(this.prevInputValue)&&(this.commonPrefix=b,this.setHintValue(b))),this.updateDropdown())}},{key:"scheduleUpdateHintScrollPosition",value:function(){if(null===this.updateHintScrollPositionTimer){var a=this;this.updateHintScrollPositionTimer=setTimeout(function(){a.updateHintScrollPosition()},0)}}},{key:"setHintValue",
value:function(a){var b=this.prevInputValue;a!==b&&a.startsWith(b)||(a="");this.hintElement.value=a;this.scheduleUpdateHintScrollPosition()}},{key:"setActiveIndex",value:function(a){if(!this.dropdownContentsStale){var b=this.activeIndex;-1!==b&&this.completionElements[b].classList.remove("autocomplete-completion-active");-1!==a&&(b=this.completionElements[a],b.classList.add("autocomplete-completion-active"),m.scrollIntoViewIfNeeded(b))}-1!==a&&this.setHintValue(this.getCompletedValueByIndex(a));this.activeIndex=
a}},{key:"getCompletedValueByIndex",value:function(a){return this.getCompletedValue(this.completionResult.completions[a].value)}},{key:"getCompletedValue",value:function(a){return this.prevInputValue.substring(0,this.completionResult.offset)+a}},{key:"selectActiveCompletion",value:function(a){var b=this.activeIndex;if(-1===b){if(!a)return!1;a=this.commonPrefix;return a.length>this.value.length?(this.value=a,!0):!1}a=this.getCompletedValueByIndex(b);if(this.value===a)return!1;this.value=a;return!0}},
{key:"selectCompletion",value:function(a){this.value=this.getCompletedValueByIndex(a)}},{key:"updateHintScrollPosition",value:function(){this.updateHintScrollPositionTimer=null;this.hintElement.scrollLeft=this.inputElement.scrollLeft}},{key:"cancelActiveCompletion",value:function(){p.cancelPromise(this.activeCompletionPromise);this.activeCompletionPromise=null}},{key:"handleInputChanged",value:function(a){this.cancelActiveCompletion();this.hintElement.value="";this.clearCompletions();this.inputChanged.dispatch(a);
this.scheduleUpdateCompletions()}},{key:"clearCompletions",value:function(){null!==this.completionResult&&(this.activeIndex=-1,this.completionElements=this.completionResult=null,this.dropdownStyleStale=this.dropdownContentsStale=!0,this.commonPrefix="",l.removeChildren(this.dropdownElement),this.updateDropdown())}},{key:"disposed",value:function(){l.removeFromParent(this.element);this.cancelActiveCompletion();null!==this.updateHintScrollPositionTimer&&(clearTimeout(this.updateHintScrollPositionTimer),
this.updateHintScrollPositionTimer=null)}},{key:"disabled",get:function(){return this.inputElement.disabled},set:function(a){this.inputElement.disabled=a}},{key:"value",get:function(){return this.prevInputValue},set:function(a){a!==this.prevInputValue&&(this.prevInputValue=this.inputElement.value=a,this.handleInputChanged(a))}}]);return f}(h.RefCounted);d.AutocompleteTextInput=f},function(h,d){d.positionDropdown=function(d,g){var c=2>=arguments.length||void 0===arguments[2]?{}:arguments[2],a=c.horizontal,
b=void 0===a?!1:a,a=c.vertical,a=void 0===a?!0:a,e=c.topMargin,e=void 0===e?6:e,h=c.bottomMargin,h=void 0===h?6:h,r=c.leftMargin,r=void 0===r?6:r,n=c.rightMargin,k=void 0===n?6:n,n=c.maxHeight,n=void 0===n?!0:n,c=c.maxWidth,p=void 0===c?!0:c,c=g.getBoundingClientRect();if(b){var b=c.right,m=d.ownerDocument.documentElement.clientHeight-c.left;b>m?(d.style.left="",d.style.right="0",p&&(d.style.maxWidth=b-r+"px")):(d.style.right="",d.style.left="0",p&&(d.style.maxWidth=m-k+"px"))}a&&(a=c.top-e,b=d.ownerDocument.documentElement.clientHeight-
c.bottom-h,a>3*b?(d.style.top="",d.style.bottom="100%",n&&(d.style.maxHeight=a+"px")):(d.style.top="100%",d.style.bottom="",n&&(d.style.maxHeight=b+"px")))}},function(h,d){d.longestCommonPrefix=function(d){$jscomp.initSymbol();$jscomp.initSymbolIterator();d=d[Symbol.iterator]();var g=d.next(),c=g.value;if(g.done)return"";for(g=c.length;0<g;){var a=d.next(),b=a.value;if(a.done)break;for(a=0;a<g&&c.charCodeAt(a)===b.charCodeAt(a);++a);g=a}return c.substring(0,g)}},function(h,d){d.scrollIntoViewIfNeeded=
function(d){var g=d.parentElement,c=d.offsetLeft-g.clientLeft,a=d.offsetTop-g.clientTop,b=g.scrollLeft,e=g.scrollTop,a=Math.max(0,a+d.offsetHeight-(e+g.clientHeight))||Math.min(0,a-e);g.scrollLeft+=Math.max(0,c+d.offsetWidth-(b+g.clientWidth))||Math.min(0,c-b);g.scrollTop+=a}},function(h,d){},function(h,d){d.makeHiddenSubmitButton=function(){var d=document.createElement("button");d.type="submit";d.className="hidden-submit-button";d.style.margin="0";d.style.border="0";d.style.padding="0";d.style.width=
"0";d.style.height="0";d.style.overflow="hidden";d.tabIndex=-1;return d}},function(h,d){},function(h,d,f){function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);
a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var b=function(){return function(a,b){if(Array.isArray(a))return a;$jscomp.initSymbol();$jscomp.initSymbolIterator();if(Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{$jscomp.initSymbol();$jscomp.initSymbolIterator();for(var g=a[Symbol.iterator](),k;!(d=(k=g.next()).done)&&(c.push(k.value),!b||c.length!==b);d=
!0);}catch(h){e=!0,f=h}finally{try{if(!d&&g["return"])g["return"]()}finally{if(e)throw f;}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance");}}(),e=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),l=f(99),r=f(100);h=f(12);var n=f(7),k=f(134),p=f(141);f(71);f(142);var m=function(b){function d(a,
b){g(this,d);var e=c(this,Object.getPrototypeOf(d).call(this));e.layer=a;e.panel=b;var f=e.element=document.createElement("span");f.className="layer-item-parent noselect";var k=e.widgetElement=document.createElement("span");k.className="layer-item noselect";f.appendChild(k);var h=e.labelElement=document.createElement("span");h.className="layer-item-label";var m=e.layerNumberElement=document.createElement("span");m.className="layer-item-number";var n=e.valueElement=document.createElement("span");n.className=
"layer-item-value";var p=document.createElement("span");p.title="Delete layer";p.className="layer-item-close";e.registerEventListener(p,"click",function(a){e.panel.layerManager.removeManagedLayer(e.layer)});k.appendChild(m);k.appendChild(h);k.appendChild(n);k.appendChild(p);e.registerEventListener(k,"click",function(b){a.setVisible(!a.visible)});e.registerEventListener(f,"mousedown",function(a){0===a.button&&e.panel.setDragging(!0)});e.registerEventListener(f,"mouseup",function(a){0===a.button&&e.panel.setDragging(!1)});
e.registerEventListener(k,"dblclick",function(b){a instanceof r.ManagedUserLayerWithSpecification&&new l.LayerDialog(e.panel.manager,a)});k=e.dropdownElement=document.createElement("div");e.registerEventListener(k,"mousedown",function(a){a.stopPropagation()});e.setupDropdownElement();e.handleLayerChanged();e.registerSignalBinding(a.layerChanged.add(e.handleLayerChanged,e));f.appendChild(k);e.registerEventListener(f,"mouseenter",function(){e.hovering=!0;e.updateDropdownState()});e.registerEventListener(f,
"mouseleave",function(a){e.hovering=!1;e.updateDropdownState()});return e}a(d,b);e(d,[{key:"updateDropdownState",value:function(){var a=this.dropdownElement.style;if(this.hovering&&!this.panel.dragging&&0<this.dropdownElement.childElementCount){if("flex"!==a.display&&(a.display="flex",this.dropdown))this.dropdown.onShow();k.positionDropdown(this.dropdownElement,this.widgetElement)}else if("none"!==a.display&&(this.dropdownElement.style.display="none",this.dropdown))this.dropdown.onHide()}},{key:"setupDropdownElement",
value:function(){this.dropdownElement.className="layer-dropdown"}},{key:"update",value:function(){var a=this.layer;this.labelElement.textContent=a.name;this.widgetElement.setAttribute("layer-visible",a.visible.toString())}},{key:"handleLayerChanged",value:function(){var a=this.layer.layer;a!==this.userLayer&&(this.dropdown&&(this.dropdown.dispose(),n.removeChildren(this.dropdownElement),this.setupDropdownElement()),this.dropdown=(this.userLayer=a)?a.makeDropdown(this.dropdownElement):void 0)}},{key:"disposed",
value:function(){this.dropdown&&this.dropdown.dispose();this.element.parentElement.removeChild(this.element)}}]);return d}(h.RefCounted);f=function(d){function f(a,b){g(this,f);var d=c(this,Object.getPrototypeOf(f).call(this));d.element=a;d.manager=b;d.layerWidgets=new Map;d.layerUpdateNeeded=!0;d.valueUpdateNeeded=!1;d.dragging=!1;a.className="layer-panel";d.registerSignalBinding(b.layerSelectedValues.changed.add(d.handleLayerValuesChanged,d));d.registerSignalBinding(b.layerManager.layersChanged.add(d.handleLayersChanged,
d));var e=d.addButton=document.createElement("button");e.className="layer-add-button";e.title="Add layer";d.registerEventListener(e,"click",function(){d.addLayerMenu()});a.appendChild(e);d.update();var k=new p(d.element,{draggable:".layer-item-parent",onStart:function(a){d.setDragging(!0);d.element.classList.add("sorting-in-progress")},onEnd:function(a){d.setDragging(!1);d.element.classList.remove("sorting-in-progress");d.layerManager.reorderManagedLayer(a.oldIndex,a.newIndex)},onMove:function(a){return a.related!==
d.addButton}});d.registerDisposer(function(){k.destroy()});return d}a(f,d);e(f,[{key:"setDragging",value:function(a){this.dragging=a;a=$jscomp.makeIterator(this.layerWidgets.values());for(var b=a.next();!b.done;b=a.next())b.value.updateDropdownState()}},{key:"dispose",value:function(){this.layerWidgets.forEach(function(a){return a.dispose()});this.layerWidgets=void 0}},{key:"handleLayersChanged",value:function(){this.layerUpdateNeeded=!0;this.handleLayerValuesChanged()}},{key:"handleLayerValuesChanged",
value:function(){this.valueUpdateNeeded||(this.valueUpdateNeeded=!0,requestAnimationFrame(this.update.bind(this)))}},{key:"update",value:function(){this.valueUpdateNeeded=!1;this.updateLayers();for(var a=this.manager.layerSelectedValues,c=$jscomp.makeIterator(this.layerWidgets),d=c.next();!d.done;d=c.next()){var e=b(d.value,2),d=e[1],f=e[0].layer,e="";null!==f&&(f=a.get(f),void 0!==f&&(e=""+f));d.valueElement.textContent=e}}},{key:"updateLayers",value:function(){var a=this;if(this.layerUpdateNeeded){this.layerUpdateNeeded=
!1;var c=this.element,d=new Set,e=c.firstElementChild;this.manager.layerManager.managedLayers.forEach(function(b,f){d.add(b);var g=a.layerWidgets.get(b);void 0===g&&(g=new m(b,a),a.layerWidgets.set(b,g));g.layerNumberElement.textContent=""+(1+f);g.update();g.element!==e&&c.insertBefore(g.element,a.addButton)});for(var f=$jscomp.makeIterator(this.layerWidgets),g=f.next();!g.done;g=f.next()){var k=b(g.value,2),g=k[0],k=k[1];d.has(g)||(this.layerWidgets.delete(g),k.dispose())}}}},{key:"addLayerMenu",
value:function(){new l.LayerDialog(this.manager)}},{key:"layerManager",get:function(){return this.manager.layerManager}}]);return f}(h.RefCounted);d.LayerPanel=f},function(h,d,f){var g,c;(function(a){!(g=a,c="function"===typeof g?g.call(d,f,d,h):g,void 0!==c&&(h.exports=c))})(function(){function a(a,b){if(!a||!a.nodeType||1!==a.nodeType)throw"Sortable: `el` must be HTMLElement, and not "+{}.toString.call(a);this.el=a;this.options=b=C({},b);a[za]=this;var c={group:Math.random(),sort:!0,disabled:!1,
store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(a.nodeName)?"li":">*",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",ignore:"a, img",filter:null,animation:0,setData:function(a,b){a.setData("Text",b.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1},e;for(e in c)e in b||(b[e]=c[e]);Ob(b);for(var f in this)"_"===f.charAt(0)&&(this[f]=this[f].bind(this));
this.nativeDraggable=b.forceFallback?!1:Nb;d(a,"mousedown",this._onTapStart);d(a,"touchstart",this._onTapStart);this.nativeDraggable&&(d(a,"dragover",this),d(a,"dragenter",this));Ia.push(this._onDragOver);b.store&&this.sort(b.store.get(this))}function b(a){A&&A.state!==a&&(k(A,"display",a?"none":""),!a&&A.state&&D.insertBefore(A,u),A.state=a)}function c(a,b,d){if(a){d=d||aa;b=b.split(".");var e=b.shift().toUpperCase(),f=new RegExp("\\s("+b.join("|")+")(?=\\s)","g");do if(">*"===e&&a.parentNode===
d||!(""!==e&&a.nodeName.toUpperCase()!=e||b.length&&((" "+a.className+" ").match(f)||[]).length!=b.length))return a;while(a!==d&&(a=a.parentNode))}return null}function d(a,b,c){a.addEventListener(b,c,!1)}function f(a,b,c){a.removeEventListener(b,c,!1)}function g(a,b,c){if(a)if(a.classList)a.classList[c?"add":"remove"](b);else{var d=(" "+a.className+" ").replace(ub," ").replace(" "+b+" "," ");a.className=(d+(c?" "+b:"")).replace(ub," ")}}function k(a,b,c){var d=a&&a.style;if(d){if(void 0===c)return aa.defaultView&&
aa.defaultView.getComputedStyle?c=aa.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];b in d||(b="-webkit-"+b);d[b]=c+("string"===typeof c?"":"px")}}function h(a,b,c){if(a){a=a.getElementsByTagName(b);b=0;var d=a.length;if(c)for(;b<d;b++)c(a[b],b);return a}return[]}function m(a,b,c,d,e,f,g){var k=aa.createEvent("Event"),h=(a||b[za]).options,l="on"+c.charAt(0).toUpperCase()+c.substr(1);k.initEvent(c,!0,!0);k.to=b;k.from=e||b;k.item=d||b;k.clone=A;k.oldIndex=f;
k.newIndex=g;b.dispatchEvent(k);h[l]&&h[l].call(a,k)}function t(a,b,c,d,e,f){var g,k=a[za],h=k.options.onMove,l;g=aa.createEvent("Event");g.initEvent("move",!0,!0);g.to=b;g.from=a;g.dragged=c;g.draggedRect=d;g.related=e||b;g.relatedRect=f||b.getBoundingClientRect();a.dispatchEvent(g);h&&(l=h.call(k,g));return l}function q(a){a.draggable=!1}function v(){Wa=!1}function x(a){a=a.tagName+a.className+a.src+a.href+a.textContent;for(var b=a.length,c=0;b--;)c+=a.charCodeAt(b);return c.toString(36)}function w(a){var b=
0;if(!a||!a.parentNode)return-1;for(;a&&(a=a.previousElementSibling);)"TEMPLATE"!==a.nodeName.toUpperCase()&&b++;return b}function z(a,b){var c,d;return function(){void 0===c&&(c=arguments,d=this,setTimeout(function(){1===c.length?a.call(d,c[0]):a.apply(d,c);c=void 0},b))}}function C(a,b){if(a&&b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}var u,y,B,A,D,E,H,G,P,R,W,Q,T,X,N={},ja,ca,ya,ub=/\s+/g,za="Sortable"+(new Date).getTime(),Ba=window,aa=Ba.document,Mb=Ba.parseInt,Nb=!!("draggable"in
aa.createElement("div")),bb=function(a){a=aa.createElement("x");a.style.cssText="pointer-events:auto";return"auto"===a.style.pointerEvents}(),Wa=!1,cb=Math.abs,Ia=[],sc=z(function(a,b,c){if(c&&b.scroll){var d,e=b.scrollSensitivity,f=b.scrollSpeed,g=a.clientX;a=a.clientY;var k=window.innerWidth,h=window.innerHeight,l,m;if(G!==c&&(H=b.scroll,G=c,!0===H)){H=c;do if(H.offsetWidth<H.scrollWidth||H.offsetHeight<H.scrollHeight)break;while(H=H.parentNode)}H&&(d=H,b=H.getBoundingClientRect(),l=(cb(b.right-
g)<=e)-(cb(b.left-g)<=e),m=(cb(b.bottom-a)<=e)-(cb(b.top-a)<=e));l||m||(l=(k-g<=e)-(g<=e),m=(h-a<=e)-(a<=e),(l||m)&&(d=Ba));if(N.vx!==l||N.vy!==m||N.el!==d)N.el=d,N.vx=l,N.vy=m,clearInterval(N.pid),d&&(N.pid=setInterval(function(){d===Ba?Ba.scrollTo(Ba.pageXOffset+l*f,Ba.pageYOffset+m*f):(m&&(d.scrollTop+=m*f),l&&(d.scrollLeft+=l*f))},24))}},30),Ob=function(a){var b=a.group;b&&"object"==typeof b||(b=a.group={name:b});["pull","put"].forEach(function(a){a in b||(b[a]=!0)});a.groups=" "+b.name+(b.put.join?
" "+b.put.join(" "):"")+" "};a.prototype={constructor:a,_onTapStart:function(a){var b=this,d=this.el,f=this.options,g=a.touches&&a.touches[0],k=(g||a).target,h=k,l=f.filter;if(!("mousedown"===a.type&&0!==a.button||f.disabled)&&(k=c(k,f.draggable,d))){Q=w(k);if("function"===typeof l){if(l.call(this,a,k,this)){m(b,h,"filter",k,d,Q);a.preventDefault();return}}else if(l&&(l=l.split(",").some(function(a){if(a=c(h,a.trim(),d))return m(b,a,"filter",k,d,Q),!0}))){a.preventDefault();return}f.handle&&!c(h,
f.handle,d)||this._prepareDragStart(a,g,k)}},_prepareDragStart:function(a,b,c){var e=this,f=e.el,k=e.options,m=f.ownerDocument;c&&!u&&c.parentNode===f&&(ja=a,D=f,u=c,y=u.parentNode,E=u.nextSibling,X=k.group,a=function(){e._disableDelayedDrag();u.draggable=!0;g(u,e.options.chosenClass,!0);e._triggerDragStart(b)},k.ignore.split(",").forEach(function(a){h(u,a.trim(),q)}),d(m,"mouseup",e._onDrop),d(m,"touchend",e._onDrop),d(m,"touchcancel",e._onDrop),k.delay?(d(m,"mouseup",e._disableDelayedDrag),d(m,
"touchend",e._disableDelayedDrag),d(m,"touchcancel",e._disableDelayedDrag),d(m,"mousemove",e._disableDelayedDrag),d(m,"touchmove",e._disableDelayedDrag),e._dragStartTimer=setTimeout(a,k.delay)):a())},_disableDelayedDrag:function(){var a=this.el.ownerDocument;clearTimeout(this._dragStartTimer);f(a,"mouseup",this._disableDelayedDrag);f(a,"touchend",this._disableDelayedDrag);f(a,"touchcancel",this._disableDelayedDrag);f(a,"mousemove",this._disableDelayedDrag);f(a,"touchmove",this._disableDelayedDrag)},
_triggerDragStart:function(a){a?(ja={target:u,clientX:a.clientX,clientY:a.clientY},this._onDragStart(ja,"touch")):this.nativeDraggable?(d(u,"dragend",this),d(D,"dragstart",this._onDragStart)):this._onDragStart(ja,!0);try{aa.selection?aa.selection.empty():window.getSelection().removeAllRanges()}catch(b){}},_dragStarted:function(){D&&u&&(g(u,this.options.ghostClass,!0),a.active=this,m(this,D,"start",u,D,Q))},_emulateDragOver:function(){if(ca&&(this._lastX!==ca.clientX||this._lastY!==ca.clientY)){this._lastX=
ca.clientX;this._lastY=ca.clientY;bb||k(B,"display","none");var a=aa.elementFromPoint(ca.clientX,ca.clientY),b=a,c=" "+this.options.group.name+"",d=Ia.length;if(b){do{if(b[za]&&-1<b[za].options.groups.indexOf(c)){for(;d--;)Ia[d]({clientX:ca.clientX,clientY:ca.clientY,target:a,rootEl:b});break}a=b}while(b=b.parentNode)}bb||k(B,"display","")}},_onTouchMove:function(b){if(ja){a.active||this._dragStarted();this._appendGhost();var c=b.touches?b.touches[0]:b,d=c.clientX-ja.clientX,e=c.clientY-ja.clientY,
d=b.touches?"translate3d("+d+"px,"+e+"px,0)":"translate("+d+"px,"+e+"px)";ya=!0;ca=c;k(B,"webkitTransform",d);k(B,"mozTransform",d);k(B,"msTransform",d);k(B,"transform",d);b.preventDefault()}},_appendGhost:function(){if(!B){var a=u.getBoundingClientRect(),b=k(u),c=this.options;B=u.cloneNode(!0);g(B,c.ghostClass,!1);g(B,c.fallbackClass,!0);k(B,"top",a.top-Mb(b.marginTop,10));k(B,"left",a.left-Mb(b.marginLeft,10));k(B,"width",a.width);k(B,"height",a.height);k(B,"opacity","0.8");k(B,"position","fixed");
k(B,"zIndex","100000");k(B,"pointerEvents","none");c.fallbackOnBody&&aa.body.appendChild(B)||D.appendChild(B);b=B.getBoundingClientRect();k(B,"width",2*a.width-b.width);k(B,"height",2*a.height-b.height)}},_onDragStart:function(a,b){var c=a.dataTransfer,e=this.options;this._offUpEvents();"clone"==X.pull&&(A=u.cloneNode(!0),k(A,"display","none"),D.insertBefore(A,u));b?("touch"===b?(d(aa,"touchmove",this._onTouchMove),d(aa,"touchend",this._onDrop),d(aa,"touchcancel",this._onDrop)):(d(aa,"mousemove",
this._onTouchMove),d(aa,"mouseup",this._onDrop)),this._loopId=setInterval(this._emulateDragOver,50)):(c&&(c.effectAllowed="move",e.setData&&e.setData.call(this,c,u)),d(aa,"drop",this),setTimeout(this._dragStarted,0))},_onDragOver:function(a){var d=this.el,f,g,h;g=this.options;f=g.group;var l=f.put,m=X===f,n=g.sort;void 0!==a.preventDefault&&(a.preventDefault(),!g.dragoverBubble&&a.stopPropagation());ya=!0;if(X&&!g.disabled&&(m?n||(h=!D.contains(u)):X.pull&&l&&(X.name===f.name||l.indexOf&&~l.indexOf(X.name)))&&
(void 0===a.rootEl||a.rootEl===this.el)&&(sc(a,g,this.el),!Wa))if(f=c(a.target,g.draggable,d),g=u.getBoundingClientRect(),h)b(!0),A||E?D.insertBefore(u,A||E):n||D.appendChild(u);else if(!(h=0===d.children.length||d.children[0]===B)&&(h=d===a.target)&&(f=d.lastElementChild,h=f.getBoundingClientRect(),h=f=(5<a.clientY-(h.top+h.height)||5<a.clientX-(h.right+h.width))&&f),h){if(f){if(f.animated)return;p=f.getBoundingClientRect()}b(m);!1!==t(D,d,u,g,f,p)&&(u.contains(d)||(d.appendChild(u),y=d),this._animate(g,
u),f&&this._animate(p,f))}else if(f&&!f.animated&&f!==u&&void 0!==f.parentNode[za]){P!==f&&(P=f,R=k(f),W=k(f.parentNode));var p=f.getBoundingClientRect(),q=p.right-p.left,r=p.bottom-p.top,n=/left|right|inline/.test(R.cssFloat+R.display)||"flex"==W.display&&0===W["flex-direction"].indexOf("row");h=f.offsetWidth>u.offsetWidth;l=f.offsetHeight>u.offsetHeight;q=.5<(n?(a.clientX-p.left)/q:(a.clientY-p.top)/r);a=f.nextElementSibling;r=t(D,d,u,g,f,p);!1!==r&&(Wa=!0,setTimeout(v,30),b(m),1===r||-1===r?m=
1===r:n?(m=u.offsetTop,n=f.offsetTop,m=m===n?f.previousElementSibling===u&&!h||q&&h:n>m):m=a!==u&&!l||q&&l,u.contains(d)||(m&&!a?d.appendChild(u):f.parentNode.insertBefore(u,m?a:f)),y=u.parentNode,this._animate(g,u),this._animate(p,f))}},_animate:function(a,b){var c=this.options.animation;if(c){var d=b.getBoundingClientRect();k(b,"transition","none");k(b,"transform","translate3d("+(a.left-d.left)+"px,"+(a.top-d.top)+"px,0)");b.offsetWidth;k(b,"transition","all "+c+"ms");k(b,"transform","translate3d(0,0,0)");
clearTimeout(b.animated);b.animated=setTimeout(function(){k(b,"transition","");k(b,"transform","");b.animated=!1},c)}},_offUpEvents:function(){var a=this.el.ownerDocument;f(aa,"touchmove",this._onTouchMove);f(a,"mouseup",this._onDrop);f(a,"touchend",this._onDrop);f(a,"touchcancel",this._onDrop)},_onDrop:function(b){var c=this.el,d=this.options;clearInterval(this._loopId);clearInterval(N.pid);clearTimeout(this._dragStartTimer);f(aa,"mousemove",this._onTouchMove);this.nativeDraggable&&(f(aa,"drop",
this),f(c,"dragstart",this._onDragStart));this._offUpEvents();if(b){ya&&(b.preventDefault(),!d.dropBubble&&b.stopPropagation());B&&B.parentNode.removeChild(B);if(u&&(this.nativeDraggable&&f(u,"dragend",this),q(u),g(u,this.options.ghostClass,!1),g(u,this.options.chosenClass,!1),D!==y?(T=w(u),0<=T&&(m(null,y,"sort",u,D,Q,T),m(this,D,"sort",u,D,Q,T),m(null,y,"add",u,D,Q,T),m(this,D,"remove",u,D,Q,T))):(A&&A.parentNode.removeChild(A),u.nextSibling!==E&&(T=w(u),0<=T&&(m(this,D,"update",u,D,Q,T),m(this,
D,"sort",u,D,Q,T)))),a.active)){if(null===T||-1===T)T=Q;m(this,D,"end",u,D,Q,T);this.save()}D=u=y=B=E=A=H=G=ja=ca=ya=T=P=R=X=a.active=null}},handleEvent:function(a){var b=a.type;"dragover"===b||"dragenter"===b?u&&(this._onDragOver(a),a.dataTransfer&&(a.dataTransfer.dropEffect="move"),a.preventDefault()):"drop"!==b&&"dragend"!==b||this._onDrop(a)},toArray:function(){for(var a=[],b,d=this.el.children,f=0,g=d.length,k=this.options;f<g;f++)b=d[f],c(b,k.draggable,this.el)&&a.push(b.getAttribute(k.dataIdAttr)||
x(b));return a},sort:function(a){var b={},d=this.el;this.toArray().forEach(function(a,f){var g=d.children[f];c(g,this.options.draggable,d)&&(b[a]=g)},this);a.forEach(function(a){b[a]&&(d.removeChild(b[a]),d.appendChild(b[a]))})},save:function(){var a=this.options.store;a&&a.set(this)},closest:function(a,b){return c(a,b||this.options.draggable,this.el)},option:function(a,b){var c=this.options;if(void 0===b)return c[a];c[a]=b;"group"===a&&Ob(c)},destroy:function(){var a=this.el;a[za]=null;f(a,"mousedown",
this._onTapStart);f(a,"touchstart",this._onTapStart);this.nativeDraggable&&(f(a,"dragover",this),f(a,"dragenter",this));Array.prototype.forEach.call(a.querySelectorAll("[draggable]"),function(a){a.removeAttribute("draggable")});Ia.splice(Ia.indexOf(this._onDragOver),1);this._onDrop();this.el=a=null}};a.utils={on:d,off:f,css:k,find:h,is:function(a,b){return!!c(a,b,a)},extend:C,throttle:z,closest:c,toggleClass:g,index:w};a.create=function(b,c){return new a(b,c)};a.version="1.4.2";return a})},function(h,
d){},function(h,d){d.withFlex=function(d,g){return function(c){c.style.flex=d;g(c)}};d.withStyle=function(d,g){return function(c){Object.assign(c.style,d);g(c)}};d.withAttributes=function(d,g){return function(c){Object.assign(c,d);g(c)}};d.box=function(d,g){return function(c){c.style.display="flex";c.style.flexDirection=d;for(var a=$jscomp.makeIterator(g),b=a.next();!b.done;b=a.next()){var b=b.value,e=c.ownerDocument.createElement("div");c.appendChild(e);b(e)}}}},function(h,d,f){function g(a,b){if(!(a instanceof
b))throw new TypeError("Cannot call a class as a function");}function c(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function a(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
b):a.__proto__=b)}var b=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var e=f(39),l=f(8),r=f(23),n=function(d){function f(a){g(this,f);var b=c(this,Object.getPrototypeOf(f).call(this));b.changed=new r.Signal;var d=!0;null==a&&(a=e.vec3.create(),d=!1);b.size=a;b.valid=d;return b}a(f,d);b(f,[{key:"reset",
value:function(){this.valid=!1;this.changed.dispatch()}},{key:"setValid",value:function(){this.valid||(this.valid=!0,this.changed.dispatch())}},{key:"toJSON",value:function(){return this.valid?Array.prototype.slice.call(this.size):void 0}},{key:"restoreState",value:function(a){try{l.parseFiniteVec(this.size,a),this.setValid()}catch(b){this.valid=!1}}},{key:"toString",value:function(){return this.valid?this.size.toString():null}},{key:"voxelFromSpatial",value:function(a,b){e.vec3.divide(a,b,this.size)}},
{key:"spatialFromVoxel",value:function(a,b){e.vec3.multiply(a,b,this.size)}}]);return f}(h.RefCounted);d.VoxelSize=n;var k=e.vec3.create(),p=e.quat.create(),m=function(d){function f(a,b){g(this,f);var d=c(this,Object.getPrototypeOf(f).call(this));d.voxelCoordinates=null;d.changed=new r.Signal;null==a&&(a=new n);d.voxelSize=a;var k=!0;null==b&&(b=e.vec3.create(),k=!1);d.spatialCoordinates=b;d.spatialCoordinatesValid=k;d.registerDisposer(a);d.registerSignalBinding(a.changed.add(d.handleVoxelSizeChanged,
d));return d}a(f,d);b(f,[{key:"reset",value:function(){this.spatialCoordinatesValid=!1;this.voxelCoordinates=null;this.changed.dispatch()}},{key:"getVoxelCoordinates",value:function(a){var b=this.voxelCoordinates;if(b)e.vec3.copy(a,b);else if(this.valid)this.voxelSize.voxelFromSpatial(a,this.spatialCoordinates);else return!1;return!0}},{key:"setVoxelCoordinates",value:function(a){var b=this.voxelSize;b.valid?(b.spatialFromVoxel(this.spatialCoordinates,a),this.markSpatialCoordinatesChanged()):(b=this.voxelCoordinates)?
e.vec3.copy(b,a):this.voxelCoordinates=e.vec3.clone(a);this.changed.dispatch()}},{key:"markSpatialCoordinatesChanged",value:function(){this.spatialCoordinatesValid=!0;this.voxelCoordinates=null;this.changed.dispatch()}},{key:"handleVoxelSizeChanged",value:function(){null==this.voxelCoordinates||this.spatialCoordinatesValid||(this.voxelSize.spatialFromVoxel(this.spatialCoordinates,this.voxelCoordinates),this.spatialCoordinatesValid=!0);this.voxelCoordinates=null;this.changed.dispatch()}},{key:"toJSON",
value:function(){var a=!0,b=this.voxelSize.toJSON(),c={};void 0!==b&&(a=!1,c.voxelSize=b);this.voxelCoordinatesValid?(this.getVoxelCoordinates(k),c.voxelCoordinates=Array.prototype.slice.call(k),a=!1):this.spatialCoordinatesValid&&(c.spatialCoordinates=Array.prototype.slice.call(this.spatialCoordinates),a=!1);return a?void 0:c}},{key:"restoreState",value:function(a){this.voxelSize.restoreState(a.voxelSize);this.spatialCoordinatesValid=!1;if(a.hasOwnProperty("voxelCoordinates"))try{var b=e.vec3.create();
l.parseFiniteVec(b,a.voxelCoordinates);this.setVoxelCoordinates(b)}catch(c){}if(a.hasOwnProperty("spatialCoordinates"))try{l.parseFiniteVec(this.spatialCoordinates,a.spatialCoordinates),this.markSpatialCoordinatesChanged()}catch(c){}}},{key:"snapToVoxel",value:function(){if(this.valid){for(var a=this.spatialCoordinates,b=this.voxelSize.size,c=0;3>c;++c){var d=b[c];a[c]=Math.round(a[c]/d)*d}this.changed.dispatch()}else if(a=this.voxelCoordinates,null!=a){for(b=0;3>b;++b)a[b]=Math.round(a[b]);this.changed.dispatch()}}},
{key:"valid",get:function(){return this.spatialCoordinatesValid&&this.voxelSize.valid}},{key:"voxelCoordinatesValid",get:function(){return this.valid||null!=this.voxelCoordinates}}]);return f}(h.RefCounted);d.SpatialPosition=m;var t=function(d){function f(a){g(this,f);var b=c(this,Object.getPrototypeOf(f).call(this));b.changed=new r.Signal;null==a&&(a=e.quat.create());b.orientation=a;return b}a(f,d);b(f,[{key:"toJSON",value:function(){var a=this.orientation;return 0===a[0]&&0===a[1]&&0===a[2]&&1===
a[3]?void 0:Array.prototype.slice.call(this.orientation)}},{key:"restoreState",value:function(a){try{l.parseFiniteVec(this.orientation,a),e.quat.normalize(this.orientation,this.orientation)}catch(b){e.quat.identity(this.orientation)}this.changed.dispatch()}},{key:"reset",value:function(){e.quat.identity(this.orientation);this.changed.dispatch()}},{key:"snap",value:function(){var a=e.mat3.create();e.mat3.fromQuat(a,this.orientation);for(var b=[!1,!1,!1],c=0;3>c;++c){for(var d=0,f=0,g=0;3>g;++g){var k=
a[3*c+g];a[3*c+g]=0;!b[g]&&Math.abs(k)>Math.abs(d)&&(d=k,f=g)}a[3*c+f]=Math.sign(d);b[f]=!0}e.quat.fromMat3(this.orientation,a);this.changed.dispatch()}}],[{key:"makeRelative",value:function(a,b){var c=new f(e.quat.multiply(e.quat.create(),a.orientation,b)),d=!1;c.registerSignalBinding(a.changed.add(function(){d||(g=!0,e.quat.multiply(c.orientation,a.orientation,b),c.changed.dispatch(),g=!1)}));var g=!1,k=e.quat.invert(e.quat.create(),b);c.registerSignalBinding(c.changed.add(function(){g||(d=!0,e.quat.multiply(a.orientation,
c.orientation,k),a.changed.dispatch(),d=!1)}));return c}}]);return f}(h.RefCounted);d.OrientationState=t;var q=function(d){function f(a,b){g(this,f);var d=c(this,Object.getPrototypeOf(f).call(this));d.changed=new r.Signal;null==a&&(a=new m);d.position=a;null==b&&(b=new t);d.orientation=b;d.registerDisposer(d.position);d.registerDisposer(d.orientation);d.registerSignalBinding(d.position.changed.add(d.changed.dispatch,d.changed));d.registerSignalBinding(d.orientation.changed.add(d.changed.dispatch,
d.changed));return d}a(f,d);b(f,[{key:"reset",value:function(){this.position.reset();this.orientation.reset()}},{key:"dispose",value:function(){this.position.changed.remove(this.changed.dispatch,this.changed)}},{key:"toMat4",value:function(a){e.mat4.fromRotationTranslation(a,this.orientation.orientation,this.position.spatialCoordinates)}},{key:"toJSON",value:function(){var a=this.position.toJSON(),b=this.orientation.toJSON();return void 0===a&&void 0===b?void 0:{position:a,orientation:b}}},{key:"restoreState",
value:function(a){this.position.restoreState(a.position);this.orientation.restoreState(a.orientation)}},{key:"snap",value:function(){this.orientation.snap();this.position.snapToVoxel();this.changed.dispatch()}},{key:"translateAbsolute",value:function(a){e.vec3.add(this.position.spatialCoordinates,this.position.spatialCoordinates,a);this.position.changed.dispatch()}},{key:"translateRelative",value:function(a){if(this.valid){var b=e.vec3.create();e.vec3.transformQuat(b,a,this.orientation.orientation);
e.vec3.add(this.position.spatialCoordinates,this.position.spatialCoordinates,b);this.position.changed.dispatch()}}},{key:"translateVoxelsRelative",value:function(a){if(this.valid){var b=e.vec3.create();e.vec3.transformQuat(b,a,this.orientation.orientation);e.vec3.multiply(b,b,this.position.voxelSize.size);e.vec3.add(this.position.spatialCoordinates,this.position.spatialCoordinates,b);this.position.changed.dispatch()}}},{key:"rotateRelative",value:function(a,b){var c=e.quat.create();e.quat.setAxisAngle(c,
a,b);var d=this.orientation.orientation;e.quat.multiply(d,d,c);this.orientation.changed.dispatch()}},{key:"rotateAbsolute",value:function(a,b,c){var d=e.quat.create();e.quat.setAxisAngle(d,a,b);a=this.orientation.orientation;if(void 0!==c){b=this.position.spatialCoordinates;var f=e.vec3.subtract(k,c,b),g=e.quat.invert(p,a);e.vec3.transformQuat(f,f,g);e.quat.multiply(a,d,a);e.vec3.transformQuat(b,f,a);e.vec3.subtract(b,c,b);this.position.changed.dispatch()}else e.quat.multiply(a,d,a);this.orientation.changed.dispatch()}},
{key:"valid",get:function(){return this.position.valid}}]);return f}(h.RefCounted);d.Pose=q;var v=function(){function a(){var b=0>=arguments.length||void 0===arguments[0]?Number.NaN:arguments[0],c=1>=arguments.length||void 0===arguments[1]?b:arguments[1];g(this,a);this.value_=b;this.defaultValue=c;this.changed=new r.Signal}b(a,[{key:"toJSON",value:function(){var a=this.value_,b=this.defaultValue;return Number.isNaN(a)&&Number.isNaN(b)||a===b?void 0:a}},{key:"restoreState",value:function(a){"number"===
typeof a&&Number.isFinite(a)&&0<a?this.value=a:this.value=this.defaultValue}},{key:"reset",value:function(){this.value=this.defaultValue}},{key:"zoomBy",value:function(a){var b=this.value_;Number.isNaN(b)||(this.value=b*a)}},{key:"value",get:function(){return this.value_},set:function(a){a!==this.value_&&(this.value_=a,this.changed.dispatch())}}]);return a}();d.TrackableZoomState=v;f=function(d){function f(){var a=0>=arguments.length||void 0===arguments[0]?new q:arguments[0],b=1>=arguments.length||
void 0===arguments[1]?Number.NaN:arguments[1];g(this,f);var d=c(this,Object.getPrototypeOf(f).call(this));d.pose=a;d.changed=new r.Signal;d.zoomFactor="number"===typeof b?new v(b):b;d.registerDisposer(a);d.registerSignalBinding(d.pose.changed.add(function(){d.changed.dispatch()}));d.registerSignalBinding(d.zoomFactor.changed.add(function(){d.changed.dispatch()}));d.registerSignalBinding(d.voxelSize.changed.add(function(){d.handleVoxelSizeChanged()}));d.handleVoxelSizeChanged();return d}a(f,d);b(f,
[{key:"reset",value:function(){this.pose.reset();this.zoomFactor.reset()}},{key:"setZoomFactorFromVoxelSize",value:function(){this.voxelSize.valid&&(this.zoomFactor.value=Math.min.apply(null,this.voxelSize.size))}},{key:"handleVoxelSizeChanged",value:function(){Number.isNaN(this.zoomFactor.value)&&this.setZoomFactorFromVoxelSize()}},{key:"toMat4",value:function(a){this.pose.toMat4(a);var b=this.zoomFactor.value;e.mat4.scale(a,a,e.vec3.fromValues(b,b,b))}},{key:"toJSON",value:function(){var a=this.pose.toJSON(),
b=this.zoomFactor.toJSON();return void 0===a&&void 0===b?void 0:{pose:a,zoomFactor:b}}},{key:"restoreState",value:function(a){a&&"object"===typeof a&&(this.pose.restoreState(a.pose),this.zoomFactor.restoreState(a.zoomFactor),this.handleVoxelSizeChanged(),this.changed.dispatch())}},{key:"zoomBy",value:function(a){this.zoomFactor.zoomBy(a)}},{key:"voxelSize",get:function(){return this.pose.position.voxelSize}},{key:"position",get:function(){return this.pose.position}},{key:"valid",get:function(){return this.pose.valid}}]);
return f}(h.RefCounted);d.NavigationState=f},function(h,d,f){function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function c(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
b):a.__proto__=b)}var a=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();h=f(12);var b=f(39);f(146);f=function(d){function f(a,c){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var d=g(this,Object.getPrototypeOf(f).call(this));d.element=a;d.viewer=c;d.positionElements=[];d.needsUpdate=
null;d.tempPosition=b.vec3.create();a.setAttribute("class","position-status-panel");for(var e=d.positionElements,h=function(c){var f=a.ownerDocument.createElement("label");f.className="position-status-coord";var g=a.ownerDocument.createElement("input");g.type="number";g.className="position-status-coord";f.textContent=b.AXES_NAMES[c];f.appendChild(g);a.appendChild(f);e.push(g);var h=!1;d.registerEventListener(g,"change",function(a){d.handleCoordinateChange()});d.registerEventListener(g,"input",function(a){h&&
(d.handleCoordinateChange(),h=!1);return!0});d.registerEventListener(g,"wheel",function(a){h=!0;g.focus();return!0});d.registerEventListener(g,"keydown",function(a){h=!1;return!0});d.registerEventListener(g,"mousedown",function(a){return h=!0});d.registerEventListener(g,"click",function(a){return!0});d.registerEventListener(g,"blur",function(a){h=!1;return!0})},t=0;3>t;++t)h(t);h=d.mouseElement=document.createElement("span");h.className="position-status-mouse";a.appendChild(h);h=c.mouseState;d.registerSignalBinding(c.navigationState.pose.changed.add(d.handleChange,
d));d.registerSignalBinding(h.changed.add(d.handleChange,d));d.handleChange();return d}c(f,d);a(f,[{key:"handleChange",value:function(){null==this.needsUpdate&&(this.needsUpdate=requestAnimationFrame(this.update.bind(this)))}},{key:"handleCoordinateChange",value:function(){var a=this.positionElements,b=this.viewer.navigationState.pose.position,c=this.tempPosition;if(b.voxelCoordinatesValid){b.getVoxelCoordinates(c);for(var d=0;3>d;++d){var e=parseFloat(a[d].value);Number.isNaN(e)||(c[d]=e)}b.setVoxelCoordinates(c)}}},
{key:"update",value:function(){this.needsUpdate=null;var a=this.viewer,b=a.mouseState,c=this.tempPosition,a=a.navigationState.pose.position;if(a.getVoxelCoordinates(c))for(var d=this.positionElements,e=0;3>e;++e)d[e].value=""+Math.floor(c[e]);a=a.voxelSize;d="";b.active&&(a.voxelFromSpatial(c,b.position),d="x "+Math.round(c[0])+"  y "+Math.round(c[1])+"  z "+Math.round(c[2]));this.mouseElement.textContent=d}},{key:"disposed",value:function(){for(var a=$jscomp.makeIterator(this.positionElements),b=
a.next();!b.done;b=a.next())this.element.removeChild(b.value);this.element=this.positionElements=void 0}}]);return f}(h.RefCounted);d.PositionStatusPanel=f},function(h,d){},function(h,d,f){function g(){try{var a=location.href.replace(/^[^#]+/,"");if(""===a||"#"===a||"#!"===a)a="#!{}";if(a.startsWith("#!")){if(a=a.slice(2),a=decodeURI(a),a!==m){m=a;var b=e.urlSafeParse(a);if("object"===typeof b){n=b;for(var c=$jscomp.makeIterator(Object.keys(n)),d=c.next();!d.done;d=c.next()){var f=d.value,g=l.get(f);
if(void 0!==g){a=f;b=g;try{k=b,b.restoreState(n[a])}catch(h){console.log("Failed to restore "+a+" state: "+h)}finally{k=null}}}}}}else m=null}catch(h){console.log(h)}}function c(){null!=t&&clearTimeout(t);t=setTimeout(a,500)}function a(){t=null;for(var a=!1,b=$jscomp.makeIterator(p),c=b.next();!c.done;c=b.next()){var c=c.value,d=r.get(c);void 0===d?n.hasOwnProperty(d)&&(a=!0):(a=!0,n[d]=c.toJSON())}p.clear();a&&(a=e.urlSafeStringify(n),a!==m&&(m=a,"{}"===m?history.replaceState(null,void 0,"#"):history.replaceState(null,
void 0,"#!"+m)))}function b(){k!==this&&(p.add(this),c())}var e=f(8),l=new Map,r=new Map,n={},k=null,p=new Set,m=null,t=null;d.delayHashUpdate=function(){null!=t&&c()};addEventListener("hashchange",g);d.registerTrackable=function(a,c){if(l.has(a))throw Error("Key "+JSON.stringify(a)+" already registered.");if(r.has(c))throw Error("Object already registered.");l.set(a,c);r.set(c,a);n.hasOwnProperty(a)&&c.restoreState(n[a]);c.changed.add(b,c);b.call(c)};d.unregisterTrackable=function(a){var c=l.get(a),
d=void 0;if(void 0!==c)d=a;else{d=r.get(a);if(void 0===d)throw Error("Key or object not registered.");c=a}l.delete(d);r.delete(c);c.changed.remove(b,c);b.call(c)};g()},function(h,d){}]);
